diff options
author | Jake Ehrlich <jakehehrlich@google.com> | 2017-10-10 18:32:22 +0000 |
---|---|---|
committer | Jake Ehrlich <jakehehrlich@google.com> | 2017-10-10 18:32:22 +0000 |
commit | c5ff72708d232079e1c2099165584cf8d03e1c7e (patch) | |
tree | 8271c157e974cec8a6b0ba96696b6781f68db83e /llvm/tools/llvm-objcopy/Object.cpp | |
parent | 77ec1ffe5c8046e24e3cd2a5d27f7497badea741 (diff) | |
download | bcm5719-llvm-c5ff72708d232079e1c2099165584cf8d03e1c7e.tar.gz bcm5719-llvm-c5ff72708d232079e1c2099165584cf8d03e1c7e.zip |
Revert "temporary"
I forgot to add a proper commit message. I'm reverting this
to fix that.
This reverts commit r315344.
llvm-svn: 315345
Diffstat (limited to 'llvm/tools/llvm-objcopy/Object.cpp')
-rw-r--r-- | llvm/tools/llvm-objcopy/Object.cpp | 77 |
1 files changed, 3 insertions, 74 deletions
diff --git a/llvm/tools/llvm-objcopy/Object.cpp b/llvm/tools/llvm-objcopy/Object.cpp index bb79e4269d4..3e6606f7095 100644 --- a/llvm/tools/llvm-objcopy/Object.cpp +++ b/llvm/tools/llvm-objcopy/Object.cpp @@ -37,7 +37,6 @@ void Segment::writeSegment(FileOutputBuffer &Out) const { std::copy(std::begin(Contents), std::end(Contents), Buf); } -void SectionBase::removeSectionReferences(const SectionBase *Sec) {} void SectionBase::initialize(SectionTableRef SecTable) {} void SectionBase::finalize() {} @@ -139,19 +138,6 @@ void SymbolTableSection::addSymbol(StringRef Name, uint8_t Bind, uint8_t Type, Size += this->EntrySize; } -void SymbolTableSection::removeSectionReferences(const SectionBase *Sec) { - if (SymbolNames == Sec) { - error("String table " + SymbolNames->Name + - " cannot be removed because it is referenced by the symbol table " + - this->Name); - } - auto Iter = - std::remove_if(std::begin(Symbols), std::end(Symbols), - [=](const SymPtr &Sym) { return Sym->DefinedIn == Sec; }); - Size -= (std::end(Symbols) - Iter) * this->EntrySize; - Symbols.erase(Iter, std::end(Symbols)); -} - void SymbolTableSection::initialize(SectionTableRef SecTable) { Size = 0; setStrTab(SecTable.getSectionOfType<StringTableSection>( @@ -209,19 +195,7 @@ void SymbolTableSectionImpl<ELFT>::writeSection( } template <class SymTabType> -void RelocSectionWithSymtabBase<SymTabType>::removeSectionReferences( - const SectionBase *Sec) { - if (Symbols == Sec) { - error("Symbol table " + Symbols->Name + " cannot be removed because it is " - "referenced by the relocation " - "section " + - this->Name); - } -} - -template <class SymTabType> -void RelocSectionWithSymtabBase<SymTabType>::initialize( - SectionTableRef SecTable) { +void RelocationSectionBase<SymTabType>::initialize(SectionTableRef SecTable) { setSymTab(SecTable.getSectionOfType<SymTabType>( Link, "Link field value " + Twine(Link) + " in section " + Name + " is invalid", @@ -236,8 +210,7 @@ void RelocSectionWithSymtabBase<SymTabType>::initialize( setSection(nullptr); } -template <class SymTabType> -void RelocSectionWithSymtabBase<SymTabType>::finalize() { +template <class SymTabType> void RelocationSectionBase<SymTabType>::finalize() { this->Link = Symbols->Index; if (SecToApplyRel != nullptr) this->Info = SecToApplyRel->Index; @@ -276,14 +249,6 @@ void DynamicRelocationSection::writeSection(llvm::FileOutputBuffer &Out) const { Out.getBufferStart() + Offset); } -void SectionWithStrTab::removeSectionReferences(const SectionBase *Sec) { - if (StrTab == Sec) { - error("String table " + StrTab->Name + " cannot be removed because it is " - "referenced by the section " + - this->Name); - } -} - bool SectionWithStrTab::classof(const SectionBase *S) { return isa<DynamicSymbolTableSection>(S) || isa<DynamicSection>(S); } @@ -624,41 +589,6 @@ void Object<ELFT>::writeSectionData(FileOutputBuffer &Out) const { Section->writeSection(Out); } -template <class ELFT> -void Object<ELFT>::removeSections( - std::function<bool(const SectionBase &)> ToRemove) { - - auto Iter = std::stable_partition( - std::begin(Sections), std::end(Sections), [=](const SecPtr &Sec) { - if (ToRemove(*Sec)) - return false; - if (auto RelSec = dyn_cast<RelocationSectionBase>(Sec.get())) - return !ToRemove(*RelSec->getSection()); - return true; - }); - if (SymbolTable != nullptr && ToRemove(*SymbolTable)) - SymbolTable = nullptr; - if (ToRemove(*SectionNames)) { - // Right now llvm-objcopy always outputs section headers. This will not - // always be the case. Eventully the section header table will become - // optional and if no section header is output then there dosn't need to be - // a section header string table. - error("Cannot remove " + SectionNames->Name + - " because it is the section header string table."); - } - // Now make sure there are no remaining references to the sections that will - // be removed. Sometimes it is impossible to remove a reference so we emit - // an error here instead. - for (auto &RemoveSec : make_range(Iter, std::end(Sections))) { - for (auto &Segment : Segments) - Segment->removeSection(RemoveSec.get()); - for (auto &KeepSec : make_range(std::begin(Sections), Iter)) - KeepSec->removeSectionReferences(RemoveSec.get()); - } - // Now finally get rid of them all togethor. - Sections.erase(Iter, std::end(Sections)); -} - template <class ELFT> void ELFObject<ELFT>::sortSections() { // Put all sections in offset order. Maintain the ordering as closely as // possible while meeting that demand however. @@ -762,8 +692,7 @@ template <class ELFT> void ELFObject<ELFT>::finalize() { this->SectionNames->addString(Section->Name); } // Make sure we add the names of all the symbols. - if (this->SymbolTable != nullptr) - this->SymbolTable->addSymbolNames(); + this->SymbolTable->addSymbolNames(); sortSections(); assignOffsets(); |