[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
Wed Feb 1 17:54:41 PST 2017

ruiu added inline comments.

Comment at: ELF/Driver.cpp:238
+  // Next options combination is not yet implemented.
+  if (Config->EmitRelocs && Config->GcSections)
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.

Comment at: ELF/InputFiles.cpp:409-410
+      if (!isa<InputSection<ELFT>>(Target))
+        fatal(toString(this) + ": --emit-relocs for relocations sections "
+                               "pointing to .eh_frame is not supported");
+      InputSection<ELFT> *RelocSec = make<InputSection<ELFT>>(this, &Sec, Name);
So, why? Please explain for those who will read this code.

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:
> > 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?


More information about the llvm-commits mailing list