diff options
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/Object/FunctionIndexObjectFile.cpp | 5 | ||||
-rw-r--r-- | llvm/lib/Object/IRObjectFile.cpp | 5 | ||||
-rw-r--r-- | llvm/lib/Object/MachOObjectFile.cpp | 8 | ||||
-rw-r--r-- | llvm/lib/Object/ObjectFile.cpp | 7 |
4 files changed, 17 insertions, 8 deletions
diff --git a/llvm/lib/Object/FunctionIndexObjectFile.cpp b/llvm/lib/Object/FunctionIndexObjectFile.cpp index fe111de1a9c..927fd1409a6 100644 --- a/llvm/lib/Object/FunctionIndexObjectFile.cpp +++ b/llvm/lib/Object/FunctionIndexObjectFile.cpp @@ -35,10 +35,7 @@ std::unique_ptr<FunctionInfoIndex> FunctionIndexObjectFile::takeIndex() { ErrorOr<MemoryBufferRef> FunctionIndexObjectFile::findBitcodeInObject(const ObjectFile &Obj) { for (const SectionRef &Sec : Obj.sections()) { - StringRef SecName; - if (std::error_code EC = Sec.getName(SecName)) - return EC; - if (SecName == ".llvmbc") { + if (Sec.isBitcode()) { StringRef SecContents; if (std::error_code EC = Sec.getContents(SecContents)) return EC; diff --git a/llvm/lib/Object/IRObjectFile.cpp b/llvm/lib/Object/IRObjectFile.cpp index 5548a3822b8..49737b5f6f9 100644 --- a/llvm/lib/Object/IRObjectFile.cpp +++ b/llvm/lib/Object/IRObjectFile.cpp @@ -266,10 +266,7 @@ basic_symbol_iterator IRObjectFile::symbol_end_impl() const { ErrorOr<MemoryBufferRef> IRObjectFile::findBitcodeInObject(const ObjectFile &Obj) { for (const SectionRef &Sec : Obj.sections()) { - StringRef SecName; - if (std::error_code EC = Sec.getName(SecName)) - return EC; - if (SecName == ".llvmbc") { + if (Sec.isBitcode()) { StringRef SecContents; if (std::error_code EC = Sec.getContents(SecContents)) return EC; diff --git a/llvm/lib/Object/MachOObjectFile.cpp b/llvm/lib/Object/MachOObjectFile.cpp index ed0ca68653f..3a892d21db3 100644 --- a/llvm/lib/Object/MachOObjectFile.cpp +++ b/llvm/lib/Object/MachOObjectFile.cpp @@ -630,6 +630,14 @@ bool MachOObjectFile::isSectionVirtual(DataRefImpl Sec) const { return false; } +bool MachOObjectFile::isSectionBitcode(DataRefImpl Sec) const { + StringRef SegmentName = getSectionFinalSegmentName(Sec); + StringRef SectName; + if (!getSectionName(Sec, SectName)) + return (SegmentName == "__LLVM" && SectName == "__bitcode"); + return false; +} + relocation_iterator MachOObjectFile::section_rel_begin(DataRefImpl Sec) const { DataRefImpl Ret; Ret.d.a = Sec.d.a; diff --git a/llvm/lib/Object/ObjectFile.cpp b/llvm/lib/Object/ObjectFile.cpp index d12dc411361..860cefa113c 100644 --- a/llvm/lib/Object/ObjectFile.cpp +++ b/llvm/lib/Object/ObjectFile.cpp @@ -55,6 +55,13 @@ std::error_code ObjectFile::printSymbolName(raw_ostream &OS, uint32_t ObjectFile::getSymbolAlignment(DataRefImpl DRI) const { return 0; } +bool ObjectFile::isSectionBitcode(DataRefImpl Sec) const { + StringRef SectName; + if (!getSectionName(Sec, SectName)) + return SectName == ".llvmbc"; + return false; +} + section_iterator ObjectFile::getRelocatedSection(DataRefImpl Sec) const { return section_iterator(SectionRef(Sec, this)); } |