Commit 162b92c93e
2021-06-16 06:35:20
1 parent
8be2967Changed files (1)
src
link
src/link/Elf.zig
@@ -1496,6 +1496,15 @@ fn linkWithLLD(self: *Elf, comp: *Compilation) !void {
try argv.append("-pie");
}
+ if (self.base.options.link_mode == .Dynamic and target.os.tag == .netbsd) {
+ // Add options to produce shared objects with only 2 PT_LOAD segments.
+ // NetBSD expects 2 PT_LOAD segments in a shared object, otherwise
+ // ld.elf_so fails to load, emitting a general "not found" error.
+ // See https://github.com/ziglang/zig/issues/9109 .
+ try argv.append("--no-rosegment");
+ try argv.append("-znorelro");
+ }
+
try argv.append("-o");
try argv.append(full_out_path);