aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/MC/ELFObjectWriter.cpp
diff options
context:
space:
mode:
authorFangrui Song <i@maskray.me>2025-04-18 18:18:30 -0700
committerFangrui Song <i@maskray.me>2025-04-18 18:18:31 -0700
commitf9bd89b7ac35920241740969b2b83c45a6a6ddb3 (patch)
tree18aa14cc18a51e25a5497ce71e705abac7fba2c8 /llvm/lib/MC/ELFObjectWriter.cpp
parent58a5c469d97302bb33a54338cf827a4cbe4e416a (diff)
downloadllvm-f9bd89b7ac35920241740969b2b83c45a6a6ddb3.zip
llvm-f9bd89b7ac35920241740969b2b83c45a6a6ddb3.tar.gz
llvm-f9bd89b7ac35920241740969b2b83c45a6a6ddb3.tar.bz2
MCFixup: Add isRelocation/isRelocRelocation helpers
Add two helper functions to simplify checks for relocation types, replacing direct comparisons with FirstRelocationKind and FirstLiteralRelocationKind. Note: Some targets haven't utilized isRelocation yet. Also, update RelaxFixupKind to use 0 as the sentinel value.
Diffstat (limited to 'llvm/lib/MC/ELFObjectWriter.cpp')
-rw-r--r--llvm/lib/MC/ELFObjectWriter.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/llvm/lib/MC/ELFObjectWriter.cpp b/llvm/lib/MC/ELFObjectWriter.cpp
index 2ae9c21..5c39dae 100644
--- a/llvm/lib/MC/ELFObjectWriter.cpp
+++ b/llvm/lib/MC/ELFObjectWriter.cpp
@@ -1385,7 +1385,7 @@ void ELFObjectWriter::recordRelocation(MCAssembler &Asm,
auto EMachine = TargetObjectWriter->getEMachine();
unsigned Type;
- if (Fixup.getKind() >= FirstLiteralRelocationKind)
+ if (mc::isRelocRelocation(Fixup.getKind()))
Type = Fixup.getKind() - FirstLiteralRelocationKind;
else
Type = TargetObjectWriter->getRelocType(Ctx, Target, Fixup, IsPCRel);
@@ -1396,7 +1396,7 @@ void ELFObjectWriter::recordRelocation(MCAssembler &Asm,
UseSectionSym = useSectionSymbol(Asm, Target, SymA, C, Type);
// Disable STT_SECTION adjustment for .reloc directives.
- UseSectionSym &= Fixup.getKind() < FirstLiteralRelocationKind;
+ UseSectionSym &= !mc::isRelocRelocation(Fixup.getKind());
}
uint64_t Addend = UseSectionSym ? C + Asm.getSymbolOffset(*SymA) : C;