History

FreeBSB fixes - elf align issues

bellard committed 23 years ago

Commit fa6ac831 parent 4df76251 file · +11 −0Browse files

Unified · Split

tccelf.c+11−0
@@ -825,7 +825,11 @@ static void tcc_add_runtime(TCCState *s1) · 824 unmodified lines
825825 }
826826
827827 /* name of ELF interpreter */
828+#ifdef __FreeBSD__
829+static char elf_interp[] = "/usr/libexec/ld-elf.so.1";
830+#else
828831 static char elf_interp[] = "/lib/ld-linux.so.2";
832+#endif
829833
830834 #define ELF_START_ADDR 0x08048000
831835 #define ELF_PAGE_SIZE 0x1000
@@ -1165,6 +1169,10 @@ int tcc_output_file(TCCState *s1, const char *filename) · 333 unmodified lines
11651169 ph->p_filesz = file_offset - ph->p_offset;
11661170 ph->p_memsz = addr - ph->p_vaddr;
11671171 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;
11681176 }
11691177
11701178 /* if interpreter, then add corresponing program header */
@@ -1324,6 +1332,9 @@ int tcc_output_file(TCCState *s1, const char *filename) · 153 unmodified lines
13241332 ehdr.e_ident[4] = ELFCLASS32;
13251333 ehdr.e_ident[5] = ELFDATA2LSB;
13261334 ehdr.e_ident[6] = EV_CURRENT;
1335+#ifdef __FreeBSD__
1336+ ehdr.e_ident[EI_OSABI] = ELFOSABI_FREEBSD;
1337+#endif
13271338 switch(file_type) {
13281339 default:
13291340 case TCC_OUTPUT_EXE:

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t