summaryrefslogtreecommitdiffstats
path: root/llvm/tools/llvm-objcopy/Object.h
diff options
context:
space:
mode:
authorJake Ehrlich <jakehehrlich@google.com>2017-09-19 19:21:09 +0000
committerJake Ehrlich <jakehehrlich@google.com>2017-09-19 19:21:09 +0000
commitf20c3f4333ae5a26650f9b1e819a485888caf7fb (patch)
treecabbc37cf85d83a2cf8229b9ddbab0e5850c21a3 /llvm/tools/llvm-objcopy/Object.h
parent610e03a0098c2712be6e78731045e01353d679eb (diff)
downloadbcm5719-llvm-f20c3f4333ae5a26650f9b1e819a485888caf7fb.tar.gz
bcm5719-llvm-f20c3f4333ae5a26650f9b1e819a485888caf7fb.zip
[llvm-objcopy] Add support for .dynamic, .dynsym, and .dynstr
This change adds support for sections involved in dynamic loading such as SHT_DYNAMIC, SHT_DYNSYM, and allocated string tables. The two added binaries used for tests can be downloaded [[ https://drive.google.com/file/d/0B3gtIAmiMwZXOXE3T0RobFg4ZTg/view?usp=sharing | here ]] and [[ https://drive.google.com/file/d/0B3gtIAmiMwZXTFJSQUJZMGxNSXc/view?usp=sharing | here ]] Differential Revision: https://reviews.llvm.org/D36560 llvm-svn: 313663
Diffstat (limited to 'llvm/tools/llvm-objcopy/Object.h')
-rw-r--r--llvm/tools/llvm-objcopy/Object.h34
1 files changed, 34 insertions, 0 deletions
diff --git a/llvm/tools/llvm-objcopy/Object.h b/llvm/tools/llvm-objcopy/Object.h
index 1b7127e86da..7a6f0132a0e 100644
--- a/llvm/tools/llvm-objcopy/Object.h
+++ b/llvm/tools/llvm-objcopy/Object.h
@@ -194,6 +194,34 @@ public:
}
};
+class SectionWithStrTab : public Section {
+private:
+ StringTableSection *StrTab;
+
+public:
+ SectionWithStrTab(llvm::ArrayRef<uint8_t> Data) : Section(Data) {}
+ void setStrTab(StringTableSection *StringTable) { StrTab = StringTable; }
+ void finalize() override;
+ static bool classof(const SectionBase *S);
+};
+
+class DynamicSymbolTableSection : public SectionWithStrTab {
+public:
+ DynamicSymbolTableSection(llvm::ArrayRef<uint8_t> Data)
+ : SectionWithStrTab(Data) {}
+ static bool classof(const SectionBase *S) {
+ return S->Type == llvm::ELF::SHT_DYNSYM;
+ }
+};
+
+class DynamicSection : public SectionWithStrTab {
+public:
+ DynamicSection(llvm::ArrayRef<uint8_t> Data) : SectionWithStrTab(Data) {}
+ static bool classof(const SectionBase *S) {
+ return S->Type == llvm::ELF::SHT_DYNAMIC;
+ }
+};
+
template <class ELFT> class Object {
private:
typedef std::unique_ptr<SectionBase> SecPtr;
@@ -210,6 +238,12 @@ private:
void readProgramHeaders(const llvm::object::ELFFile<ELFT> &ElfFile);
void readSectionHeaders(const llvm::object::ELFFile<ELFT> &ElfFile);
+ SectionBase *getSection(uint16_t Index, llvm::Twine ErrMsg);
+
+ template <class T>
+ T *getSectionOfType(uint16_t Index, llvm::Twine IndexErrMsg,
+ llvm::Twine TypeErrMsg);
+
protected:
StringTableSection *SectionNames;
SymbolTableSection *SymbolTable;
OpenPOWER on IntegriCloud