diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/llvm/Object/COFF.h | 1 | ||||
-rw-r--r-- | include/llvm/Object/ELF.h | 33 | ||||
-rw-r--r-- | include/llvm/Object/MachO.h | 1 | ||||
-rw-r--r-- | include/llvm/Object/ObjectFile.h | 5 |
4 files changed, 39 insertions, 1 deletions
diff --git a/include/llvm/Object/COFF.h b/include/llvm/Object/COFF.h index 6212785..4f90187 100644 --- a/include/llvm/Object/COFF.h +++ b/include/llvm/Object/COFF.h @@ -164,6 +164,7 @@ public: virtual uint8_t getBytesInAddress() const; virtual StringRef getFileFormatName() const; virtual unsigned getArch() const; + virtual StringRef getLoadName() const; error_code getHeader(const coff_file_header *&Res) const; error_code getSection(int32_t index, const coff_section *&Res) const; diff --git a/include/llvm/Object/ELF.h b/include/llvm/Object/ELF.h index ce002f2..e746b0a 100644 --- a/include/llvm/Object/ELF.h +++ b/include/llvm/Object/ELF.h @@ -369,6 +369,9 @@ private: DenseMap<const Elf_Sym*, ELF::Elf64_Word> ExtendedSymbolTable; const Elf_Shdr *dot_dynamic_sec; // .dynamic + // Pointer to SONAME entry in dynamic string table + // This is set the first time getLoadName is called. + mutable const char *dt_soname; /// @brief Map sections to an array of relocation sections that reference /// them sorted by section index. @@ -471,6 +474,7 @@ public: virtual uint8_t getBytesInAddress() const; virtual StringRef getFileFormatName() const; virtual unsigned getArch() const; + virtual StringRef getLoadName() const; uint64_t getNumSections() const; uint64_t getStringTableIndex() const; @@ -1259,7 +1263,8 @@ ELFObjectFile<target_endianness, is64Bits>::ELFObjectFile(MemoryBuffer *Object , dot_shstrtab_sec(0) , dot_strtab_sec(0) , dot_dynstr_sec(0) - , dot_dynamic_sec(0) { + , dot_dynamic_sec(0) + , dt_soname(0) { const uint64_t FileSize = Data->getBufferSize(); @@ -1486,6 +1491,32 @@ error_code ELFObjectFile<target_endianness, is64Bits> } template<support::endianness target_endianness, bool is64Bits> +StringRef +ELFObjectFile<target_endianness, is64Bits>::getLoadName() const { + if (!dt_soname) { + // Find the DT_SONAME entry + dyn_iterator it = begin_dynamic_table(); + dyn_iterator ie = end_dynamic_table(); + error_code ec; + while (it != ie) { + if (it->getTag() == ELF::DT_SONAME) + break; + it.increment(ec); + if (ec) + report_fatal_error("dynamic table iteration failed"); + } + if (it != ie) { + if (dot_dynstr_sec == NULL) + report_fatal_error("Dynamic string table is missing"); + dt_soname = getString(dot_dynstr_sec, it->getVal()); + } else { + dt_soname = ""; + } + } + return dt_soname; +} + +template<support::endianness target_endianness, bool is64Bits> library_iterator ELFObjectFile<target_endianness, is64Bits> ::begin_libraries_needed() const { // Find the first DT_NEEDED entry diff --git a/include/llvm/Object/MachO.h b/include/llvm/Object/MachO.h index 185df06..1aae85a 100644 --- a/include/llvm/Object/MachO.h +++ b/include/llvm/Object/MachO.h @@ -42,6 +42,7 @@ public: virtual uint8_t getBytesInAddress() const; virtual StringRef getFileFormatName() const; virtual unsigned getArch() const; + virtual StringRef getLoadName() const; MachOObject *getObject() { return MachOObj; } diff --git a/include/llvm/Object/ObjectFile.h b/include/llvm/Object/ObjectFile.h index dd47ceb..1e9d895 100644 --- a/include/llvm/Object/ObjectFile.h +++ b/include/llvm/Object/ObjectFile.h @@ -359,6 +359,11 @@ public: virtual StringRef getFileFormatName() const = 0; virtual /* Triple::ArchType */ unsigned getArch() const = 0; + /// For shared objects, returns the name which this object should be + /// loaded from at runtime. This corresponds to DT_SONAME on ELF and + /// LC_ID_DYLIB (install name) on MachO. + virtual StringRef getLoadName() const = 0; + /// @returns Pointer to ObjectFile subclass to handle this type of object. /// @param ObjectPath The path to the object file. ObjectPath.isObject must /// return true. |