Previously LLD crashed on on provided testcase because "/DISCARD/" was
not supported. Patch implements that.
Details
Diff Detail
Event Timeline
ELF/LinkerScript.cpp | ||
---|---|---|
266 | Please describe not what we are doing but why we are doing. |
ELF/LinkerScript.cpp | ||
---|---|---|
266 | Done. |
ELF/Driver.cpp | ||
---|---|---|
238 | This comment can be improved. // -emit-relocs and -gc-sections don't conflict in theory, but LLD currently // does not support the combination due to an implementation limitation. | |
ELF/InputFiles.cpp | ||
409–410 | So, why? Please explain for those who will read this code. | |
ELF/LinkerScript.cpp | ||
266 | I still do not understand why you need this. Well, I do understand what you are trying to do here and what your intention is, but I wonder why you specifically have to care about this case. Let's say you have sections A and B. A defines symbol X, and B has an undefined symbol X. Naturally, the B's undefined symbol will be resolved using A. But, what if you discard section A using a linker script? What will happen? Isn't this essentially the same situation as this? |
ELF/InputFiles.cpp | ||
---|---|---|
409–410 | Will "pointing to .eh_frame is not supported due to an implementation limitation" sound fine for you ? | |
ELF/LinkerScript.cpp | ||
266 | Linux kernel contains exactly the situation I show in testcase. /DISCARD/ : { *(.debug*) } And without that code we just crash for this situation. Because we will try to emit .rela.debug* and crash. |
ELF/LinkerScript.cpp | ||
---|---|---|
266 | Do not focus too much on the Linux kernel. Please attempt to find the fundamental issue and a generic solution. If you reach a conclusion that this still needs special handling after a careful examination, that is fine, but adding a piece of code just to link the Linux kernel is not ok. |
ELF/LinkerScript.cpp | ||
---|---|---|
266 |
So we have next. SECTIONS { . = 0x1000; .A : { *(.A) } /DISCARD/ : { *(.B*) } } .section .A,"a" .quad foo .section .B,"a" foo: What will happen? We will not fail on inputs above. BFD will, gold also does not. We resolve symbol VA to zero in that case. But how it is can be relative to this patch ? Both sections A and B apply relocations using InputSectionBase<ELFT>::relocate. If A refers to symbol defined in B and we discard B, it still should be possible to know about "issue", because we apply relocations and can find out that symbol is in discarded section during relocation loop. In my case for --emit-relocs lets say I have A and .rela.A. And script discards A. One another solution I though about was: |
To support discarding of .eh_frame when in has relocation section,
I had to change where DependentSections lives, now it is a member of
InputSectionBase<ELFT>
This comment can be improved.