[llvm] [BOLT][AArch64] Fix LDR relocation type in ADRP+LDR sequence (PR #166391)
YongKang Zhu via llvm-commits
llvm-commits at lists.llvm.org
Tue Nov 4 07:53:19 PST 2025
https://github.com/yozhu created https://github.com/llvm/llvm-project/pull/166391
`R_AARCH64_ADD_ABS_LO12_NC` is for the `ADD` instruction in the `ADRP+ADD` sequence. For `ADRP+LDR` sequence generated in LDR relaxation, relocation type for `LDR` should be `R_AARCH64_LDST64_ABS_LO12_NC` if it is 64-bit integer load or `R_AARCH64_LDST32_ABS_LO12_NC` if 32-bit.
Sorry should have included this in #165787.
>From ec7bcbc6bbb237671f0ab721e88b88dcbed6fcc4 Mon Sep 17 00:00:00 2001
From: YongKang Zhu <yongzhu at fb.com>
Date: Tue, 30 Sep 2025 11:01:38 -0700
Subject: [PATCH] [BOLT][AArch64] Fix LDR relocation type in ADRP+LDR sequence
`R_AARCH64_ADD_ABS_LO12_NC` is for the `ADD` instruction in the `ADRP+ADD`
sequence. For `ADRP+LDR` sequence generated in LDR relaxation, relocation
type for `LDR` should be `R_AARCH64_LDST64_ABS_LO12_NC` if it is 64-bit
integer load or `R_AARCH64_LDST32_ABS_LO12_NC` if 32-bit.
---
bolt/lib/Target/AArch64/AArch64MCPlusBuilder.cpp | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/bolt/lib/Target/AArch64/AArch64MCPlusBuilder.cpp b/bolt/lib/Target/AArch64/AArch64MCPlusBuilder.cpp
index 8a496c566b06b..43c9d9d3f14bd 100644
--- a/bolt/lib/Target/AArch64/AArch64MCPlusBuilder.cpp
+++ b/bolt/lib/Target/AArch64/AArch64MCPlusBuilder.cpp
@@ -640,7 +640,8 @@ class AArch64MCPlusBuilder : public MCPlusBuilder {
Insts[1].addOperand(MCOperand::createImm(0));
Insts[1].addOperand(MCOperand::createImm(0));
setOperandToSymbolRef(Insts[1], /* OpNum */ 2, Target, 0, Ctx,
- ELF::R_AARCH64_ADD_ABS_LO12_NC);
+ isLDRXl(LDRInst) ? ELF::R_AARCH64_LDST64_ABS_LO12_NC
+ : ELF::R_AARCH64_LDST32_ABS_LO12_NC);
return Insts;
}
More information about the llvm-commits
mailing list