authorgravatar for michael.dusan@gmail.comMichael Dusan <michael.dusan@gmail.com> 2021-06-16 00:35:20-04:00
committergravatar for michael.dusan@gmail.comMichael Dusan <michael.dusan@gmail.com> 2021-06-16 14:46:25-04:00
log79a4da14ad137aa52a32f9113982b706d8c5fe8b
treef27b7528a30331c0e6f1cb3ff0a3a68f3b1776bc
parente125ead2b1549eff5bd20c3fb640c9480a9c9aeb

netbsd: add args to limit number of PT_LOAD segs

NetBSD expects 2 PT_LOAD segments in a shared object, otherwise ld.elf_so fails to load, emitting a general "not found" error. Workaround issue by adding args `--no-rosegment` and `-znorelro`. see #9109

1 files changed, 9 insertions(+), 0 deletions(-)

src/link/Elf.zig+9
...@@ -1496,6 +1496,15 @@ fn linkWithLLD(self: *Elf, comp: *Compilation) !void {...@@ -1496,6 +1496,15 @@ fn linkWithLLD(self: *Elf, comp: *Compilation) !void {
1496 try argv.append("-pie");1496 try argv.append("-pie");
1497 }1497 }
14981498
1499 if (self.base.options.link_mode == .Dynamic and target.os.tag == .netbsd) {
1500 // Add options to produce shared objects with only 2 PT_LOAD segments.
1501 // NetBSD expects 2 PT_LOAD segments in a shared object, otherwise
1502 // ld.elf_so fails to load, emitting a general "not found" error.
1503 // See https://github.com/ziglang/zig/issues/9109 .
1504 try argv.append("--no-rosegment");
1505 try argv.append("-znorelro");
1506 }
1507
1499 try argv.append("-o");1508 try argv.append("-o");
1500 try argv.append(full_out_path);1509 try argv.append(full_out_path);
15011510