changeset 212:b106d9cd31dc

[project @ 2002-12-08 14:35:48 by bellard] FreeBSB fixes - elf align issues
author bellard
date Sun, 08 Dec 2002 14:35:48 +0000
parents aea76b59cbc3
children e82d6bc5f24d
files tccelf.c
diffstat 1 files changed, 11 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/tccelf.c	Sun Dec 08 14:35:31 2002 +0000
+++ b/tccelf.c	Sun Dec 08 14:35:48 2002 +0000
@@ -825,7 +825,11 @@
 }
 
 /* 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 @@
             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 @@
     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: