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
21#include <stdio.h>21#include <stdio.h>
22#include <stdarg.h>22#include <stdarg.h>
23#include <string.h>23#include <string.h>
24#if !defined(__FreeBSD__) && !defined(__DragonFly__) && !defined(__OpenBSD__)24#if !defined(__FreeBSD__) && !defined(__FreeBSD_kernel__) \
25 && !defined(__DragonFly__) && !defined(__OpenBSD__)
25#include <malloc.h>26#include <malloc.h>
26#endif27#endif
27 28
@@ -35,7 +36,8 @@ · 7 unmodified lines
35#define CONFIG_TCC_MALLOC_HOOKS36#define CONFIG_TCC_MALLOC_HOOKS
36#define HAVE_MEMALIGN37#define HAVE_MEMALIGN
37 38
38#if defined(__FreeBSD__) || defined(__DragonFly__) || defined(__dietlibc__) \39#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) \
40 || defined(__DragonFly__) || defined(__dietlibc__) \
39 || defined(__UCLIBC__) || defined(__OpenBSD__) || defined(_WIN32)41 || defined(__UCLIBC__) || defined(__OpenBSD__) || defined(_WIN32)
40#warning Bound checking does not support malloc (etc.) in this environment.42#warning Bound checking does not support malloc (etc.) in this environment.
41#undef CONFIG_TCC_MALLOC_HOOKS43#undef CONFIG_TCC_MALLOC_HOOKS
libtcc.c+3−0
@@ -943,6 +943,9 @@ LIBTCCAPI TCCState *tcc_new(void) · 942 unmodified lines
943 tcc_define_symbol(s, "__FreeBSD__", str( __FreeBSD__));943 tcc_define_symbol(s, "__FreeBSD__", str( __FreeBSD__));
944#undef str944#undef str
945#endif945#endif
946#if defined(__FreeBSD_kernel__)
947 tcc_define_symbol(s, "__FreeBSD_kernel__", NULL);
948#endif
946#if defined(__linux)949#if defined(__linux)
947 tcc_define_symbol(s, "__linux__", NULL);950 tcc_define_symbol(s, "__linux__", NULL);
948 tcc_define_symbol(s, "__linux", NULL);951 tcc_define_symbol(s, "__linux", NULL);
tcc.h+2−1
@@ -808,7 +808,8 @@ enum tcc_token { · 807 unmodified lines
808 #define strtof (float)strtod808 #define strtof (float)strtod
809 #define strtoll (long long)strtol809 #define strtoll (long long)strtol
810#endif810#endif
811#elif defined(TCC_UCLIBC) || defined(__FreeBSD__) || defined(__DragonFly__) \811#elif defined(TCC_UCLIBC) || defined(__FreeBSD__) \
812 || defined(__FreeBSD_kernel__) || defined(__DragonFly__) \
812 || defined(__OpenBSD__)813 || defined(__OpenBSD__)
813/* currently incorrect */814/* currently incorrect */
814static inline long double strtold(const char *nptr, char **endptr)815static 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
1332/* name of ELF interpreter */1332/* name of ELF interpreter */
1333#if defined __FreeBSD__1333#if defined __FreeBSD__
1334static const char elf_interp[] = "/libexec/ld-elf.so.1";1334static const char elf_interp[] = "/libexec/ld-elf.so.1";
1335#elif defined __FreeBSD_kernel__
1336static char elf_interp[] = "/lib/ld.so.1";
1335#elif defined TCC_ARM_EABI1337#elif defined TCC_ARM_EABI
1336static const char elf_interp[] = "/lib/ld-linux.so.3";1338static const char elf_interp[] = "/lib/ld-linux.so.3";
1337#elif defined(TCC_TARGET_X86_64)1339#elif defined(TCC_TARGET_X86_64)
@@ -1368,7 +1370,7 @@ static void tcc_output_binary(TCCState *s1, FILE *f, · 30 unmodified lines
1368 }1370 }
1369}1371}
1370 1372
1371#if defined(__FreeBSD__)1373#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
1372#define HAVE_PHDR 11374#define HAVE_PHDR 1
1373#define EXTRA_RELITEMS 141375#define EXTRA_RELITEMS 14
1374 1376
@@ -1851,7 +1853,7 @@ static int elf_output_file(TCCState *s1, const char *filename) · 476 unmodified lines
1851 }1853 }
1852 /* update dynamic relocation infos */1854 /* update dynamic relocation infos */
1853 if (s->sh_type == SHT_RELX) {1855 if (s->sh_type == SHT_RELX) {
1854#if defined(__FreeBSD__)1856#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
1855 if (!strcmp(strsec->data + s->sh_name, ".rel.got")) { // rel_size == 0) {1857 if (!strcmp(strsec->data + s->sh_name, ".rel.got")) { // rel_size == 0) {
1856 rel_addr = addr;1858 rel_addr = addr;
1857 rel_size += s->sh_size; // XXX only first rel.1859 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
1892 if (interp) {1894 if (interp) {
1893 ph = &phdr[0];1895 ph = &phdr[0];
1894 1896
1895#if defined(__FreeBSD__)1897#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
1896 {1898 {
1897 int len = phnum * sizeof(ElfW(Phdr));1899 int len = phnum * sizeof(ElfW(Phdr));
1898 1900
@@ -2007,7 +2009,7 @@ static int elf_output_file(TCCState *s1, const char *filename) · 108 unmodified lines
2007 put_dt(dynamic, DT_RELASZ, rel_size);2009 put_dt(dynamic, DT_RELASZ, rel_size);
2008 put_dt(dynamic, DT_RELAENT, sizeof(ElfW_Rel));2010 put_dt(dynamic, DT_RELAENT, sizeof(ElfW_Rel));
2009#else2011#else
2010#if defined(__FreeBSD__)2012#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
2011 put_dt(dynamic, DT_PLTGOT, s1->got->sh_addr);2013 put_dt(dynamic, DT_PLTGOT, s1->got->sh_addr);
2012 put_dt(dynamic, DT_PLTRELSZ, rel_size);2014 put_dt(dynamic, DT_PLTRELSZ, rel_size);
2013 put_dt(dynamic, DT_JMPREL, rel_addr);2015 put_dt(dynamic, DT_JMPREL, rel_addr);
@@ -2115,7 +2117,7 @@ static int elf_output_file(TCCState *s1, const char *filename) · 101 unmodified lines
2115 ehdr.e_ident[4] = TCC_ELFCLASS;2117 ehdr.e_ident[4] = TCC_ELFCLASS;
2116 ehdr.e_ident[5] = ELFDATA2LSB;2118 ehdr.e_ident[5] = ELFDATA2LSB;
2117 ehdr.e_ident[6] = EV_CURRENT;2119 ehdr.e_ident[6] = EV_CURRENT;
2118#ifdef __FreeBSD__2120#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
2119 ehdr.e_ident[EI_OSABI] = ELFOSABI_FREEBSD;2121 ehdr.e_ident[EI_OSABI] = ELFOSABI_FREEBSD;
2120#endif2122#endif
2121#ifdef TCC_TARGET_ARM2123#ifdef TCC_TARGET_ARM
@@ -2153,7 +2155,7 @@ static int elf_output_file(TCCState *s1, const char *filename) · 31 unmodified lines
2153 for(i=1;i<s1->nb_sections;i++) {2155 for(i=1;i<s1->nb_sections;i++) {
2154 s = s1->sections[section_order[i]];2156 s = s1->sections[section_order[i]];
2155 if (s->sh_type != SHT_NOBITS) {2157 if (s->sh_type != SHT_NOBITS) {
2156#if defined(__FreeBSD__)2158#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
2157 if (s->sh_type == SHT_DYNSYM)2159 if (s->sh_type == SHT_DYNSYM)
2158 patch_dynsym_undef(s1, s);2160 patch_dynsym_undef(s1, s);
2159#endif2161#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
438 int i;438 int i;
439 439
440 if (level == 0) {440 if (level == 0) {
441#if defined(__FreeBSD__)441#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
442 *paddr = uc->uc_mcontext.mc_eip;442 *paddr = uc->uc_mcontext.mc_eip;
443#elif defined(__dietlibc__)443#elif defined(__dietlibc__)
444 *paddr = uc->uc_mcontext.eip;444 *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
447#endif447#endif
448 return 0;448 return 0;
449 } else {449 } else {
450#if defined(__FreeBSD__)450#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
451 fp = uc->uc_mcontext.mc_ebp;451 fp = uc->uc_mcontext.mc_ebp;
452#elif defined(__dietlibc__)452#elif defined(__dietlibc__)
453 fp = uc->uc_mcontext.ebp;453 fp = uc->uc_mcontext.ebp;
@@ -477,14 +477,14 @@ static int rt_get_caller_pc(unsigned long *paddr, · 23 unmodified lines
477 477
478 if (level == 0) {478 if (level == 0) {
479 /* XXX: only support linux */479 /* XXX: only support linux */
480#if defined(__FreeBSD__)480#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
481 *paddr = uc->uc_mcontext.mc_rip;481 *paddr = uc->uc_mcontext.mc_rip;
482#else482#else
483 *paddr = uc->uc_mcontext.gregs[REG_RIP];483 *paddr = uc->uc_mcontext.gregs[REG_RIP];
484#endif484#endif
485 return 0;485 return 0;
486 } else {486 } else {
487#if defined(__FreeBSD__)487#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
488 fp = uc->uc_mcontext.mc_rbp;488 fp = uc->uc_mcontext.mc_rbp;
489#else489#else
490 fp = uc->uc_mcontext.gregs[REG_RBP];490 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