[PATCH] D38724: [ELF] - Do not collect SHT_REL[A] sections unconditionally when --gc-sections and --emit-relocs used together.

George Rimar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 23 03:51:49 PDT 2017


grimar added a comment.

In https://reviews.llvm.org/D38724#902841, @mcgrathr wrote:

> This change works on my case, but it names the reloc sections it emits based on the first input section in the output section being relocated rather than on the output section itself.
>  e.g. in my -ffunction-sections --gc-sections --emit-relocs build, the SHT_RELA section with sh_info pointing to the .text section is called .rela.text.first_function_in_text rather than .rela.text.


I am not sure that is an issue as SHT_RELA section name should be insignificant here, but it I would probably fix that to make output nicer and be consistent with GNU linkers. I'll take a look.



================
Comment at: ELF/MarkLive.cpp:228
     if (auto *MS = dyn_cast<MergeInputSection>(Sec))
       MS->markLiveAt(Offset);
 
----------------
ruiu wrote:
> I took time to investigate this, and looks like the easiest way of doing this is to change
> 
>    void markLiveAt(uint64_t Offset) {
>     assert(this->Flags & llvm::ELF::SHF_ALLOC);
>     LiveOffsets.insert(Offset);
>    }
> 
> to
> 
>   void markLiveAt(uint64_t Offset) {
>     if (this->Flags & llvm::ELF::SHF_ALLOC)
>       LiveOffsets.insert(Offset);
>    }
Thanks for your time. It is probably the easiest way indeed,
but I supposed D38996 is a better cleanup solution for this place. 
Sounds like I should abandon it then ?


https://reviews.llvm.org/D38724





More information about the llvm-commits mailing list