ADDI = 14
};
+constexpr uint32_t NOP = 0x60000000;
+
enum class PPCLegacyInsn : uint32_t {
NOINSN = 0,
// Loads.
writePrefixedInstruction(loc, pcRelInsn |
((totalDisp & 0x3ffff0000) << 16) |
(totalDisp & 0xffff));
- write32(loc + rel.addend, 0x60000000); // nop accessInsn.
+ write32(loc + rel.addend, NOP); // nop accessInsn.
break;
}
default:
switch (rel.type) {
case R_PPC64_GOT_TLSGD16_HA:
- writeFromHalf16(loc, 0x60000000); // nop
+ writeFromHalf16(loc, NOP);
break;
case R_PPC64_GOT_TLSGD16:
case R_PPC64_GOT_TLSGD16_LO:
relocateNoSym(loc, R_PPC64_TPREL16_HA, val);
break;
case R_PPC64_TLSGD:
- write32(loc, 0x60000000); // nop
+ write32(loc, NOP);
write32(loc + 4, 0x38630000); // addi r3, r3
// Since we are relocating a half16 type relocation and Loc + 4 points to
// the start of an instruction we need to advance the buffer by an extra
switch (rel.type) {
case R_PPC64_GOT_TLSLD16_HA:
- writeFromHalf16(loc, 0x60000000); // nop
+ writeFromHalf16(loc, NOP);
break;
case R_PPC64_GOT_TLSLD16_LO:
writeFromHalf16(loc, 0x3c6d0000); // addis r3, r13, 0
break;
case R_PPC64_TLSLD:
- write32(loc, 0x60000000); // nop
+ write32(loc, NOP);
write32(loc + 4, 0x38631000); // addi r3, r3, 4096
break;
case R_PPC64_DTPREL16:
unsigned offset = (config->ekind == ELF64BEKind) ? 2 : 0;
switch (rel.type) {
case R_PPC64_GOT_TPREL16_HA:
- write32(loc - offset, 0x60000000); // nop
+ write32(loc - offset, NOP);
break;
case R_PPC64_GOT_TPREL16_LO_DS:
case R_PPC64_GOT_TPREL16_DS: {
case R_PPC64_REL16_HA:
case R_PPC64_TPREL16_HA:
if (config->tocOptimize && shouldTocOptimize && ha(val) == 0)
- writeFromHalf16(loc, 0x60000000);
+ writeFromHalf16(loc, NOP);
else
write16(loc, ha(val));
break;
return;
}
case R_PPC64_TLSGD:
- write32(loc, 0x60000000); // bl __tls_get_addr(sym@tlsgd) --> nop
+ write32(loc, NOP); // bl __tls_get_addr(sym@tlsgd) --> nop
write32(loc + 4, 0x7c636A14); // nop --> add r3, r3, r13
return;
default:
uint32_t secondInstr = read32(loc + 8);
if (!loImm && getPrimaryOpCode(secondInstr) == 14) {
loImm = secondInstr & 0xFFFF;
- } else if (secondInstr != 0x60000000) {
+ } else if (secondInstr != NOP) {
return false;
}
};
if (!checkRegOperands(firstInstr, 12, 1))
return false;
- if (secondInstr != 0x60000000 && !checkRegOperands(secondInstr, 12, 12))
+ if (secondInstr != NOP && !checkRegOperands(secondInstr, 12, 12))
return false;
int32_t stackFrameSize = (hiImm * 65536) + loImm;
if (hiImm) {
write32(loc + 4, 0x3D810000 | (uint16_t)hiImm);
// If the low immediate is zero the second instruction will be a nop.
- secondInstr = loImm ? 0x398C0000 | (uint16_t)loImm : 0x60000000;
+ secondInstr = loImm ? 0x398C0000 | (uint16_t)loImm : NOP;
write32(loc + 8, secondInstr);
} else {
// addi r12, r1, imm
write32(loc + 4, (0x39810000) | (uint16_t)loImm);
- write32(loc + 8, 0x60000000);
+ write32(loc + 8, NOP);
}
return true;