authorgravatar for agreppin@chilibi.chAlain Greppin <agreppin@chilibi.ch> 2024-04-17 12:48:12+02:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-04-29 12:48:56-07:00
log956f53beb09c07925970453d4c178c6feb53ba70
treed3f48c4dbce3deb29dc106dfcfb149b52062b95a
parentfc45e5b39c0e09dcf69cc65a92375bef0c9593cb

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

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

src/link/Elf.zig+1-1
......@@ -2508,7 +2508,7 @@ fn linkWithLLD(self: *Elf, arena: Allocator, prog_node: *std.Progress.Node) !voi
25082508 try argv.append("-pie");
25092509 }
25102510
2511 if (is_dyn_lib and target.os.tag == .netbsd) {
2511 if (is_exe_or_dyn_lib and target.os.tag == .netbsd) {
25122512 // Add options to produce shared objects with only 2 PT_LOAD segments.
25132513 // NetBSD expects 2 PT_LOAD segments in a shared object, otherwise
25142514 // ld.elf_so fails loading dynamic libraries with "not found" error.