History

Add support for __FreeBSD_kernel__ kernel

Add support for kfreebsd-i386 and kfreebsd-amd64 Debian arch with thanks to Pierre Chifflier <chifflier@cpe.fr>.

Thomas Preud'homme committed 16 years ago

Commit 776364f1 parent 2887f405 files · +21 −13Browse files

Unified · Split

5 files
  1. lib/bcheck.c +4 −2
  2. libtcc.c +3 −0
  3. tcc.h +2 −1
  4. tccelf.c +8 −6
  5. tccrun.c +4 −4
lib/bcheck.c+4−2
@@ -21,7 +21,8 @@ · 20 unmodified lines
2121 #include <stdio.h>
2222 #include <stdarg.h>
2323 #include <string.h>
24−#if !defined(__FreeBSD__) && !defined(__DragonFly__) && !defined(__OpenBSD__)
24+#if !defined(__FreeBSD__) && !defined(__FreeBSD_kernel__) \
25+ && !defined(__DragonFly__) && !defined(__OpenBSD__)
2526 #include <malloc.h>
2627 #endif
2728
@@ -35,7 +36,8 @@ · 7 unmodified lines
3536 #define CONFIG_TCC_MALLOC_HOOKS
3637 #define HAVE_MEMALIGN
3738
38−#if defined(__FreeBSD__) || defined(__DragonFly__) || defined(__dietlibc__) \
39+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) \
40+ || defined(__DragonFly__) || defined(__dietlibc__) \
3941 || defined(__UCLIBC__) || defined(__OpenBSD__) || defined(_WIN32)
4042 #warning Bound checking does not support malloc (etc.) in this environment.
4143 #undef CONFIG_TCC_MALLOC_HOOKS
libtcc.c+3−0
@@ -943,6 +943,9 @@ LIBTCCAPI TCCState *tcc_new(void) · 942 unmodified lines
943943 tcc_define_symbol(s, "__FreeBSD__", str( __FreeBSD__));
944944 #undef str
945945 #endif
946+#if defined(__FreeBSD_kernel__)
947+ tcc_define_symbol(s, "__FreeBSD_kernel__", NULL);
948+#endif
946949 #if defined(__linux)
947950 tcc_define_symbol(s, "__linux__", NULL);
948951 tcc_define_symbol(s, "__linux", NULL);
tcc.h+2−1
@@ -808,7 +808,8 @@ enum tcc_token { · 807 unmodified lines
808808 #define strtof (float)strtod
809809 #define strtoll (long long)strtol
810810 #endif
811−#elif defined(TCC_UCLIBC) || defined(__FreeBSD__) || defined(__DragonFly__) \
811+#elif defined(TCC_UCLIBC) || defined(__FreeBSD__) \
812+ || defined(__FreeBSD_kernel__) || defined(__DragonFly__) \
812813 || defined(__OpenBSD__)
813814 /* currently incorrect */
814815 static inline long double strtold(const char *nptr, char **endptr)
tccelf.c+8−6
@@ -1332,6 +1332,8 @@ ST_FUNC void tcc_add_linker_symbols(TCCState *s1) · 1331 unmodified lines
13321332 /* name of ELF interpreter */
13331333 #if defined __FreeBSD__
13341334 static const char elf_interp[] = "/libexec/ld-elf.so.1";
1335+#elif defined __FreeBSD_kernel__
1336+static char elf_interp[] = "/lib/ld.so.1";
13351337 #elif defined TCC_ARM_EABI
13361338 static const char elf_interp[] = "/lib/ld-linux.so.3";
13371339 #elif defined(TCC_TARGET_X86_64)
@@ -1368,7 +1370,7 @@ static void tcc_output_binary(TCCState *s1, FILE *f, · 30 unmodified lines
13681370 }
13691371 }
13701372
1371−#if defined(__FreeBSD__)
1373+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
13721374 #define HAVE_PHDR 1
13731375 #define EXTRA_RELITEMS 14
13741376
@@ -1851,7 +1853,7 @@ static int elf_output_file(TCCState *s1, const char *filename) · 476 unmodified lines
18511853 }
18521854 /* update dynamic relocation infos */
18531855 if (s->sh_type == SHT_RELX) {
1854−#if defined(__FreeBSD__)
1856+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
18551857 if (!strcmp(strsec->data + s->sh_name, ".rel.got")) { // rel_size == 0) {
18561858 rel_addr = addr;
18571859 rel_size += s->sh_size; // XXX only first rel.
@@ -1892,7 +1894,7 @@ static int elf_output_file(TCCState *s1, const char *filename) · 34 unmodified lines
18921894 if (interp) {
18931895 ph = &phdr[0];
18941896
1895−#if defined(__FreeBSD__)
1897+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
18961898 {
18971899 int len = phnum * sizeof(ElfW(Phdr));
18981900
@@ -2007,7 +2009,7 @@ static int elf_output_file(TCCState *s1, const char *filename) · 108 unmodified lines
20072009 put_dt(dynamic, DT_RELASZ, rel_size);
20082010 put_dt(dynamic, DT_RELAENT, sizeof(ElfW_Rel));
20092011 #else
2010−#if defined(__FreeBSD__)
2012+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
20112013 put_dt(dynamic, DT_PLTGOT, s1->got->sh_addr);
20122014 put_dt(dynamic, DT_PLTRELSZ, rel_size);
20132015 put_dt(dynamic, DT_JMPREL, rel_addr);
@@ -2115,7 +2117,7 @@ static int elf_output_file(TCCState *s1, const char *filename) · 101 unmodified lines
21152117 ehdr.e_ident[4] = TCC_ELFCLASS;
21162118 ehdr.e_ident[5] = ELFDATA2LSB;
21172119 ehdr.e_ident[6] = EV_CURRENT;
2118−#ifdef __FreeBSD__
2120+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
21192121 ehdr.e_ident[EI_OSABI] = ELFOSABI_FREEBSD;
21202122 #endif
21212123 #ifdef TCC_TARGET_ARM
@@ -2153,7 +2155,7 @@ static int elf_output_file(TCCState *s1, const char *filename) · 31 unmodified lines
21532155 for(i=1;i<s1->nb_sections;i++) {
21542156 s = s1->sections[section_order[i]];
21552157 if (s->sh_type != SHT_NOBITS) {
2156−#if defined(__FreeBSD__)
2158+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
21572159 if (s->sh_type == SHT_DYNSYM)
21582160 patch_dynsym_undef(s1, s);
21592161 #endif
tccrun.c+4−4
@@ -438,7 +438,7 @@ static int rt_get_caller_pc(unsigned long *paddr, ucontext_t *uc, int level) · 437 unmodified lines
438438 int i;
439439
440440 if (level == 0) {
441−#if defined(__FreeBSD__)
441+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
442442 *paddr = uc->uc_mcontext.mc_eip;
443443 #elif defined(__dietlibc__)
444444 *paddr = uc->uc_mcontext.eip;
@@ -447,7 +447,7 @@ static int rt_get_caller_pc(unsigned long *paddr, ucontext_t *uc, int level) · 2 unmodified lines
447447 #endif
448448 return 0;
449449 } else {
450−#if defined(__FreeBSD__)
450+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
451451 fp = uc->uc_mcontext.mc_ebp;
452452 #elif defined(__dietlibc__)
453453 fp = uc->uc_mcontext.ebp;
@@ -477,14 +477,14 @@ static int rt_get_caller_pc(unsigned long *paddr, · 23 unmodified lines
477477
478478 if (level == 0) {
479479 /* XXX: only support linux */
480−#if defined(__FreeBSD__)
480+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
481481 *paddr = uc->uc_mcontext.mc_rip;
482482 #else
483483 *paddr = uc->uc_mcontext.gregs[REG_RIP];
484484 #endif
485485 return 0;
486486 } else {
487−#if defined(__FreeBSD__)
487+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
488488 fp = uc->uc_mcontext.mc_rbp;
489489 #else
490490 fp = uc->uc_mcontext.gregs[REG_RBP];

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t