-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Handle .init_array link_section specially on wasm #121533
Merged
+36
−9
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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
Next
Next commit
Loading status checks…
Handle .init_array link_section specially on wasm
- Loading branch information
commit a85700a1a8f5aa729bd19e5a2a78f8a80d623093
There are no files selected for viewing
This file contains 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 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 |
---|---|---|
|
@@ -159,21 +159,27 @@ fn maybe_check_static_with_link_section(tcx: TyCtxt<'_>, id: LocalDefId) { | |
return; | ||
} | ||
|
||
// For the wasm32 target statics with `#[link_section]` are placed into custom | ||
// sections of the final output file, but this isn't link custom sections of | ||
// other executable formats. Namely we can only embed a list of bytes, | ||
// nothing with provenance (pointers to anything else). If any provenance | ||
// show up, reject it here. | ||
// For the wasm32 target statics with `#[link_section]` other than `.init_array` | ||
// are placed into custom sections of the final output file, but this isn't link | ||
// custom sections of other executable formats. Namely we can only embed a list | ||
// of bytes, nothing with provenance (pointers to anything else). If any | ||
// provenance show up, reject it here. | ||
// `#[link_section]` may contain arbitrary, or even undefined bytes, but it is | ||
// the consumer's responsibility to ensure all bytes that have been read | ||
// have defined values. | ||
if let Ok(alloc) = tcx.eval_static_initializer(id.to_def_id()) | ||
&& alloc.inner().provenance().ptrs().len() != 0 | ||
{ | ||
let msg = "statics with a custom `#[link_section]` must be a \ | ||
if attrs | ||
.link_section | ||
.map(|link_section| !link_section.as_str().starts_with(".init_array")) | ||
.unwrap_or(true) | ||
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. I guess this could just be unwrap() because of the early return on line 158-159 |
||
{ | ||
let msg = "statics with a custom `#[link_section]` must be a \ | ||
simple list of bytes on the wasm target with no \ | ||
extra levels of indirection such as references"; | ||
tcx.dcx().span_err(tcx.def_span(id), msg); | ||
tcx.dcx().span_err(tcx.def_span(id), msg); | ||
} | ||
} | ||
} | ||
|
||
|
Oops, something went wrong.
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.
Pre-existing, but might as well fix it: "this isn't link custom sections..." is nonsensical phrasing. I'm not sure what the correct words would be.
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.
Maybe s/link/like?