[PATCH] D37561: [ELF] - Don't crash when --emit-relocs is used with --gc-sections
George Rimar via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 18 02:41:02 PDT 2017
grimar added inline comments.
================
Comment at: ELF/InputSection.cpp:86-88
+ Live = !Config->GcSections;
+ if (!(Flags & SHF_ALLOC))
+ Live = Type != SHT_REL && Type != SHT_RELA;
----------------
ruiu wrote:
> grimar wrote:
> > ruiu wrote:
> > > This is too magical that it needs comment.
> > Oh, I am sorry, looks I put `=` instead of `|=` at last minute by mistake.
> > Fixed, added comment.
> It is better to define a helper function. You can use this.
>
> // Return true if a section with given section flags is live (will never be
> // GCed) by default. If a section can be GCed, this function returns false.
> static bool isLiveByDefault(uint64_t Flags, uint32_t Type) {
> // If GC is enabled, all memory-mapped sections are subject of GC.
> if (!Config->GcSections)
> return true;
> if (Flags & SHF_ALLOC)
> return false;
>
> // Besides that, relocation sections can also be GCed because their
> // relocation target sections may be GCed. This doesn't really matter
> // in most cases because the linker usually consumes relocation
> // sections instead of emitting them, but -emit-reloc needs this.
> return Type != SHT_REL && Type != SHT_RELA;
> }
Used. Thanks !
https://reviews.llvm.org/D37561
More information about the llvm-commits
mailing list