Fix getting output type from linker scripts that use AS_NEEDED#1546
Open
jwakely wants to merge 1 commit intorui314:mainfrom
Open
Fix getting output type from linker scripts that use AS_NEEDED#1546jwakely wants to merge 1 commit intorui314:mainfrom
jwakely wants to merge 1 commit intorui314:mainfrom
Conversation
ff1916d to
df7b143
Compare
Closed
jmakovicka
reviewed
Feb 11, 2026
src/linker-script.cc
Outdated
| if (tok.size() >= 3 && (tok[0] == "INPUT" || tok[0] == "GROUP") && | ||
| tok[1] == "(") | ||
| tok[1] == "(") { | ||
| if (tok[2] == "AS_NEEDED" && tok[3] == "(") |
There was a problem hiding this comment.
I think we should check that there are enough tokens after AS_NEEDED, i.e. tok.size() >= 5
df7b143 to
aed588b
Compare
kasper93
reviewed
Feb 28, 2026
src/linker-script.cc
Outdated
| if (tok.size() >= 3 && (tok[0] == "INPUT" || tok[0] == "GROUP") && | ||
| tok[1] == "(") | ||
| tok[1] == "(") { | ||
| if (tok[2] == "AS_NEEDED" && tok[3] == "(" && tok.size() >= 5) |
There was a problem hiding this comment.
Suggested change
| if (tok[2] == "AS_NEEDED" && tok[3] == "(" && tok.size() >= 5) | |
| if (tok[2] == "AS_NEEDED" && tok.size() >= 5 && tok[3] == "(") |
Only tok.size() >= 3 is checked above, so tok[3] would be OOB. changing order of this check fixes this.
Make Script<E>::get_script_output_type support AS_NEEDED inside an INPUT or GROUP group, so that the libatomic_asneeded.so linker script used by GCC 16 works. Fixes rui314#1545 Signed-off-by: Jonathan Wakely <jwakely@redhat.com>
aed588b to
e0a6f8e
Compare
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Make
Script<E>::get_script_output_typesupportAS_NEEDEDinside anINPUTorGROUPgroup, so that thelibatomic_asneeded.solinker script used by GCC 16 works.Fixes #1545