aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/MC/ELFObjectWriter.cpp
diff options
context:
space:
mode:
authorFangrui Song <i@maskray.me>2024-08-18 15:47:38 -0700
committerFangrui Song <i@maskray.me>2024-08-18 15:47:38 -0700
commit1a6bf94407af7962345ffaf6ac9e9a9766fd8913 (patch)
tree8bd932f4c91ded8c6b112d955cfbd22119172e31 /llvm/lib/MC/ELFObjectWriter.cpp
parentc6e16a49ef41261b01aabc27f4b806af6cc81a20 (diff)
downloadllvm-1a6bf94407af7962345ffaf6ac9e9a9766fd8913.zip
llvm-1a6bf94407af7962345ffaf6ac9e9a9766fd8913.tar.gz
llvm-1a6bf94407af7962345ffaf6ac9e9a9766fd8913.tar.bz2
[MC] Remove ELFRelocationEntry::OriginalAddend
For MIPS's o32 ABI (REL), https://reviews.llvm.org/D19718 introduced `OriginalAddend` to find the matching R_MIPS_LO16 relocation for R_MIPS_GOT16 when STT_SECTION conversion is applicable. lw $2, %lo(local1) lui $2, %got(local1) However, we could just store the original `Addend` in `ELFRelocationEntry` and remove `OriginalAddend`. Note: The relocation ordering algorithm in https://reviews.llvm.org/D19718 is inefficient (#104562), which will be addressed by another patch.
Diffstat (limited to 'llvm/lib/MC/ELFObjectWriter.cpp')
-rw-r--r--llvm/lib/MC/ELFObjectWriter.cpp17
1 files changed, 6 insertions, 11 deletions
diff --git a/llvm/lib/MC/ELFObjectWriter.cpp b/llvm/lib/MC/ELFObjectWriter.cpp
index 7a8a6c8..35d0a2e 100644
--- a/llvm/lib/MC/ELFObjectWriter.cpp
+++ b/llvm/lib/MC/ELFObjectWriter.cpp
@@ -1443,22 +1443,17 @@ void ELFObjectWriter::recordRelocation(MCAssembler &Asm,
bool RelocateWithSymbol =
shouldRelocateWithSymbol(Asm, Target, SymA, C, Type) ||
(Parent->getType() == ELF::SHT_LLVM_CALL_GRAPH_PROFILE);
- uint64_t Addend = 0;
-
- FixedValue = !RelocateWithSymbol && SymA && !SymA->isUndefined()
- ? C + Asm.getSymbolOffset(*SymA)
- : C;
- if (usesRela(TO, FixupSection)) {
- Addend = FixedValue;
- FixedValue = 0;
- }
+ uint64_t Addend = !RelocateWithSymbol && SymA && !SymA->isUndefined()
+ ? C + Asm.getSymbolOffset(*SymA)
+ : C;
+ FixedValue = usesRela(TO, FixupSection) ? 0 : Addend;
if (!RelocateWithSymbol) {
const auto *SectionSymbol =
SecA ? cast<MCSymbolELF>(SecA->getBeginSymbol()) : nullptr;
if (SectionSymbol)
SectionSymbol->setUsedInReloc();
- ELFRelocationEntry Rec(FixupOffset, SectionSymbol, Type, Addend, SymA, C);
+ ELFRelocationEntry Rec(FixupOffset, SectionSymbol, Type, Addend, SymA);
Relocations[&FixupSection].push_back(Rec);
return;
}
@@ -1473,7 +1468,7 @@ void ELFObjectWriter::recordRelocation(MCAssembler &Asm,
else
RenamedSymA->setUsedInReloc();
}
- ELFRelocationEntry Rec(FixupOffset, RenamedSymA, Type, Addend, SymA, C);
+ ELFRelocationEntry Rec(FixupOffset, RenamedSymA, Type, Addend, SymA);
Relocations[&FixupSection].push_back(Rec);
}