[llvm] r241112 - Implement containsSymbol with other lower level methods.
Rafael Espindola
rafael.espindola at gmail.com
Tue Jun 30 13:18:49 PDT 2015
Author: rafael
Date: Tue Jun 30 15:18:49 2015
New Revision: 241112
URL: http://llvm.org/viewvc/llvm-project?rev=241112&view=rev
Log:
Implement containsSymbol with other lower level methods.
Modified:
llvm/trunk/include/llvm/Object/COFF.h
llvm/trunk/include/llvm/Object/ELFObjectFile.h
llvm/trunk/include/llvm/Object/MachO.h
llvm/trunk/include/llvm/Object/ObjectFile.h
llvm/trunk/lib/Object/COFFObjectFile.cpp
llvm/trunk/lib/Object/MachOObjectFile.cpp
llvm/trunk/lib/Object/ObjectFile.cpp
Modified: llvm/trunk/include/llvm/Object/COFF.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Object/COFF.h?rev=241112&r1=241111&r2=241112&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Object/COFF.h (original)
+++ llvm/trunk/include/llvm/Object/COFF.h Tue Jun 30 15:18:49 2015
@@ -669,7 +669,6 @@ protected:
bool isSectionData(DataRefImpl Sec) const override;
bool isSectionBSS(DataRefImpl Sec) const override;
bool isSectionVirtual(DataRefImpl Sec) const override;
- bool sectionContainsSymbol(DataRefImpl Sec, DataRefImpl Symb) const override;
relocation_iterator section_rel_begin(DataRefImpl Sec) const override;
relocation_iterator section_rel_end(DataRefImpl Sec) const override;
Modified: llvm/trunk/include/llvm/Object/ELFObjectFile.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Object/ELFObjectFile.h?rev=241112&r1=241111&r2=241112&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Object/ELFObjectFile.h (original)
+++ llvm/trunk/include/llvm/Object/ELFObjectFile.h Tue Jun 30 15:18:49 2015
@@ -222,7 +222,6 @@ protected:
bool isSectionData(DataRefImpl Sec) const override;
bool isSectionBSS(DataRefImpl Sec) const override;
bool isSectionVirtual(DataRefImpl Sec) const override;
- bool sectionContainsSymbol(DataRefImpl Sec, DataRefImpl Symb) const override;
relocation_iterator section_rel_begin(DataRefImpl Sec) const override;
relocation_iterator section_rel_end(DataRefImpl Sec) const override;
section_iterator getRelocatedSection(DataRefImpl Sec) const override;
@@ -596,17 +595,6 @@ bool ELFObjectFile<ELFT>::isSectionVirtu
}
template <class ELFT>
-bool ELFObjectFile<ELFT>::sectionContainsSymbol(DataRefImpl Sec,
- DataRefImpl Symb) const {
- const Elf_Sym *ESym = toELFSymIter(Symb);
-
- uintX_t Index = ESym->st_shndx;
- bool Reserved = Index >= ELF::SHN_LORESERVE && Index <= ELF::SHN_HIRESERVE;
-
- return !Reserved && (&*toELFShdrIter(Sec) == EF.getSection(ESym->st_shndx));
-}
-
-template <class ELFT>
relocation_iterator
ELFObjectFile<ELFT>::section_rel_begin(DataRefImpl Sec) const {
DataRefImpl RelData;
Modified: llvm/trunk/include/llvm/Object/MachO.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Object/MachO.h?rev=241112&r1=241111&r2=241112&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Object/MachO.h (original)
+++ llvm/trunk/include/llvm/Object/MachO.h Tue Jun 30 15:18:49 2015
@@ -230,7 +230,6 @@ public:
bool isSectionData(DataRefImpl Sec) const override;
bool isSectionBSS(DataRefImpl Sec) const override;
bool isSectionVirtual(DataRefImpl Sec) const override;
- bool sectionContainsSymbol(DataRefImpl Sec, DataRefImpl Symb) const override;
relocation_iterator section_rel_begin(DataRefImpl Sec) const override;
relocation_iterator section_rel_end(DataRefImpl Sec) const override;
Modified: llvm/trunk/include/llvm/Object/ObjectFile.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Object/ObjectFile.h?rev=241112&r1=241111&r2=241112&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Object/ObjectFile.h (original)
+++ llvm/trunk/include/llvm/Object/ObjectFile.h Tue Jun 30 15:18:49 2015
@@ -223,8 +223,6 @@ protected:
virtual bool isSectionBSS(DataRefImpl Sec) const = 0;
// A section is 'virtual' if its contents aren't present in the object image.
virtual bool isSectionVirtual(DataRefImpl Sec) const = 0;
- virtual bool sectionContainsSymbol(DataRefImpl Sec,
- DataRefImpl Symb) const = 0;
virtual relocation_iterator section_rel_begin(DataRefImpl Sec) const = 0;
virtual relocation_iterator section_rel_end(DataRefImpl Sec) const = 0;
virtual section_iterator getRelocatedSection(DataRefImpl Sec) const;
@@ -400,11 +398,6 @@ inline bool SectionRef::isVirtual() cons
return OwningObject->isSectionVirtual(SectionPimpl);
}
-inline bool SectionRef::containsSymbol(SymbolRef S) const {
- return OwningObject->sectionContainsSymbol(SectionPimpl,
- S.getRawDataRefImpl());
-}
-
inline relocation_iterator SectionRef::relocation_begin() const {
return OwningObject->section_rel_begin(SectionPimpl);
}
Modified: llvm/trunk/lib/Object/COFFObjectFile.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/COFFObjectFile.cpp?rev=241112&r1=241111&r2=241112&view=diff
==============================================================================
--- llvm/trunk/lib/Object/COFFObjectFile.cpp (original)
+++ llvm/trunk/lib/Object/COFFObjectFile.cpp Tue Jun 30 15:18:49 2015
@@ -322,14 +322,6 @@ bool COFFObjectFile::isSectionVirtual(Da
return Sec->PointerToRawData == 0;
}
-bool COFFObjectFile::sectionContainsSymbol(DataRefImpl SecRef,
- DataRefImpl SymbRef) const {
- const coff_section *Sec = toSec(SecRef);
- COFFSymbolRef Symb = getCOFFSymbol(SymbRef);
- int32_t SecNumber = (Sec - SectionTable) + 1;
- return SecNumber == Symb.getSectionNumber();
-}
-
static uint32_t getNumberOfRelocations(const coff_section *Sec,
MemoryBufferRef M, const uint8_t *base) {
// The field for the number of relocations in COFF section table is only
Modified: llvm/trunk/lib/Object/MachOObjectFile.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/MachOObjectFile.cpp?rev=241112&r1=241111&r2=241112&view=diff
==============================================================================
--- llvm/trunk/lib/Object/MachOObjectFile.cpp (original)
+++ llvm/trunk/lib/Object/MachOObjectFile.cpp Tue Jun 30 15:18:49 2015
@@ -567,21 +567,6 @@ bool MachOObjectFile::isSectionVirtual(D
return false;
}
-bool MachOObjectFile::sectionContainsSymbol(DataRefImpl Sec,
- DataRefImpl Symb) const {
- SymbolRef::Type ST = getSymbolType(Symb);
- if (ST == SymbolRef::ST_Unknown)
- return false;
-
- uint64_t SectBegin = getSectionAddress(Sec);
- uint64_t SectEnd = getSectionSize(Sec);
- SectEnd += SectBegin;
-
- uint64_t SymAddr;
- getSymbolAddress(Symb, SymAddr);
- return (SymAddr >= SectBegin) && (SymAddr < SectEnd);
-}
-
relocation_iterator MachOObjectFile::section_rel_begin(DataRefImpl Sec) const {
DataRefImpl Ret;
Ret.d.a = Sec.d.a;
Modified: llvm/trunk/lib/Object/ObjectFile.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/ObjectFile.cpp?rev=241112&r1=241111&r2=241112&view=diff
==============================================================================
--- llvm/trunk/lib/Object/ObjectFile.cpp (original)
+++ llvm/trunk/lib/Object/ObjectFile.cpp Tue Jun 30 15:18:49 2015
@@ -28,6 +28,13 @@ void ObjectFile::anchor() { }
ObjectFile::ObjectFile(unsigned int Type, MemoryBufferRef Source)
: SymbolicFile(Type, Source) {}
+bool SectionRef::containsSymbol(SymbolRef S) const {
+ section_iterator SymSec = getObject()->section_end();
+ if (S.getSection(SymSec))
+ return false;
+ return *this == *SymSec;
+}
+
std::error_code ObjectFile::printSymbolName(raw_ostream &OS,
DataRefImpl Symb) const {
StringRef Name;
More information about the llvm-commits
mailing list