diff --git a/lld/ELF/InputSection.cpp b/lld/ELF/InputSection.cpp index a8d3163cde64..a9185f8d8a98 100644 --- a/lld/ELF/InputSection.cpp +++ b/lld/ELF/InputSection.cpp @@ -1022,17 +1022,15 @@ void InputSectionBase::relocateAlloc(uint8_t *buf, uint8_t *bufEnd) { continue; uint64_t offset = rel.offset; uint8_t *bufLoc = buf + offset; - RelType type = rel.type; uint64_t addrLoc = getOutputSection()->addr + offset; if (auto *sec = dyn_cast(this)) addrLoc += sec->outSecOff; - RelExpr expr = rel.expr; - uint64_t targetVA = SignExtend64( - getRelocTargetVA(file, type, rel.addend, addrLoc, *rel.sym, expr), - bits); + const uint64_t targetVA = + SignExtend64(getRelocTargetVA(file, rel.type, rel.addend, addrLoc, + *rel.sym, rel.expr), bits); - switch (expr) { + switch (rel.expr) { case R_RELAX_GOT_PC: case R_RELAX_GOT_PC_NOPIC: target->relaxGot(bufLoc, rel, targetVA); @@ -1044,9 +1042,9 @@ void InputSectionBase::relocateAlloc(uint8_t *buf, uint8_t *bufEnd) { // the associated R_PPC64_GOT_PCREL34 since only the latter has an // associated symbol. So save the offset when relaxing R_PPC64_GOT_PCREL34 // and only relax the other if the saved offset matches. - if (type == R_PPC64_GOT_PCREL34) + if (rel.type == R_PPC64_GOT_PCREL34) lastPPCRelaxedRelocOff = offset; - if (type == R_PPC64_PCREL_OPT && offset != lastPPCRelaxedRelocOff) + if (rel.type == R_PPC64_PCREL_OPT && offset != lastPPCRelaxedRelocOff) break; target->relaxGot(bufLoc, rel, targetVA); break;