[PATCH] D28612: [ELF] - Added support for --emit-relocs.
George Rimar via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 26 00:56:15 PST 2017
grimar added inline comments.
================
Comment at: ELF/InputFiles.cpp:409
+ if (!isa<InputSection<ELFT>>(Target))
+ fatal(toString(this) + ": --emit-relocs for relocations sections "
+ "pointing to .eh_frame is not supported");
----------------
ruiu wrote:
> grimar wrote:
> > I am going to remove that fatal error in following patch.
> > It is needed for linux kernel, but since it involves move DependentSection from InputSection<ELFT> to somewhere and also adding more additional tests probably, I think it is better not to do that change in this patch.
> > Hope it's ok.
> I think what you really need to do is to make it a vector just like Rafael did in https://reviews.llvm.org/D28626.
I do not see how vector helps. Issue here is that
DependentSection is a member of InputSection, but
EhInputSection inhireted from InputSectionBase<ELFT>
```
EhInputSection : public InputSectionBase<ELFT>
```
In following patch I plan to move DependentSection to InputSectionBase probably to solve that problem.
================
Comment at: ELF/LinkerScript.cpp:265-270
+
+ // If we discard a section, we also should discard a dependent section.
+ InputSection<ELFT> *IS = dyn_cast<InputSection<ELFT>>(S);
+ if (!IS || !IS->DependentSection || !IS->DependentSection->Live)
+ continue;
+ discard({IS->DependentSection});
----------------
ruiu wrote:
> I don't think this is correct. You shouldn't add any code this function, or there's a bug in GC.
>
> If section S depends on section T, and if S is marked as dead, T must be marked as dead too before the control reaches this function. So both S and T will be discarded without doing anything special.
It is not relative to GC at all.
Please look at emit-reloc-discard.s.
Call is:
```
# RUN: echo "SECTIONS { /DISCARD/ : { *(.debug*) } }" > %t.script
# RUN: ld.lld --emit-relocs --script %t.script %t.o -o %t1
```
So .debug_* sections are discarded **from script**, GC is not involved and not executed.
And since .debug_ are discarded, .rela.debug_* should be discarded as well. That is what that place do.
https://reviews.llvm.org/D28612
More information about the llvm-commits
mailing list