[PATCH] D29273: [ELF] - Added partial support for --emit-relocs (no --gc-section case)

Rui Ueyama via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 2 10:00:59 PST 2017


ruiu added inline comments.


================
Comment at: ELF/LinkerScript.cpp:266
+
+    // If we discard a section, we also should discard a dependent section.
+    InputSection<ELFT> *IS = dyn_cast<InputSection<ELFT>>(S);
----------------
grimar wrote:
> ruiu wrote:
> > grimar wrote:
> > > ruiu wrote:
> > > > Please describe not what we are doing but why we are doing.
> > > Done.
> > 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?
> Linux kernel contains exactly the situation I show in testcase.
> It discards all debug sections:
> 
> ```
> /DISCARD/ : { *(.debug*) }
> ```
> 
> And without that code we just crash for this situation. Because we will try to emit .rela.debug* and crash.
> That is the only real situation I care here about.
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.


https://reviews.llvm.org/D29273





More information about the llvm-commits mailing list