Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

--version-script should be applicable for --export-dynamic binaries #19870

Open
MasterAwesome opened this issue May 5, 2024 · 0 comments · May be fixed by #19871
Open

--version-script should be applicable for --export-dynamic binaries #19870

MasterAwesome opened this issue May 5, 2024 · 0 comments · May be fixed by #19871
Labels
bug Observed behavior contradicts documented or intended behavior linking os-linux
Milestone

Comments

@MasterAwesome
Copy link

Zig Version

0.13.0-dev.46+3648d7df1

Steps to Reproduce and Observed Behavior

I'm trying to export a symbol from my binary (kinda similar to #6804).

For the following code:

export const FOO linksection(".custom") = "Zig".*;

pub fn main() !void {}

Using zig build-exe -O ReleaseSmall --force_undefined FOO -rdynamic src/main.zig exports the symbol FOO but also export a bunch of symbols that I don't need to export:

000000000101bebe W fmodq
000000000101bcbc W __fmodx
0000000001008168 R FOO        // The symbol I actually care about
0000000001012e0f W __gedf2
0000000001012d7d W __gehf2

-rdynamic documentation mentions Add all symbols to the dynamic symbol table.

I tried using --version-script <version_script> --no-undefined-version but --version-script doesn't seem to change the linker command at all (at least for build-exe). --version-script behavior is exactly what I need here although I cannot use this for build-exe due to version script only used for dyn_libs here. I think --version-script behavior shouldn't be restricted only to is_dyn_libs but also executables with -rdynamic.

Rust does this as well to ensure certain symbols are maintained in the executable here

Expected Behavior

--version-script and related must apply for executables when -rdynamic flag is applied.

@MasterAwesome MasterAwesome added the bug Observed behavior contradicts documented or intended behavior label May 5, 2024
@Vexu Vexu added this to the 0.13.0 milestone May 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Observed behavior contradicts documented or intended behavior linking os-linux
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants