commit 956f53beb09c07925970453d4c178c6feb53ba70 (tree)
parent fc45e5b39c0e09dcf69cc65a92375bef0c9593cb
Author: Alain Greppin <agreppin@chilibi.ch>
Date: Wed, 17 Apr 2024 12:48:12 +0200
NetBSD: avoid ldd error on executables. zig cc produce 4 PT_LOAD segments,
wheras on NetBSD, only 2 PT_LOAD are usually produced by other compilers
(tested with host gcc and clang).
$ ldd -v main_4segs
.../main_4segs: wrong number of segments (4 != 2)
.../main_4segs: invalid ELF class 2; expected 1
Diffstat:
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/link/Elf.zig b/src/link/Elf.zig
@@ -2508,7 +2508,7 @@ fn linkWithLLD(self: *Elf, arena: Allocator, prog_node: *std.Progress.Node) !voi
try argv.append("-pie");
}
- if (is_dyn_lib and target.os.tag == .netbsd) {
+ if (is_exe_or_dyn_lib 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 loading dynamic libraries with "not found" error.