authorgravatar for r00ster91@proton.meWooster <r00ster91@proton.me> 2024-12-20 14:14:38+09:00
committergravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2025-03-26 21:52:44+01:00
log27ae10afe0d764626e0191f0129654131d398814
treeed29ca06652b98776839c3c93c33a10562ff8c88
parentf391a2cd2075855a1b179eaef9facbdd539b4b8a
signaturebadge-check Signed by SSH key SHA256:7B/LJ7bpR1eX8aCXSr4mtd5M45VMPKcx9zY8e95b5QM

linux: don't export getauxval when not required


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

lib/std/os/linux.zig+9-9
...@@ -482,22 +482,22 @@ pub const O = switch (native_arch) {...@@ -482,22 +482,22 @@ pub const O = switch (native_arch) {
482/// Set by startup code, used by `getauxval`.482/// Set by startup code, used by `getauxval`.
483pub var elf_aux_maybe: ?[*]std.elf.Auxv = null;483pub var elf_aux_maybe: ?[*]std.elf.Auxv = null;
484484
485/// Whether an external or internal getauxval implementation is used.
485const extern_getauxval = switch (builtin.zig_backend) {486const extern_getauxval = switch (builtin.zig_backend) {
486 // Calling extern functions is not yet supported with these backends487 // Calling extern functions is not yet supported with these backends
487 .stage2_aarch64, .stage2_arm, .stage2_riscv64, .stage2_sparc64 => false,488 .stage2_aarch64, .stage2_arm, .stage2_riscv64, .stage2_sparc64 => false,
488 else => !builtin.link_libc,489 else => !builtin.link_libc,
489};490};
490491
491comptime {
492 const root = @import("root");
493 // Export this only when building executable, otherwise it is overriding
494 // the libc implementation
495 if (extern_getauxval and (builtin.output_mode == .Exe or @hasDecl(root, "main"))) {
496 @export(&getauxvalImpl, .{ .name = "getauxval", .linkage = .weak });
497 }
498}
499
500pub const getauxval = if (extern_getauxval) struct {492pub const getauxval = if (extern_getauxval) struct {
493 comptime {
494 const root = @import("root");
495 // Export this only when building an executable, otherwise it is overriding
496 // the libc implementation
497 if (builtin.output_mode == .Exe or @hasDecl(root, "main")) {
498 @export(&getauxvalImpl, .{ .name = "getauxval", .linkage = .weak });
499 }
500 }
501 extern fn getauxval(index: usize) usize;501 extern fn getauxval(index: usize) usize;
502}.getauxval else getauxvalImpl;502}.getauxval else getauxvalImpl;
503503