Skip to content

Commit 6e26ffa

Browse files
committed
[BOLT][AARCH64] Skip R_AARCH64_LD_PREL_LO19 relocation
Supress failed to analyze relocations warning for R_AARCH64_LD_PREL_LO19 relocation. This relocation is mostly used to get value stored in CI and we don't process it since we are caluclating target address using the instruction value in evaluateMemOperandTarget(). Differential Revision: https://reviews.llvm.org/D127413
1 parent 93b4a41 commit 6e26ffa

File tree

3 files changed

+17
-2
lines changed

3 files changed

+17
-2
lines changed

bolt/include/bolt/Core/Relocation.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,10 @@ struct Relocation {
5555
/// Return size of this relocation.
5656
size_t getSize() const { return getSizeForType(Type); }
5757

58-
/// Handle special cases when relocation should not be processed by bolt
58+
/// Skip relocations that we don't want to handle in BOLT
59+
static bool skipRelocationType(uint64_t Type);
60+
61+
/// Handle special cases when relocation should not be processed by BOLT
5962
static bool skipRelocationProcess(uint64_t Type, uint64_t Contents);
6063

6164
// Adjust value depending on relocation type (make it PC relative or not)

bolt/lib/Core/Relocation.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,12 @@ size_t getSizeForTypeAArch64(uint64_t Type) {
165165
}
166166
}
167167

168+
bool skipRelocationTypeX86(uint64_t Type) { return Type == ELF::R_X86_64_NONE; }
169+
170+
bool skipRelocationTypeAArch64(uint64_t Type) {
171+
return Type == ELF::R_AARCH64_NONE || Type == ELF::R_AARCH64_LD_PREL_LO19;
172+
}
173+
168174
bool skipRelocationProcessX86(uint64_t Type, uint64_t Contents) {
169175
return false;
170176
}
@@ -536,6 +542,12 @@ size_t Relocation::getSizeForType(uint64_t Type) {
536542
return getSizeForTypeX86(Type);
537543
}
538544

545+
bool Relocation::skipRelocationType(uint64_t Type) {
546+
if (Arch == Triple::aarch64)
547+
return skipRelocationTypeAArch64(Type);
548+
return skipRelocationTypeX86(Type);
549+
}
550+
539551
bool Relocation::skipRelocationProcess(uint64_t Type, uint64_t Contents) {
540552
if (Arch == Triple::aarch64)
541553
return skipRelocationProcessAArch64(Type, Contents);

bolt/lib/Rewrite/RewriteInstance.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2332,7 +2332,7 @@ void RewriteInstance::readRelocations(const SectionRef &Section) {
23322332
SmallString<16> TypeName;
23332333
Rel.getTypeName(TypeName);
23342334
uint64_t RType = Rel.getType();
2335-
if (Relocation::isNone(RType))
2335+
if (Relocation::skipRelocationType(RType))
23362336
continue;
23372337

23382338
// Adjust the relocation type as the linker might have skewed it.

0 commit comments

Comments
 (0)