Add support for __FreeBSD_kernel__ kernel

Add support for kfreebsd-i386 and kfreebsd-amd64 Debian arch with
thanks to Pierre Chifflier <chifflier@cpe.fr>.
This commit is contained in:
Thomas Preud'homme
2010-09-10 21:09:07 +02:00
parent 2887f40f76
commit 776364f395
5 changed files with 21 additions and 13 deletions

View File

@ -1332,6 +1332,8 @@ ST_FUNC void tcc_add_linker_symbols(TCCState *s1)
/* name of ELF interpreter */
#if defined __FreeBSD__
static const char elf_interp[] = "/libexec/ld-elf.so.1";
#elif defined __FreeBSD_kernel__
static char elf_interp[] = "/lib/ld.so.1";
#elif defined TCC_ARM_EABI
static const char elf_interp[] = "/lib/ld-linux.so.3";
#elif defined(TCC_TARGET_X86_64)
@ -1368,7 +1370,7 @@ static void tcc_output_binary(TCCState *s1, FILE *f,
}
}
#if defined(__FreeBSD__)
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
#define HAVE_PHDR 1
#define EXTRA_RELITEMS 14
@ -1851,7 +1853,7 @@ static int elf_output_file(TCCState *s1, const char *filename)
}
/* update dynamic relocation infos */
if (s->sh_type == SHT_RELX) {
#if defined(__FreeBSD__)
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
if (!strcmp(strsec->data + s->sh_name, ".rel.got")) { // rel_size == 0) {
rel_addr = addr;
rel_size += s->sh_size; // XXX only first rel.
@ -1892,7 +1894,7 @@ static int elf_output_file(TCCState *s1, const char *filename)
if (interp) {
ph = &phdr[0];
#if defined(__FreeBSD__)
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
{
int len = phnum * sizeof(ElfW(Phdr));
@ -2007,7 +2009,7 @@ static int elf_output_file(TCCState *s1, const char *filename)
put_dt(dynamic, DT_RELASZ, rel_size);
put_dt(dynamic, DT_RELAENT, sizeof(ElfW_Rel));
#else
#if defined(__FreeBSD__)
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
put_dt(dynamic, DT_PLTGOT, s1->got->sh_addr);
put_dt(dynamic, DT_PLTRELSZ, rel_size);
put_dt(dynamic, DT_JMPREL, rel_addr);
@ -2115,7 +2117,7 @@ static int elf_output_file(TCCState *s1, const char *filename)
ehdr.e_ident[4] = TCC_ELFCLASS;
ehdr.e_ident[5] = ELFDATA2LSB;
ehdr.e_ident[6] = EV_CURRENT;
#ifdef __FreeBSD__
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
ehdr.e_ident[EI_OSABI] = ELFOSABI_FREEBSD;
#endif
#ifdef TCC_TARGET_ARM
@ -2153,7 +2155,7 @@ static int elf_output_file(TCCState *s1, const char *filename)
for(i=1;i<s1->nb_sections;i++) {
s = s1->sections[section_order[i]];
if (s->sh_type != SHT_NOBITS) {
#if defined(__FreeBSD__)
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
if (s->sh_type == SHT_DYNSYM)
patch_dynsym_undef(s1, s);
#endif