diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2015-06-26 12:44:10 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2015-06-26 12:44:10 +0000 |
commit | edd5f84419db0228d8379f5287c3ae26426f47d6 (patch) | |
tree | 346e1280851d8da47edf199cb41ceeff0c20357f | |
parent | 41401e9c803c52af38cf0ad7813c35b5336006a4 (diff) | |
download | bcm5719-llvm-edd5f84419db0228d8379f5287c3ae26426f47d6.tar.gz bcm5719-llvm-edd5f84419db0228d8379f5287c3ae26426f47d6.zip |
Expose getFlags via ELFSectionRef.
llvm-svn: 240779
-rw-r--r-- | llvm/include/llvm/Object/ELFObjectFile.h | 15 | ||||
-rw-r--r-- | llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp | 14 |
2 files changed, 15 insertions, 14 deletions
diff --git a/llvm/include/llvm/Object/ELFObjectFile.h b/llvm/include/llvm/Object/ELFObjectFile.h index 889425c4d92..60a9f70f6ab 100644 --- a/llvm/include/llvm/Object/ELFObjectFile.h +++ b/llvm/include/llvm/Object/ELFObjectFile.h @@ -48,6 +48,7 @@ protected: virtual uint64_t getSymbolSize(DataRefImpl Symb) const = 0; virtual uint8_t getSymbolOther(DataRefImpl Symb) const = 0; virtual uint32_t getSectionType(DataRefImpl Sec) const = 0; + virtual uint64_t getSectionFlags(DataRefImpl Sec) const = 0; public: virtual ErrorOr<int64_t> getRelocationAddend(DataRefImpl Rel) const = 0; @@ -59,8 +60,6 @@ public: typedef iterator_range<elf_symbol_iterator> elf_symbol_iterator_range; virtual elf_symbol_iterator_range getDynamicSymbolIterators() const = 0; - virtual uint64_t getSectionFlags(SectionRef Sec) const = 0; - elf_symbol_iterator_range symbols() const; static inline bool classof(const Binary *v) { return v->isELF(); } @@ -79,6 +78,10 @@ public: uint32_t getType() const { return getObject()->getSectionType(getRawDataRefImpl()); } + + uint64_t getFlags() const { + return getObject()->getSectionFlags(getRawDataRefImpl()); + } }; class ELFSymbolRef : public SymbolRef { @@ -187,6 +190,7 @@ protected: SmallVectorImpl<char> &Result) const override; uint32_t getSectionType(DataRefImpl Sec) const override; + uint64_t getSectionFlags(DataRefImpl Sec) const override; uint64_t getROffset(DataRefImpl Rel) const; StringRef getRelocationTypeName(uint32_t Type) const; @@ -279,8 +283,6 @@ public: ErrorOr<int64_t> getRelocationAddend(DataRefImpl Rel) const override; bool hasRelocationAddend(DataRefImpl Rel) const override; - uint64_t getSectionFlags(SectionRef Sec) const override; - uint8_t getBytesInAddress() const override; StringRef getFileFormatName() const override; unsigned getArch() const override; @@ -325,9 +327,8 @@ std::error_code ELFObjectFile<ELFT>::getSymbolName(DataRefImpl Symb, } template <class ELFT> -uint64_t ELFObjectFile<ELFT>::getSectionFlags(SectionRef Sec) const { - DataRefImpl DRI = Sec.getRawDataRefImpl(); - return toELFShdrIter(DRI)->sh_flags; +uint64_t ELFObjectFile<ELFT>::getSectionFlags(DataRefImpl Sec) const { + return toELFShdrIter(Sec)->sh_flags; } template <class ELFT> diff --git a/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp b/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp index fdb634e888c..489589ef1f8 100644 --- a/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp +++ b/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp @@ -266,10 +266,10 @@ computeAllocationSizeForSections(std::vector<uint64_t> &SectionSizes, return TotalSize; } -static bool isRequiredForExecution(const SectionRef &Section) { +static bool isRequiredForExecution(const SectionRef Section) { const ObjectFile *Obj = Section.getObject(); - if (auto *ELFObj = dyn_cast<object::ELFObjectFileBase>(Obj)) - return ELFObj->getSectionFlags(Section) & ELF::SHF_ALLOC; + if (isa<object::ELFObjectFileBase>(Obj)) + return ELFSectionRef(Section).getFlags() & ELF::SHF_ALLOC; if (auto *COFFObj = dyn_cast<object::COFFObjectFile>(Obj)) { const coff_section *CoffSection = COFFObj->getCOFFSection(Section); // Avoid loading zero-sized COFF sections. @@ -286,12 +286,12 @@ static bool isRequiredForExecution(const SectionRef &Section) { assert(isa<MachOObjectFile>(Obj)); return true; - } +} -static bool isReadOnlyData(const SectionRef &Section) { +static bool isReadOnlyData(const SectionRef Section) { const ObjectFile *Obj = Section.getObject(); - if (auto *ELFObj = dyn_cast<object::ELFObjectFileBase>(Obj)) - return !(ELFObj->getSectionFlags(Section) & + if (isa<object::ELFObjectFileBase>(Obj)) + return !(ELFSectionRef(Section).getFlags() & (ELF::SHF_WRITE | ELF::SHF_EXECINSTR)); if (auto *COFFObj = dyn_cast<object::COFFObjectFile>(Obj)) return ((COFFObj->getCOFFSection(Section)->Characteristics & |