Open partaror opened 3 months ago
@llvm/issue-subscribers-lld-elf
Author: Parth Arora (partaror)
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
SECTIONS {
FOO : { *(EXCLUDE_FILE(2.o) *.text*) }
BAR : { *(*.text) }
}
Then this will work:
60 60 b 16 FOO
60 60 b 16 1.o:(.text)
60 60 b 1 foo
70 70 b 16 BAR
70 70 b 16 2.o:(.text)
70 70 b 1 bar
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 EXCLUDE_FILE
inside the section patterns list works as expected.
In some cases, it is useful to place EXCLUDE_FILE
outside the section patterns list. One example where this is beneficial is described below:
EXCLUDE_FILE(2.o) *(.text.foo .text.bar .text.baz)
*(EXCLUDE_FILE(2.o) .text.foo EXCLUDE_FILE(2.o) .text.bar EXCLUDE_FILE(2.o) .text.baz)
The above two input section descriptions have the same behavior; however, it is much simpler to maintain the input section description with EXCLUDE_FILE
outside the section patterns list.
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
)