-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
zig: expose linker options and include '-z notext' #10056
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
Conversation
Add an option to allow the '-z notext' option to be passed to the linker via. the compiler frontend, which is a flag that tells the linker that relocations in read-only sections are permitted. Certain targets such as Solana BPF rely on this flag. Expose all linker options i.e. '-z nodelete', '-z now', '-z relro' in the compiler frontend. Usage documentation has been updated accordingly. Expose the '-z notext' flag in the standard library build runner.
@@ -401,6 +401,14 @@ const usage_build_generic = | |||
\\ -fno-allow-shlib-undefined Disallows undefined symbols in shared libraries | |||
\\ --eh-frame-hdr Enable C++ exception handling by passing --eh-frame-hdr to linker | |||
\\ --emit-relocs Enable output of relocation sections for post build tools | |||
\\ -z [arg] Append linker arguments |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, -z <arg>
seems specific to ELF linkers; would it make more sense to expose each flag of interest separately with -fnotext
or something similar? Also, we should definitely point out these are ELF-specific. @andrewrk I'd appreciate your look at this too!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-z
specifies an extension flag. wasm-ld
supports them as well and we actually already make use of it to set the stack size for executables. So if we go with this, perhaps those should be supported too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
\\ -z [arg] Append linker arguments | |
\\ -z [arg] Set linker extension flags |
@@ -401,6 +401,14 @@ const usage_build_generic = | |||
\\ -fno-allow-shlib-undefined Disallows undefined symbols in shared libraries | |||
\\ --eh-frame-hdr Enable C++ exception handling by passing --eh-frame-hdr to linker | |||
\\ --emit-relocs Enable output of relocation sections for post build tools | |||
\\ -z [arg] Append linker arguments |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
\\ -z [arg] Append linker arguments | |
\\ -z [arg] Set linker extension flags |
} else if (mem.eql(u8, arg, "-z")) { | ||
i += 1; | ||
if (i >= args.len) { | ||
fatal("expected linker arg after '{s}'", .{arg}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fatal("expected linker arg after '{s}'", .{arg}); | |
fatal("expected linker extension flag after '{s}'", .{arg}); |
Damn I was hoping github would let me make these changes before merging |
Add an option to allow the '-z notext' option to be passed to the linker via. the compiler frontend, which is a flag that tells the linker that relocations in read-only sections are permitted. Certain targets such as Solana BPF rely on this flag.
Expose all linker options i.e. '-z nodelete', '-z now', '-z relro' in the compiler frontend. Usage documentation has been updated accordingly.
Expose the '-z notext' flag in the standard library build runner.