The dynamic linker on netbsd can only handle 2 PT_LOAD sections.
Unified · Split
| @@ -1951,8 +1951,14 @@ static int sort_sections(TCCState *s1, int *sec_order, Section *interp) · 1950 unmodified lines | |||
| 1951 | f = 0; | 1951 | f = 0; |
| 1952 | if (k < 0x700) { | 1952 | if (k < 0x700) { |
| 1953 | f = s->sh_flags & (SHF_ALLOC|SHF_WRITE|SHF_EXECINSTR|SHF_TLS); | 1953 | 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 | ||
| 1954 | if ((k & 0xfff0) == 0x240) /* RELRO sections */ | 1959 | if ((k & 0xfff0) == 0x240) /* RELRO sections */ |
| 1955 | f |= 1<<4; | 1960 | f |= 1<<4; |
| 1961 | #endif | ||
| 1956 | if (f != f0) /* start new header when flags changed or relro */ | 1962 | if (f != f0) /* start new header when flags changed or relro */ |
| 1957 | f0 = f, ++n, f |= 1<<8; | 1963 | f0 = f, ++n, f |= 1<<8; |
| 1958 | } | 1964 | } |