diff options
author | Vladislav Khmelevsky <och95@yandex.ru> | 2023-03-15 00:08:11 +0400 |
---|---|---|
committer | Vladislav Khmelevsky <och95@yandex.ru> | 2023-03-17 17:24:19 +0400 |
commit | f9bf9f925e3761df3bf6222c4e70f4cc74e8c9c7 (patch) | |
tree | d46974f3e88e0160d53e67cf3c138d2c43af53ba /bolt/include | |
parent | 62f09d788f9fc540db12f3cfa2f98760071fca96 (diff) | |
download | llvm-f9bf9f925e3761df3bf6222c4e70f4cc74e8c9c7.tar.gz |
[BOLT] Add .relr.dyn section support
Vladislav Khmelevsky,
Advanced Software Technology Lab, Huawei
Differential Revision: https://reviews.llvm.org/D146085
Diffstat (limited to 'bolt/include')
-rw-r--r-- | bolt/include/bolt/Core/BinarySection.h | 1 | ||||
-rw-r--r-- | bolt/include/bolt/Core/Relocation.h | 3 | ||||
-rw-r--r-- | bolt/include/bolt/Rewrite/RewriteInstance.h | 11 |
3 files changed, 15 insertions, 0 deletions
diff --git a/bolt/include/bolt/Core/BinarySection.h b/bolt/include/bolt/Core/BinarySection.h index 20b4b5c92576..d3c3ba485c75 100644 --- a/bolt/include/bolt/Core/BinarySection.h +++ b/bolt/include/bolt/Core/BinarySection.h @@ -275,6 +275,7 @@ public: bool isTBSS() const { return isBSS() && isTLS(); } bool isVirtual() const { return ELFType == ELF::SHT_NOBITS; } bool isRela() const { return ELFType == ELF::SHT_RELA; } + bool isRelr() const { return ELFType == ELF::SHT_RELR; } bool isWritable() const { return (ELFFlags & ELF::SHF_WRITE); } bool isAllocatable() const { if (isELF()) { diff --git a/bolt/include/bolt/Core/Relocation.h b/bolt/include/bolt/Core/Relocation.h index ed56d41beb05..51dd76938756 100644 --- a/bolt/include/bolt/Core/Relocation.h +++ b/bolt/include/bolt/Core/Relocation.h @@ -109,6 +109,9 @@ struct Relocation { /// Return code for a ABS 8-byte relocation static uint64_t getAbs64(); + /// Return code for a RELATIVE relocation + static uint64_t getRelative(); + /// Return true if this relocation is PC-relative. Return false otherwise. bool isPCRelative() const { return isPCRelative(Type); } diff --git a/bolt/include/bolt/Rewrite/RewriteInstance.h b/bolt/include/bolt/Rewrite/RewriteInstance.h index 54837aaccee3..7e4f7c3e2187 100644 --- a/bolt/include/bolt/Rewrite/RewriteInstance.h +++ b/bolt/include/bolt/Rewrite/RewriteInstance.h @@ -138,6 +138,9 @@ private: /// Read relocations from a given section. void readDynamicRelocations(const object::SectionRef &Section, bool IsJmpRel); + /// Read relocations from a given RELR section. + void readDynamicRelrRelocations(BinarySection &Section); + /// Print relocation information. void printRelocationInfo(const RelocationRef &Rel, StringRef SymbolName, uint64_t SymbolAddress, uint64_t Addend, @@ -312,6 +315,9 @@ private: /// Patch allocatable relocation sections. ELF_FUNCTION(void, patchELFAllocatableRelaSections); + /// Patch allocatable relr section. + ELF_FUNCTION(void, patchELFAllocatableRelrSection); + /// Finalize memory image of section header string table. ELF_FUNCTION(void, finalizeSectionStringTable); @@ -486,6 +492,11 @@ private: uint64_t DynamicRelocationsSize{0}; uint64_t DynamicRelativeRelocationsCount{0}; + // Location and size of .relr.dyn relocations. + std::optional<uint64_t> DynamicRelrAddress; + uint64_t DynamicRelrSize{0}; + uint64_t DynamicRelrEntrySize{0}; + /// PLT relocations are special kind of dynamic relocations stored separately. std::optional<uint64_t> PLTRelocationsAddress; uint64_t PLTRelocationsSize{0}; |