[lld] r268604 - ELF: Do not use -1 to mark pieces of merge sections as being tail merged.
Rafael EspĂndola via llvm-commits
llvm-commits at lists.llvm.org
Thu May 5 08:29:15 PDT 2016
On 5 May 2016 at 00:10, Peter Collingbourne via llvm-commits
<llvm-commits at lists.llvm.org> wrote:
> Author: pcc
> Date: Wed May 4 23:10:12 2016
> New Revision: 268604
>
> URL: http://llvm.org/viewvc/llvm-project?rev=268604&view=rev
> Log:
> ELF: Do not use -1 to mark pieces of merge sections as being tail merged.
>
> We were previously using an output offset of -1 for both GC'd and tail
> merged pieces. We need to distinguish these two cases in order to filter
> GC'd symbols from the symbol table -- we were previously asserting when we
> asked for the VA of a symbol pointing into a dead piece, which would end
> up asking the tail merging string table for an offset even though we hadn't
> initialized it properly.
>
> This patch fixes the bug by using an offset of -1 to exclusively mean GC'd
> pieces, using 0 for tail merges, and distinguishing the tail merge case from
> an offset of 0 by asking the output section whether it is tail merge.
>
> Differential Revision: http://reviews.llvm.org/D19953
>
> Added:
> lld/trunk/test/ELF/string-gc.s
> Modified:
> lld/trunk/ELF/InputSection.cpp
> lld/trunk/ELF/InputSection.h
> lld/trunk/ELF/MarkLive.cpp
> lld/trunk/ELF/OutputSections.cpp
> lld/trunk/ELF/OutputSections.h
> lld/trunk/ELF/Writer.cpp
>
> Modified: lld/trunk/ELF/InputSection.cpp
> URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputSection.cpp?rev=268604&r1=268603&r2=268604&view=diff
> ==============================================================================
> --- lld/trunk/ELF/InputSection.cpp (original)
> +++ lld/trunk/ELF/InputSection.cpp Wed May 4 23:10:12 2016
> @@ -419,7 +419,8 @@ MergeInputSection<ELFT>::MergeInputSecti
> StringRef Data((const char *)D.data(), D.size());
> std::vector<std::pair<uintX_t, uintX_t>> &Offsets = this->Offsets;
>
> - uintX_t V = Config->GcSections ? -1 : 0;
> + uintX_t V = Config->GcSections ? MergeInputSection<ELFT>::PieceDead
> + : MergeInputSection<ELFT>::PieceLive;
> if (Header->sh_flags & SHF_STRINGS) {
> uintX_t Offset = 0;
> while (!Data.empty()) {
> @@ -478,15 +479,15 @@ typename ELFT::uint MergeInputSection<EL
> // Compute the Addend and if the Base is cached, return.
> uintX_t Addend = Offset - Start;
> uintX_t &Base = I->second;
> - if (Base != uintX_t(-1))
> + auto *MOS = static_cast<MergeOutputSection<ELFT> *>(this->OutSec);
> + if (!MOS->shouldTailMerge())
> return Base + Addend;
This disabled the caching, no?
Cheers,
Rafael
More information about the llvm-commits
mailing list