1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-25 04:02:41 +01:00

[NFC][object] Change the input parameter of the method isDebugSection.

Summary: This is a NFC patch to change the input parameter of the method SectionRef::isDebugSection(), by replacing the StringRef SectionName with DataRefImpl Sec. This allows us to determine if a section is debug type in more ways than just by section name.

Reviewed By: jhenderson

Differential Revision: https://reviews.llvm.org/D102601
This commit is contained in:
Esme-Yi 2021-05-26 08:47:53 +00:00
parent 75476d7b62
commit b08bc2bd30
8 changed files with 33 additions and 14 deletions

View File

@ -959,7 +959,7 @@ protected:
bool isSectionData(DataRefImpl Sec) const override;
bool isSectionBSS(DataRefImpl Sec) const override;
bool isSectionVirtual(DataRefImpl Sec) const override;
bool isDebugSection(StringRef SectionName) const override;
bool isDebugSection(DataRefImpl Sec) const override;
relocation_iterator section_rel_begin(DataRefImpl Sec) const override;
relocation_iterator section_rel_end(DataRefImpl Sec) const override;

View File

@ -289,7 +289,7 @@ protected:
bool isSectionVirtual(DataRefImpl Sec) const override;
bool isBerkeleyText(DataRefImpl Sec) const override;
bool isBerkeleyData(DataRefImpl Sec) const override;
bool isDebugSection(StringRef SectionName) const override;
bool isDebugSection(DataRefImpl Sec) const override;
relocation_iterator section_rel_begin(DataRefImpl Sec) const override;
relocation_iterator section_rel_end(DataRefImpl Sec) const override;
std::vector<SectionRef> dynamic_relocation_sections() const override;
@ -928,7 +928,14 @@ bool ELFObjectFile<ELFT>::isBerkeleyData(DataRefImpl Sec) const {
}
template <class ELFT>
bool ELFObjectFile<ELFT>::isDebugSection(StringRef SectionName) const {
bool ELFObjectFile<ELFT>::isDebugSection(DataRefImpl Sec) const {
Expected<StringRef> SectionNameOrErr = getSectionName(Sec);
if (!SectionNameOrErr) {
// TODO: Report the error message properly.
consumeError(SectionNameOrErr.takeError());
return false;
}
StringRef SectionName = SectionNameOrErr.get();
return SectionName.startswith(".debug") ||
SectionName.startswith(".zdebug") || SectionName == ".gdb_index";
}

View File

@ -309,7 +309,7 @@ public:
bool isSectionBSS(DataRefImpl Sec) const override;
bool isSectionVirtual(DataRefImpl Sec) const override;
bool isSectionBitcode(DataRefImpl Sec) const override;
bool isDebugSection(StringRef SectionName) const override;
bool isDebugSection(DataRefImpl Sec) const override;
/// When dsymutil generates the companion file, it strips all unnecessary
/// sections (e.g. everything in the _TEXT segment) by omitting their body

View File

@ -123,7 +123,7 @@ public:
bool isBerkeleyData() const;
/// Whether this section is a debug section.
bool isDebugSection(StringRef SectionName) const;
bool isDebugSection() const;
bool containsSymbol(SymbolRef S) const;
@ -274,7 +274,7 @@ protected:
virtual bool isSectionStripped(DataRefImpl Sec) const;
virtual bool isBerkeleyText(DataRefImpl Sec) const;
virtual bool isBerkeleyData(DataRefImpl Sec) const;
virtual bool isDebugSection(StringRef SectionName) const;
virtual bool isDebugSection(DataRefImpl Sec) const;
virtual relocation_iterator section_rel_begin(DataRefImpl Sec) const = 0;
virtual relocation_iterator section_rel_end(DataRefImpl Sec) const = 0;
virtual Expected<section_iterator> getRelocatedSection(DataRefImpl Sec) const;
@ -504,8 +504,8 @@ inline bool SectionRef::isBerkeleyData() const {
return OwningObject->isBerkeleyData(SectionPimpl);
}
inline bool SectionRef::isDebugSection(StringRef SectionName) const {
return OwningObject->isDebugSection(SectionName);
inline bool SectionRef::isDebugSection() const {
return OwningObject->isDebugSection(SectionPimpl);
}
inline relocation_iterator SectionRef::relocation_begin() const {

View File

@ -328,7 +328,14 @@ bool COFFObjectFile::isSectionBSS(DataRefImpl Ref) const {
// The .debug sections are the only debug sections for COFF
// (\see MCObjectFileInfo.cpp).
bool COFFObjectFile::isDebugSection(StringRef SectionName) const {
bool COFFObjectFile::isDebugSection(DataRefImpl Ref) const {
Expected<StringRef> SectionNameOrErr = getSectionName(Ref);
if (!SectionNameOrErr) {
// TODO: Report the error message properly.
consumeError(SectionNameOrErr.takeError());
return false;
}
StringRef SectionName = SectionNameOrErr.get();
return SectionName.startswith(".debug");
}

View File

@ -2035,7 +2035,14 @@ bool MachOObjectFile::isSectionBSS(DataRefImpl Sec) const {
SectionType == MachO::S_GB_ZEROFILL);
}
bool MachOObjectFile::isDebugSection(StringRef SectionName) const {
bool MachOObjectFile::isDebugSection(DataRefImpl Sec) const {
Expected<StringRef> SectionNameOrErr = getSectionName(Sec);
if (!SectionNameOrErr) {
// TODO: Report the error message properly.
consumeError(SectionNameOrErr.takeError());
return false;
}
StringRef SectionName = SectionNameOrErr.get();
return SectionName.startswith("__debug") ||
SectionName.startswith("__zdebug") ||
SectionName.startswith("__apple") || SectionName == "__gdb_index" ||

View File

@ -94,9 +94,7 @@ bool ObjectFile::isBerkeleyData(DataRefImpl Sec) const {
return isSectionData(Sec);
}
bool ObjectFile::isDebugSection(StringRef SectionName) const {
return false;
}
bool ObjectFile::isDebugSection(DataRefImpl Sec) const { return false; }
Expected<section_iterator>
ObjectFile::getRelocatedSection(DataRefImpl Sec) const {

View File

@ -93,7 +93,7 @@ void dwarfdump::calculateSectionSizes(const ObjectFile &Obj,
LLVM_DEBUG(dbgs() << SectionName.str() << ": " << Section.getSize()
<< '\n');
if (!Section.isDebugSection(SectionName))
if (!Section.isDebugSection())
continue;
Sizes.TotalDebugSectionsSize += Section.getSize();