Skip to content

Commit 7781175

Browse files
committed
[BOLT] Fix flush pending relocs
facebookarchive/BOLT#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
1 parent 733b8b2 commit 7781175

File tree

3 files changed

+10
-11
lines changed

3 files changed

+10
-11
lines changed

bolt/include/bolt/Core/Relocation.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,7 @@ struct Relocation {
6464
static bool skipRelocationProcess(uint64_t &Type, uint64_t Contents);
6565

6666
// Adjust value depending on relocation type (make it PC relative or not)
67-
static uint64_t adjustValue(uint64_t Type, uint64_t Value,
68-
uint64_t PC);
67+
static uint64_t encodeValue(uint64_t Type, uint64_t Value, uint64_t PC);
6968

7069
/// Extract current relocated value from binary contents. This is used for
7170
/// RISC architectures where values are encoded in specific bits depending

bolt/lib/Core/BinarySection.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ void BinarySection::flushPendingRelocations(raw_pwrite_stream &OS,
146146
if (Reloc.Symbol)
147147
Value += Resolver(Reloc.Symbol);
148148

149-
Value = Relocation::adjustValue(Reloc.Type, Value,
149+
Value = Relocation::encodeValue(Reloc.Type, Value,
150150
SectionAddress + Reloc.Offset);
151151

152152
OS.pwrite(reinterpret_cast<const char *>(&Value),

bolt/lib/Core/Relocation.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -262,10 +262,11 @@ static bool skipRelocationProcessAArch64(uint64_t &Type, uint64_t Contents) {
262262
return false;
263263
}
264264

265-
static uint64_t adjustValueX86(uint64_t Type, uint64_t Value, uint64_t PC) {
265+
static uint64_t encodeValueX86(uint64_t Type, uint64_t Value, uint64_t PC) {
266266
switch (Type) {
267267
default:
268-
llvm_unreachable("not supported relocation");
268+
llvm_unreachable("unsupported relocation");
269+
case ELF::R_X86_64_64:
269270
case ELF::R_X86_64_32:
270271
break;
271272
case ELF::R_X86_64_PC32:
@@ -275,10 +276,10 @@ static uint64_t adjustValueX86(uint64_t Type, uint64_t Value, uint64_t PC) {
275276
return Value;
276277
}
277278

278-
static uint64_t adjustValueAArch64(uint64_t Type, uint64_t Value, uint64_t PC) {
279+
static uint64_t encodeValueAArch64(uint64_t Type, uint64_t Value, uint64_t PC) {
279280
switch (Type) {
280281
default:
281-
llvm_unreachable("not supported relocation");
282+
llvm_unreachable("unsupported relocation");
282283
case ELF::R_AARCH64_ABS32:
283284
break;
284285
case ELF::R_AARCH64_PREL16:
@@ -566,11 +567,10 @@ bool Relocation::skipRelocationProcess(uint64_t &Type, uint64_t Contents) {
566567
return skipRelocationProcessX86(Type, Contents);
567568
}
568569

569-
uint64_t Relocation::adjustValue(uint64_t Type, uint64_t Value,
570-
uint64_t PC) {
570+
uint64_t Relocation::encodeValue(uint64_t Type, uint64_t Value, uint64_t PC) {
571571
if (Arch == Triple::aarch64)
572-
return adjustValueAArch64(Type, Value, PC);
573-
return adjustValueX86(Type, Value, PC);
572+
return encodeValueAArch64(Type, Value, PC);
573+
return encodeValueX86(Type, Value, PC);
574574
}
575575

576576
uint64_t Relocation::extractValue(uint64_t Type, uint64_t Contents,

0 commit comments

Comments
 (0)