From 9dc5b3e6c423733d5d7d553521b48ea30518f37c Mon Sep 17 00:00:00 2001 From: Anshuman Dasgupta Date: Tue, 24 Jul 2012 19:48:24 +0000 Subject: Add new interfaces to support ldd's ReaderElf.cpp. Patch by Sid Manning! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@160685 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Object/ELF.h | 45 ++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 42 insertions(+), 3 deletions(-) (limited to 'include/llvm/Object/ELF.h') diff --git a/include/llvm/Object/ELF.h b/include/llvm/Object/ELF.h index cafcb5e..1b536f1 100644 --- a/include/llvm/Object/ELF.h +++ b/include/llvm/Object/ELF.h @@ -505,9 +505,6 @@ private: const Elf_Rela *getRela(DataRefImpl Rela) const; const char *getString(uint32_t section, uint32_t offset) const; const char *getString(const Elf_Shdr *section, uint32_t offset) const; - error_code getSymbolName(const Elf_Shdr *section, - const Elf_Sym *Symb, - StringRef &Res) const; error_code getSymbolVersion(const Elf_Shdr *section, const Elf_Sym *Symb, StringRef &Version, @@ -519,6 +516,11 @@ protected: void validateSymbol(DataRefImpl Symb) const; public: + error_code getSymbolName(const Elf_Shdr *section, + const Elf_Sym *Symb, + StringRef &Res) const; + error_code getSectionName(const Elf_Shdr *section, + StringRef &Res) const; const Elf_Dyn *getDyn(DataRefImpl DynData) const; error_code getSymbolVersion(SymbolRef Symb, StringRef &Version, bool &IsDefault) const; @@ -597,11 +599,15 @@ public: virtual StringRef getObjectType() const { return "ELF"; } virtual unsigned getArch() const; virtual StringRef getLoadName() const; + virtual error_code getSectionContents(const Elf_Shdr *sec, + StringRef &Res) const; uint64_t getNumSections() const; uint64_t getStringTableIndex() const; ELF::Elf64_Word getSymbolTableIndex(const Elf_Sym *symb) const; const Elf_Shdr *getSection(const Elf_Sym *symb) const; + const Elf_Shdr *getElfSection(section_iterator &It) const; + const Elf_Sym *getElfSymbol(symbol_iterator &It) const; // Methods for type inquiry through isa, cast, and dyn_cast bool isDyldType() const { return isDyldELFObject; } @@ -783,6 +789,22 @@ ELFObjectFile } template +const typename ELFObjectFile::Elf_Shdr * +ELFObjectFile + ::getElfSection(section_iterator &It) const { + llvm::object::DataRefImpl ShdrRef = It->getRawDataRefImpl(); + return const_cast(reinterpret_cast + (ShdrRef.p)); +} + +template +const typename ELFObjectFile::Elf_Sym * +ELFObjectFile + ::getElfSymbol(symbol_iterator &It) const { + return getSymbol(It->getRawDataRefImpl()); +} + +template error_code ELFObjectFile ::getSymbolFileOffset(DataRefImpl Symb, uint64_t &Result) const { @@ -1060,6 +1082,15 @@ error_code ELFObjectFile template error_code ELFObjectFile + ::getSectionContents(const Elf_Shdr *Sec, + StringRef &Result) const { + const char *start = (const char*)base() + Sec->sh_offset; + Result = StringRef(start, Sec->sh_size); + return object_error::success; +} + +template +error_code ELFObjectFile ::getSectionAlignment(DataRefImpl Sec, uint64_t &Result) const { const Elf_Shdr *sec = reinterpret_cast(Sec.p); @@ -2153,6 +2184,14 @@ error_code ELFObjectFile template error_code ELFObjectFile + ::getSectionName(const Elf_Shdr *section, + StringRef &Result) const { + Result = StringRef(getString(dot_shstrtab_sec, section->sh_name)); + return object_error::success; +} + +template +error_code ELFObjectFile ::getSymbolVersion(const Elf_Shdr *section, const Elf_Sym *symb, StringRef &Version, -- cgit v1.1 From 9669f749764997ab7033d5c4b0546fe739dd71d8 Mon Sep 17 00:00:00 2001 From: "Michael J. Spencer" Date: Tue, 24 Jul 2012 21:07:56 +0000 Subject: [Object] Remove unneeded const_cast. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@160692 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Object/ELF.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'include/llvm/Object/ELF.h') diff --git a/include/llvm/Object/ELF.h b/include/llvm/Object/ELF.h index 1b536f1..7698441 100644 --- a/include/llvm/Object/ELF.h +++ b/include/llvm/Object/ELF.h @@ -793,8 +793,7 @@ const typename ELFObjectFile::Elf_Shdr * ELFObjectFile ::getElfSection(section_iterator &It) const { llvm::object::DataRefImpl ShdrRef = It->getRawDataRefImpl(); - return const_cast(reinterpret_cast - (ShdrRef.p)); + return reinterpret_cast(ShdrRef.p); } template -- cgit v1.1 From 745d94d29fec3df001a08062644e68052ac14618 Mon Sep 17 00:00:00 2001 From: Roman Divacky Date: Thu, 16 Aug 2012 18:30:03 +0000 Subject: Handle PowerPC. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@162034 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Object/ELF.h | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'include/llvm/Object/ELF.h') diff --git a/include/llvm/Object/ELF.h b/include/llvm/Object/ELF.h index 7698441..40c6cb1 100644 --- a/include/llvm/Object/ELF.h +++ b/include/llvm/Object/ELF.h @@ -2015,6 +2015,8 @@ StringRef ELFObjectFile return "ELF32-arm"; case ELF::EM_HEXAGON: return "ELF32-hexagon"; + case ELF::EM_PPC: + return "ELF32-ppc"; default: return "ELF32-unknown"; } @@ -2024,6 +2026,8 @@ StringRef ELFObjectFile return "ELF64-i386"; case ELF::EM_X86_64: return "ELF64-x86-64"; + case ELF::EM_PPC64: + return "ELF64-ppc64"; default: return "ELF64-unknown"; } @@ -2044,6 +2048,10 @@ unsigned ELFObjectFile::getArch() const { return Triple::arm; case ELF::EM_HEXAGON: return Triple::hexagon; + case ELF::EM_PPC: + return Triple::ppc; + case ELF::EM_PPC64: + return Triple::ppc64; default: return Triple::UnknownArch; } -- cgit v1.1 From 05b2bc8781d9af403a257599613e12cb8fef19e8 Mon Sep 17 00:00:00 2001 From: Roman Divacky Date: Thu, 16 Aug 2012 19:07:59 +0000 Subject: Revert r162034, r162035 and r162037. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@162039 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Object/ELF.h | 8 -------- 1 file changed, 8 deletions(-) (limited to 'include/llvm/Object/ELF.h') diff --git a/include/llvm/Object/ELF.h b/include/llvm/Object/ELF.h index 40c6cb1..7698441 100644 --- a/include/llvm/Object/ELF.h +++ b/include/llvm/Object/ELF.h @@ -2015,8 +2015,6 @@ StringRef ELFObjectFile return "ELF32-arm"; case ELF::EM_HEXAGON: return "ELF32-hexagon"; - case ELF::EM_PPC: - return "ELF32-ppc"; default: return "ELF32-unknown"; } @@ -2026,8 +2024,6 @@ StringRef ELFObjectFile return "ELF64-i386"; case ELF::EM_X86_64: return "ELF64-x86-64"; - case ELF::EM_PPC64: - return "ELF64-ppc64"; default: return "ELF64-unknown"; } @@ -2048,10 +2044,6 @@ unsigned ELFObjectFile::getArch() const { return Triple::arm; case ELF::EM_HEXAGON: return Triple::hexagon; - case ELF::EM_PPC: - return Triple::ppc; - case ELF::EM_PPC64: - return Triple::ppc64; default: return Triple::UnknownArch; } -- cgit v1.1 From b889e0cd2fea4afee623d5be603b912b955a2eca Mon Sep 17 00:00:00 2001 From: Akira Hatanaka Date: Fri, 17 Aug 2012 21:28:04 +0000 Subject: Correct MCJIT functionality for MIPS32 architecture. No new tests are added. All tests in ExecutionEngine/MCJIT that have been failing pass after this patch is applied (when "make check" is done on a mips board). Patch by Petar Jovanovic. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@162135 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Object/ELF.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'include/llvm/Object/ELF.h') diff --git a/include/llvm/Object/ELF.h b/include/llvm/Object/ELF.h index 7698441..5b95557 100644 --- a/include/llvm/Object/ELF.h +++ b/include/llvm/Object/ELF.h @@ -2044,6 +2044,9 @@ unsigned ELFObjectFile::getArch() const { return Triple::arm; case ELF::EM_HEXAGON: return Triple::hexagon; + case ELF::EM_MIPS: + return (target_endianness == support::little) ? + Triple::mipsel : Triple::mips; default: return Triple::UnknownArch; } -- cgit v1.1