From abd1532ad41f6b9c7f1c5a10b5b8df22d73567cf Mon Sep 17 00:00:00 2001 From: "Avi Halachmi (:avih)" Date: Mon, 25 Sep 2017 18:39:35 +0300 Subject: [PATCH] freebsd: allow building tcc which targets windows Currently tcc doesn't have a compile-time config indicating that the target is freebsd, and as a result, the tcc binary adds freebsh stuff to elf headers if the compile-time (of tcc) *host* is freebsd. Test also that the target is not PE while generating an elf header. This still likely fails (but untested) when tcc targets other non-freebsd systems on a freebsd system, but for now fix it only when targetting windows. --- tccelf.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tccelf.c b/tccelf.c index 9a7aa91..225cd9d 100644 --- a/tccelf.c +++ b/tccelf.c @@ -1832,7 +1832,8 @@ static void tcc_output_elf(TCCState *s1, FILE *f, int phnum, ElfW(Phdr) *phdr, ehdr.e_ident[4] = ELFCLASSW; ehdr.e_ident[5] = ELFDATA2LSB; ehdr.e_ident[6] = EV_CURRENT; -#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) +#if !defined(TCC_TARGET_PE) && (defined(__FreeBSD__) || defined(__FreeBSD_kernel__)) + /* FIXME: should set only for freebsd _target_, but we exclude only PE target */ ehdr.e_ident[EI_OSABI] = ELFOSABI_FREEBSD; #endif #ifdef TCC_TARGET_ARM