Amilendra Kodithuwakku via llvm-dev
2021-Jul-17 16:23 UTC
[llvm-dev] [lld][ELF] Regarding removeUnusedSyntheticSections()
Hi, I am working on an LLD port for a research project based on the AARCH64 based architecture which requires adding a new SyntheticSection to InStruct, but doing so gives me 2 failed x86 tests: lld :: ELF/shuffle-sections-init-fini.s lld :: ELF/shuffle-sections.s This new SyntheticSection is empty for X86, so in principle those tests should be unaffected. The immediate reason is that the shuffle implementation, maybeShuffle(), is dependent on inputSections. I think the real cause is that removeUnusedSyntheticSections() does not remove empty sections from the inputSections vector (although there is a comment that says that it does that). AFAICT elements are removed only from isd->sections and script->orphanSections. I could not find any uses of empty sections after this point, but you never know so thought of asking here. Is there a reason empty SyntheticSections in inputSections is preserved after removeUnusedSyntheticSections()? Or is there another approach that will not require maintaining the shuffle tests everytime a Synthetic section is added/removed? If it is safe to remove empty SyntheticSections from inputSections I can send out a patch to do that. Locally I have a simple patch that confirms that the shuffle tests do not fail after adding a new SyntheticSection. I can't think of new regression tests to add because this behavior cannot be demonstrated without adding a new SyntheticSection to InStruct. Thanks Amilendra -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20210717/70dcdc1b/attachment.html>
Fangrui Song via llvm-dev
2021-Jul-21 19:34 UTC
[llvm-dev] [lld][ELF] Regarding removeUnusedSyntheticSections()
On 2021-07-17, Amilendra Kodithuwakku via llvm-dev wrote:>Hi, > >I am working on an LLD port for a research project based on the AARCH64 based architecture which requires adding a new SyntheticSection to InStruct, but doing so gives me 2 failed x86 tests: > lld :: ELF/shuffle-sections-init-fini.s > lld :: ELF/shuffle-sections.s >This new SyntheticSection is empty for X86, so in principle those tests should be unaffected. > >The immediate reason is that the shuffle implementation, maybeShuffle(), is dependent on inputSections. I think the real cause is that removeUnusedSyntheticSections() does not remove empty sections from the inputSections vector (although there is a comment that says that it does that). AFAICT elements are removed only from isd->sections and script->orphanSections. > >I could not find any uses of empty sections after this point, but you never know so thought of asking here. Is there a reason empty SyntheticSections in inputSections is preserved after removeUnusedSyntheticSections()? Or is there another approach that will not require maintaining the shuffle tests everytime a Synthetic section is added/removed? > >If it is safe to remove empty SyntheticSections from inputSections I can send out a patch to do that. Locally I have a simple patch that confirms that the shuffle tests do not fail after adding a new SyntheticSection. I can't think of new regression tests to add because this behavior cannot be demonstrated without adding a new SyntheticSection to InStruct.It is safe. The comment is about the references (isd->sections; script->orphanSections). (I can fix it after one week if I haven't seen a patch yet:) )>Thanks >Amilendra