-
-
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -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 | ||||||
\\ nodelete Indicate that the object cannot be deleted from a process | ||||||
\\ notext Permit read-only relocations in read-only segments | ||||||
\\ defs Force a fatal error if any undefined symbols remain | ||||||
\\ origin Indicate that the object must have its origin processed | ||||||
\\ noexecstack Indicate that the object requires an executable stack | ||||||
\\ now Force all relocations to be processed on load | ||||||
\\ relro Force all relocations to be resolved and be read-only on load | ||||||
\\ -dynamic Force output to be dynamically linked | ||||||
\\ -static Force output to be statically linked | ||||||
\\ -Bsymbolic Bind global references locally | ||||||
|
@@ -595,6 +603,7 @@ fn buildOutputType( | |||||
var linker_allow_shlib_undefined: ?bool = null; | ||||||
var linker_bind_global_refs_locally: ?bool = null; | ||||||
var linker_z_nodelete = false; | ||||||
var linker_z_notext = false; | ||||||
var linker_z_defs = false; | ||||||
var linker_z_origin = false; | ||||||
var linker_z_noexecstack = false; | ||||||
|
@@ -1086,6 +1095,29 @@ fn buildOutputType( | |||||
linker_allow_shlib_undefined = true; | ||||||
} else if (mem.eql(u8, arg, "-fno-allow-shlib-undefined")) { | ||||||
linker_allow_shlib_undefined = false; | ||||||
} 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 commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
} | ||||||
const z_arg = args[i]; | ||||||
if (mem.eql(u8, z_arg, "nodelete")) { | ||||||
linker_z_nodelete = true; | ||||||
} else if (mem.eql(u8, z_arg, "notext")) { | ||||||
linker_z_notext = true; | ||||||
} else if (mem.eql(u8, z_arg, "defs")) { | ||||||
linker_z_defs = true; | ||||||
} else if (mem.eql(u8, z_arg, "origin")) { | ||||||
linker_z_origin = true; | ||||||
} else if (mem.eql(u8, z_arg, "noexecstack")) { | ||||||
linker_z_noexecstack = true; | ||||||
} else if (mem.eql(u8, z_arg, "now")) { | ||||||
linker_z_now = true; | ||||||
} else if (mem.eql(u8, z_arg, "relro")) { | ||||||
linker_z_relro = true; | ||||||
} else { | ||||||
warn("unsupported linker arg: -z {s}", .{z_arg}); | ||||||
} | ||||||
} else if (mem.eql(u8, arg, "-Bsymbolic")) { | ||||||
linker_bind_global_refs_locally = true; | ||||||
} else if (mem.eql(u8, arg, "--debug-compile-errors")) { | ||||||
|
@@ -1422,6 +1454,8 @@ fn buildOutputType( | |||||
const z_arg = linker_args.items[i]; | ||||||
if (mem.eql(u8, z_arg, "nodelete")) { | ||||||
linker_z_nodelete = true; | ||||||
} else if (mem.eql(u8, z_arg, "notext")) { | ||||||
linker_z_notext = true; | ||||||
} else if (mem.eql(u8, z_arg, "defs")) { | ||||||
linker_z_defs = true; | ||||||
} else if (mem.eql(u8, z_arg, "origin")) { | ||||||
|
@@ -2108,6 +2142,7 @@ fn buildOutputType( | |||||
.linker_allow_shlib_undefined = linker_allow_shlib_undefined, | ||||||
.linker_bind_global_refs_locally = linker_bind_global_refs_locally, | ||||||
.linker_z_nodelete = linker_z_nodelete, | ||||||
.linker_z_notext = linker_z_notext, | ||||||
.linker_z_defs = linker_z_defs, | ||||||
.linker_z_origin = linker_z_origin, | ||||||
.linker_z_noexecstack = linker_z_noexecstack, | ||||||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.