-
Notifications
You must be signed in to change notification settings - Fork 11.5k
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
[LLD] EXCLUDE_FILE
linker script directive is not excluding files in linker script rule-matching
#100109
Comments
EXCLUDE_FILE
linker script directive is not excluding files in linker script rule-matchingEXCLUDE_FILE
linker script directive is not excluding files in linker script rule-matching
@llvm/issue-subscribers-lld-elf Author: Parth Arora (partaror)
`EXCLUDE_FILE` linker script directive is not excluding files in linker script rule-matching.
Reproducible example: #!/usr/bin/env bash
cat >1.c <<\EOF
int foo() { return 1; }
EOF
cat >2.c <<\EOF
int bar() { return 3; }
EOF
cat >script.t <<\EOF
SECTIONS {
FOO : { EXCLUDE_FILE(2.o) *(*.text*) }
BAR : { *(*.text*) }
}
EOF
clang-15 -o 1.o 1.c -c
clang-15 -o 2.o 2.c -c
ld.lld -o a.lld.out 1.o 2.o -T script.t
ld.bfd -o a.bfd.out 1.o 2.o -T script.t Ideally, Rule-matching is correct when GNU LD is used. ( |
I've not checked the source code to confirm. This is a drive by comment just in case you are able to update your script. It does seem like all the existing LLD test cases use the EXCLUDE_FILE inside the section list. For example if you rewrite
Then this will work:
It may be that LLD isn't correctly implementing the EXCLUDE_FILE before pattern form. |
Hi @smithp35, Thank you for the quick reply. Yes, using In some cases, it is useful to place
The above two input section descriptions have the same behavior; however, it is much simpler to maintain the input section description with |
EXCLUDE_FILE
linker script directive is not excluding files in linker script rule-matching.Reproducible example:
Ideally,
1.o(.text)
should matchFOO
output section and2.o(.text)
should matchBAR
output section. However, when LLD is used, both1.o(.text)
and2.o(.text)
incorrectly matchesFOO
output section.Rule-matching is correct when GNU LD is used. (
1.o(.text)
matchesFOO
and2.o(.text)
matchesBAR
)The text was updated successfully, but these errors were encountered: