History

Fix netbsd elf problem

The dynamic linker on netbsd can only handle 2 PT_LOAD sections.

herman ten brugge committed 4 years ago

Commit 4589fdf1 parent 09808f31 file · +6 −0Browse files

Unified · Split

tccelf.c+6−0
@@ -1951,8 +1951,14 @@ static int sort_sections(TCCState *s1, int *sec_order, Section *interp) · 1950 unmodified lines
19511951 f = 0;
19521952 if (k < 0x700) {
19531953 f = s->sh_flags & (SHF_ALLOC|SHF_WRITE|SHF_EXECINSTR|SHF_TLS);
1954+#if TARGETOS_NetBSD
1955+ /* NetBSD only supports 2 PT_LOAD sections.
1956+ See: https://blog.netbsd.org/tnf/entry/the_first_report_on_lld */
1957+ if ((f & SHF_WRITE) == 0) f |= SHF_EXECINSTR;
1958+#else
19541959 if ((k & 0xfff0) == 0x240) /* RELRO sections */
19551960 f |= 1<<4;
1961+#endif
19561962 if (f != f0) /* start new header when flags changed or relro */
19571963 f0 = f, ++n, f |= 1<<8;
19581964 }

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