authorgravatar for michael.dusan@gmail.comMichael Dusan <michael.dusan@gmail.com> 2021-06-16 00:35:20-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-06-17 20:28:37-07:00
log162b92c93ee36ab8c8668cb22f63a298cadd6d38
tree0dd519dcb9045ef1dd4317126fac4f4c37b0033d
parent8be29674a95b8a6dd52b439701180e9e74e221aa

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 {
14961496 try argv.append("-pie");
14971497 }
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
14991508 try argv.append("-o");
15001509 try argv.append(full_out_path);
15011510