aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbellard <bellard>2002-12-08 14:35:48 +0000
committerbellard <bellard>2002-12-08 14:35:48 +0000
commitfa6ac83ec5af8114d4a75b740076c7104f364270 (patch)
treef3f4d2f01697678700319c00fe20aee86e26e341
parent4df76253ad25610a7b1afffc2c52229fb5b596f8 (diff)
downloadtinycc-fa6ac83ec5af8114d4a75b740076c7104f364270.tar.gz
tinycc-fa6ac83ec5af8114d4a75b740076c7104f364270.tar.bz2
FreeBSB fixes - elf align issues
-rw-r--r--tccelf.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/tccelf.c b/tccelf.c
index 33aeac1..a94fd4f 100644
--- a/tccelf.c
+++ b/tccelf.c
@@ -825,7 +825,11 @@ static void tcc_add_runtime(TCCState *s1)
}
/* name of ELF interpreter */
+#ifdef __FreeBSD__
+static char elf_interp[] = "/usr/libexec/ld-elf.so.1";
+#else
static char elf_interp[] = "/lib/ld-linux.so.2";
+#endif
#define ELF_START_ADDR 0x08048000
#define ELF_PAGE_SIZE 0x1000
@@ -1165,6 +1169,10 @@ int tcc_output_file(TCCState *s1, const char *filename)
ph->p_filesz = file_offset - ph->p_offset;
ph->p_memsz = addr - ph->p_vaddr;
ph++;
+ /* if in the middle of a page, we duplicate the page in
+ memory so that one copy is RX and the other is RW */
+ if ((addr & (ELF_PAGE_SIZE - 1)) != 0)
+ addr += ELF_PAGE_SIZE;
}
/* if interpreter, then add corresponing program header */
@@ -1324,6 +1332,9 @@ int tcc_output_file(TCCState *s1, const char *filename)
ehdr.e_ident[4] = ELFCLASS32;
ehdr.e_ident[5] = ELFDATA2LSB;
ehdr.e_ident[6] = EV_CURRENT;
+#ifdef __FreeBSD__
+ ehdr.e_ident[EI_OSABI] = ELFOSABI_FREEBSD;
+#endif
switch(file_type) {
default:
case TCC_OUTPUT_EXE: