[lld] [lld][ELF] Demote symbols in discarded sections to Undefined. (PR #68777)

Peter Smith via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 11 23:45:18 PDT 2023


https://github.com/smithp35 commented:

Does GNU ld permit this, or does it result in dangling relocations? If GNU ld does permit this then there's a chance that this might break some programs where the dangling relocations are benign. I guess that we may need to add a command line option to suppress the errors, although maybe not initially.

How does this work with uses of /DISCARD/ in a ld -r relocatable link? I guess a follow up question is what is it supposed to do for ld -r relocatable links. It would still be user error to /DISCARD/ a section where some other section had relocations to that section, but I don't think undefined symbols are checked for.

A possible alternative implementation could be to test each relocation in scanOne to see if the symbol is defined in a discarded section. You could then make a specific error message, or do the work to make the symbol undefined at that point. Not sure how well that would work out, but could be worth a prototype.

https://github.com/llvm/llvm-project/pull/68777


More information about the llvm-commits mailing list