Skip to content

Commit e5c974f

Browse files
authored
std.os.linux: export getauxval only when building executable or root has main function
1 parent 9002977 commit e5c974f

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

lib/std/os/linux.zig

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,10 @@ const extern_getauxval = switch (builtin.zig_backend) {
393393
};
394394

395395
comptime {
396-
if (extern_getauxval) {
396+
const root = @import("root");
397+
// Export this only when building executable, otherwise it is overriding
398+
// the libc implementation
399+
if (extern_getauxval and (builtin.output_mode == .Exe or @hasDecl(root, "main"))) {
397400
@export(getauxvalImpl, .{ .name = "getauxval", .linkage = .weak });
398401
}
399402
}

0 commit comments

Comments
 (0)