summaryrefslogtreecommitdiff
path: root/bolt
diff options
context:
space:
mode:
authorRafael Auler <rafaelauler@fb.com>2023-05-10 17:56:43 -0700
committerRafael Auler <rafaelauler@fb.com>2023-05-11 11:52:32 -0700
commit77811752e3c7e3b354a235bd21d9aa076da9825a (patch)
treeef56eba0f1542b66e120d277a77b6c1d256b3c67 /bolt
parent733b8b2b4919e76e1768919461fd5eb211e41d79 (diff)
downloadllvm-77811752e3c7e3b354a235bd21d9aa076da9825a.tar.gz
[BOLT] Fix flush pending relocs
https://github.com/facebookincubator/BOLT/pull/255 accidentally omitted a relocation type when refactoring the code. Add this type back and change function name so its intent is more clear. Reviewed By: #bolt, Amir Differential Revision: https://reviews.llvm.org/D150335
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.cpp16
3 files changed, 10 insertions, 11 deletions
diff --git a/bolt/include/bolt/Core/Relocation.h b/bolt/include/bolt/Core/Relocation.h
index 51dd76938756..1296c001db57 100644
--- a/bolt/include/bolt/Core/Relocation.h
+++ b/bolt/include/bolt/Core/Relocation.h
@@ -64,8 +64,7 @@ struct Relocation {
static bool skipRelocationProcess(uint64_t &Type, uint64_t Contents);
// Adjust value depending on relocation type (make it PC relative or not)
- static uint64_t adjustValue(uint64_t Type, uint64_t Value,
- uint64_t PC);
+ static uint64_t encodeValue(uint64_t Type, uint64_t Value, uint64_t PC);
/// Extract current relocated value from binary contents. This is used for
/// RISC architectures where values are encoded in specific bits depending
diff --git a/bolt/lib/Core/BinarySection.cpp b/bolt/lib/Core/BinarySection.cpp
index 846515c3ed13..e0e7b15d04a5 100644
--- a/bolt/lib/Core/BinarySection.cpp
+++ b/bolt/lib/Core/BinarySection.cpp
@@ -146,7 +146,7 @@ void BinarySection::flushPendingRelocations(raw_pwrite_stream &OS,
if (Reloc.Symbol)
Value += Resolver(Reloc.Symbol);
- Value = Relocation::adjustValue(Reloc.Type, Value,
+ Value = Relocation::encodeValue(Reloc.Type, Value,
SectionAddress + Reloc.Offset);
OS.pwrite(reinterpret_cast<const char *>(&Value),
diff --git a/bolt/lib/Core/Relocation.cpp b/bolt/lib/Core/Relocation.cpp
index b36e321f4e34..d3e7fccc2310 100644
--- a/bolt/lib/Core/Relocation.cpp
+++ b/bolt/lib/Core/Relocation.cpp
@@ -262,10 +262,11 @@ static bool skipRelocationProcessAArch64(uint64_t &Type, uint64_t Contents) {
return false;
}
-static uint64_t adjustValueX86(uint64_t Type, uint64_t Value, uint64_t PC) {
+static uint64_t encodeValueX86(uint64_t Type, uint64_t Value, uint64_t PC) {
switch (Type) {
default:
- llvm_unreachable("not supported relocation");
+ llvm_unreachable("unsupported relocation");
+ case ELF::R_X86_64_64:
case ELF::R_X86_64_32:
break;
case ELF::R_X86_64_PC32:
@@ -275,10 +276,10 @@ static uint64_t adjustValueX86(uint64_t Type, uint64_t Value, uint64_t PC) {
return Value;
}
-static uint64_t adjustValueAArch64(uint64_t Type, uint64_t Value, uint64_t PC) {
+static uint64_t encodeValueAArch64(uint64_t Type, uint64_t Value, uint64_t PC) {
switch (Type) {
default:
- llvm_unreachable("not supported relocation");
+ llvm_unreachable("unsupported relocation");
case ELF::R_AARCH64_ABS32:
break;
case ELF::R_AARCH64_PREL16:
@@ -566,11 +567,10 @@ bool Relocation::skipRelocationProcess(uint64_t &Type, uint64_t Contents) {
return skipRelocationProcessX86(Type, Contents);
}
-uint64_t Relocation::adjustValue(uint64_t Type, uint64_t Value,
- uint64_t PC) {
+uint64_t Relocation::encodeValue(uint64_t Type, uint64_t Value, uint64_t PC) {
if (Arch == Triple::aarch64)
- return adjustValueAArch64(Type, Value, PC);
- return adjustValueX86(Type, Value, PC);
+ return encodeValueAArch64(Type, Value, PC);
+ return encodeValueX86(Type, Value, PC);
}
uint64_t Relocation::extractValue(uint64_t Type, uint64_t Contents,