commit 162b92c93ee36ab8c8668cb22f63a298cadd6d38 (tree)
parent 8be29674a95b8a6dd52b439701180e9e74e221aa
Author: Michael Dusan <michael.dusan@gmail.com>
Date: Wed, 16 Jun 2021 00:35:20 -0400
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
Diffstat:
1 file changed, 9 insertions(+), 0 deletions(-)
diff --git a/src/link/Elf.zig b/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);