Skip to content

Commit b0ae054

Browse files
authored
[BOLT][AArch64] Fix LDR relocation type in ADRP+LDR sequence (#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.
1 parent 0469ff0 commit b0ae054

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

bolt/lib/Target/AArch64/AArch64MCPlusBuilder.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -640,7 +640,8 @@ class AArch64MCPlusBuilder : public MCPlusBuilder {
640640
Insts[1].addOperand(MCOperand::createImm(0));
641641
Insts[1].addOperand(MCOperand::createImm(0));
642642
setOperandToSymbolRef(Insts[1], /* OpNum */ 2, Target, 0, Ctx,
643-
ELF::R_AARCH64_ADD_ABS_LO12_NC);
643+
isLDRXl(LDRInst) ? ELF::R_AARCH64_LDST64_ABS_LO12_NC
644+
: ELF::R_AARCH64_LDST32_ABS_LO12_NC);
644645
return Insts;
645646
}
646647

0 commit comments

Comments
 (0)