diff options
Diffstat (limited to 'llvm/tools/llvm-objcopy')
-rw-r--r-- | llvm/tools/llvm-objcopy/ELF/Object.cpp | 13 | ||||
-rw-r--r-- | llvm/tools/llvm-objcopy/ELF/Object.h | 2 |
2 files changed, 9 insertions, 6 deletions
diff --git a/llvm/tools/llvm-objcopy/ELF/Object.cpp b/llvm/tools/llvm-objcopy/ELF/Object.cpp index 8b895826b3c..ccc6efa5dbd 100644 --- a/llvm/tools/llvm-objcopy/ELF/Object.cpp +++ b/llvm/tools/llvm-objcopy/ELF/Object.cpp @@ -457,6 +457,13 @@ Error SymbolTableSection::removeSymbols( return Error::success(); } +void SymbolTableSection::replaceSectionReferences( + const DenseMap<SectionBase *, SectionBase *> &FromTo) { + for (std::unique_ptr<Symbol> &Sym : Symbols) + if (SectionBase *To = FromTo.lookup(Sym->DefinedIn)) + Sym->DefinedIn = To; +} + void SymbolTableSection::initialize(SectionTableRef SecTable) { Size = 0; setStrTab(SecTable.getSectionOfType<StringTableSection>( @@ -638,12 +645,6 @@ void RelocationSection::replaceSectionReferences( // Update the target section if it was replaced. if (SectionBase *To = FromTo.lookup(SecToApplyRel)) SecToApplyRel = To; - - // Change the sections where symbols are defined in if their - // original sections were replaced. - for (const Relocation &R : Relocations) - if (SectionBase *To = FromTo.lookup(R.RelocSymbol->DefinedIn)) - R.RelocSymbol->DefinedIn = To; } void SectionWriter::visit(const DynamicRelocationSection &Sec) { diff --git a/llvm/tools/llvm-objcopy/ELF/Object.h b/llvm/tools/llvm-objcopy/ELF/Object.h index 8e72cedcf27..732ff898ed5 100644 --- a/llvm/tools/llvm-objcopy/ELF/Object.h +++ b/llvm/tools/llvm-objcopy/ELF/Object.h @@ -529,6 +529,8 @@ public: void accept(SectionVisitor &Visitor) const override; void accept(MutableSectionVisitor &Visitor) override; Error removeSymbols(function_ref<bool(const Symbol &)> ToRemove) override; + void replaceSectionReferences( + const DenseMap<SectionBase *, SectionBase *> &FromTo) override; static bool classof(const SectionBase *S) { return S->Type == ELF::SHT_SYMTAB; |