Unified · Split
| @@ -825,7 +825,11 @@ static void tcc_add_runtime(TCCState *s1) · 824 unmodified lines | |||
| 825 | } | 825 | } |
| 826 | 826 | ||
| 827 | /* name of ELF interpreter */ | 827 | /* name of ELF interpreter */ |
| 828 | #ifdef __FreeBSD__ | ||
| 829 | static char elf_interp[] = "/usr/libexec/ld-elf.so.1"; | ||
| 830 | #else | ||
| 828 | static char elf_interp[] = "/lib/ld-linux.so.2"; | 831 | static char elf_interp[] = "/lib/ld-linux.so.2"; |
| 832 | #endif | ||
| 829 | 833 | ||
| 830 | #define ELF_START_ADDR 0x08048000 | 834 | #define ELF_START_ADDR 0x08048000 |
| 831 | #define ELF_PAGE_SIZE 0x1000 | 835 | #define ELF_PAGE_SIZE 0x1000 |
| @@ -1165,6 +1169,10 @@ int tcc_output_file(TCCState *s1, const char *filename) · 333 unmodified lines | |||
| 1165 | ph->p_filesz = file_offset - ph->p_offset; | 1169 | ph->p_filesz = file_offset - ph->p_offset; |
| 1166 | ph->p_memsz = addr - ph->p_vaddr; | 1170 | ph->p_memsz = addr - ph->p_vaddr; |
| 1167 | ph++; | 1171 | ph++; |
| 1172 | /* if in the middle of a page, we duplicate the page in | ||
| 1173 | memory so that one copy is RX and the other is RW */ | ||
| 1174 | if ((addr & (ELF_PAGE_SIZE - 1)) != 0) | ||
| 1175 | addr += ELF_PAGE_SIZE; | ||
| 1168 | } | 1176 | } |
| 1169 | 1177 | ||
| 1170 | /* if interpreter, then add corresponing program header */ | 1178 | /* if interpreter, then add corresponing program header */ |
| @@ -1324,6 +1332,9 @@ int tcc_output_file(TCCState *s1, const char *filename) · 153 unmodified lines | |||
| 1324 | ehdr.e_ident[4] = ELFCLASS32; | 1332 | ehdr.e_ident[4] = ELFCLASS32; |
| 1325 | ehdr.e_ident[5] = ELFDATA2LSB; | 1333 | ehdr.e_ident[5] = ELFDATA2LSB; |
| 1326 | ehdr.e_ident[6] = EV_CURRENT; | 1334 | ehdr.e_ident[6] = EV_CURRENT; |
| 1335 | #ifdef __FreeBSD__ | ||
| 1336 | ehdr.e_ident[EI_OSABI] = ELFOSABI_FREEBSD; | ||
| 1337 | #endif | ||
| 1327 | switch(file_type) { | 1338 | switch(file_type) { |
| 1328 | default: | 1339 | default: |
| 1329 | case TCC_OUTPUT_EXE: | 1340 | case TCC_OUTPUT_EXE: |