Skip to content

static zig libraries are exporting getauxval which is overriding libc symbol #19089

Closed
@vesim987

Description

@vesim987

Zig Version

0.12.0-dev.2589+eaa6218f0

Steps to Reproduce and Observed Behavior

Currently https://github.com/ziglang/zig/blob/master/lib/std/os/linux.zig#L391-L404 is exporting getauxvec when not linking libc, which is causing static libraries to export such symbol, and overriding the one from libc. This is causing getauxvec to return zero which is breaking https://github.com/ziglang/zig/blob/master/lib/std/start.zig#L478-L479

Repro: https://github.com/vesim987/zig-getauval-repro

$ zig build run
thread 134272 panic: cast causes pointer to be null
/nix/store/ggiv642mg6v4x34kmkk8xk5cv2kxygwk-zig-0.12.0-dev.2589+eaa6218f0/lib/std/start.zig:480:41: 0x1039bd5 in main (exe)
        const phdrs = (@as([*]elf.Phdr, @ptrFromInt(at_phdr)))[0..at_phnum];

Expected Behavior

The code about should work w/o any iisues.
TBH i don't really know what the correct behavior should be, maybe exporting this symbol only when builtin.output_mode == .Exe?

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugObserved behavior contradicts documented or intended behaviorstandard libraryThis issue involves writing Zig code for the standard library.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions