summaryrefslogtreecommitdiff
path: root/bolt
diff options
context:
space:
mode:
authorVladislav Khmelevsky <och95@yandex.ru>2023-02-15 17:18:37 +0400
committerVladislav Khmelevsky <och95@yandex.ru>2023-02-22 16:58:43 +0400
commitb0d1f87b5943b695be44e7ae186a28e263143a6b (patch)
tree0399f8568133f5a7ff5d26f4007b9b9aa7c7bba6 /bolt
parent7aec47acc3474ed12b2d44250419aad8d516cd69 (diff)
downloadllvm-b0d1f87b5943b695be44e7ae186a28e263143a6b.tar.gz
[BOLT] Fix data reoder for aarch64
Use proper relocation for aarch64 Differential Revision: https://reviews.llvm.org/D144095
Diffstat (limited to 'bolt')
-rw-r--r--bolt/include/bolt/Core/Relocation.h3
-rw-r--r--bolt/lib/Core/BinarySection.cpp2
-rw-r--r--bolt/lib/Core/Relocation.cpp6
3 files changed, 10 insertions, 1 deletions
diff --git a/bolt/include/bolt/Core/Relocation.h b/bolt/include/bolt/Core/Relocation.h
index c6efe4600ae9..ed56d41beb05 100644
--- a/bolt/include/bolt/Core/Relocation.h
+++ b/bolt/include/bolt/Core/Relocation.h
@@ -106,6 +106,9 @@ struct Relocation {
/// Return code for a PC-relative 8-byte relocation
static uint64_t getPC64();
+ /// Return code for a ABS 8-byte relocation
+ static uint64_t getAbs64();
+
/// Return true if this relocation is PC-relative. Return false otherwise.
bool isPCRelative() const { return isPCRelative(Type); }
diff --git a/bolt/lib/Core/BinarySection.cpp b/bolt/lib/Core/BinarySection.cpp
index fefa83e47cc1..1e28da4cb2f7 100644
--- a/bolt/lib/Core/BinarySection.cpp
+++ b/bolt/lib/Core/BinarySection.cpp
@@ -252,7 +252,7 @@ void BinarySection::reorderContents(const std::vector<BinaryData *> &Order,
// of the reordered segment to force LLVM to recognize and map this
// section.
MCSymbol *ZeroSym = BC.registerNameAtAddress("Zero", 0, 0, 0);
- addRelocation(OS.tell(), ZeroSym, ELF::R_X86_64_64, 0xdeadbeef);
+ addRelocation(OS.tell(), ZeroSym, Relocation::getAbs64(), 0xdeadbeef);
uint64_t Zero = 0;
OS.write(reinterpret_cast<const char *>(&Zero), sizeof(Zero));
diff --git a/bolt/lib/Core/Relocation.cpp b/bolt/lib/Core/Relocation.cpp
index e8a889f48683..eceecf3ef03c 100644
--- a/bolt/lib/Core/Relocation.cpp
+++ b/bolt/lib/Core/Relocation.cpp
@@ -636,6 +636,12 @@ bool Relocation::isPCRelative(uint64_t Type) {
return isPCRelativeX86(Type);
}
+uint64_t Relocation::getAbs64() {
+ if (Arch == Triple::aarch64)
+ return ELF::R_AARCH64_ABS64;
+ return ELF::R_X86_64_64;
+}
+
size_t Relocation::emit(MCStreamer *Streamer) const {
const size_t Size = getSizeForType(Type);
MCContext &Ctx = Streamer->getContext();