authorgravatar for michael.dusan@gmail.comMichael Dusan <michael.dusan@gmail.com> 2023-04-29 13:14:49-04:00
committergravatar for michael.dusan@gmail.comMichael Dusan <michael.dusan@gmail.com> 2023-05-16 16:45:10-04:00
log247b35360900367c3678f2d8a6dd0d0693f17072
treeecf701d4c4ab701b5fdbd26b23c636899e060433
parentb754068fbc7492962953068d31386d4c04e37ae5

netbsd: restrict PT_LOAD workaround to dlibs only

NetBSD supports executables with > 2 PT_LOAD segments but dynamic libraries continue to expect exactly 2 PT_LOAD segments.

1 files changed, 2 insertions(+), 2 deletions(-)

src/link/Elf.zig+2-2
......@@ -1654,10 +1654,10 @@ fn linkWithLLD(self: *Elf, comp: *Compilation, prog_node: *std.Progress.Node) !v
16541654 try argv.append("-pie");
16551655 }
16561656
1657 if (self.base.options.link_mode == .Dynamic and target.os.tag == .netbsd) {
1657 if (is_dyn_lib and target.os.tag == .netbsd) {
16581658 // Add options to produce shared objects with only 2 PT_LOAD segments.
16591659 // NetBSD expects 2 PT_LOAD segments in a shared object, otherwise
1660 // ld.elf_so fails to load, emitting a general "not found" error.
1660 // ld.elf_so fails loading dynamic libraries with "not found" error.
16611661 // See https://github.com/ziglang/zig/issues/9109 .
16621662 try argv.append("--no-rosegment");
16631663 try argv.append("-znorelro");