aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/MC/ELFObjectWriter.cpp
diff options
context:
space:
mode:
authorFangrui Song <i@maskray.me>2025-04-16 00:07:16 -0700
committerGitHub <noreply@github.com>2025-04-16 00:07:16 -0700
commita630ef71e84a6bf09a99053ea42d37632ca0d18a (patch)
tree29810d7b0d6f18a6e34229fc6a85f97ce1ea6e20 /llvm/lib/MC/ELFObjectWriter.cpp
parentc1fc4c6a69c6ca0ae6aa060e4377ab5040505a66 (diff)
downloadllvm-a630ef71e84a6bf09a99053ea42d37632ca0d18a.zip
llvm-a630ef71e84a6bf09a99053ea42d37632ca0d18a.tar.gz
llvm-a630ef71e84a6bf09a99053ea42d37632ca0d18a.tar.bz2
ELFObjectWriter: Disable STT_SECTION adjustment for .reloc
... to match GNU Assembler. This generalizes the SHT_LLVM_CALL_GRAPH_PROFILE special case (which uses .reloc with BFD_RELOC_NONE https://reviews.llvm.org/D104080). Targets that want STT_SECTION adjustment cannot use FirstLiteralRelocationKind derived fixup kinds. Depends on the fix of #135521 Pull Request: https://github.com/llvm/llvm-project/pull/135519
Diffstat (limited to 'llvm/lib/MC/ELFObjectWriter.cpp')
-rw-r--r--llvm/lib/MC/ELFObjectWriter.cpp5
1 files changed, 2 insertions, 3 deletions
diff --git a/llvm/lib/MC/ELFObjectWriter.cpp b/llvm/lib/MC/ELFObjectWriter.cpp
index 46c71e2..2ae9c21 100644
--- a/llvm/lib/MC/ELFObjectWriter.cpp
+++ b/llvm/lib/MC/ELFObjectWriter.cpp
@@ -1395,9 +1395,8 @@ void ELFObjectWriter::recordRelocation(MCAssembler &Asm,
if (UseSectionSym) {
UseSectionSym = useSectionSymbol(Asm, Target, SymA, C, Type);
- // Disable STT_SECTION adjustment for CG Profile to help with --cg-profile.
- const auto *Parent = cast<MCSectionELF>(Fragment->getParent());
- UseSectionSym &= Parent->getType() != ELF::SHT_LLVM_CALL_GRAPH_PROFILE;
+ // Disable STT_SECTION adjustment for .reloc directives.
+ UseSectionSym &= Fixup.getKind() < FirstLiteralRelocationKind;
}
uint64_t Addend = UseSectionSym ? C + Asm.getSymbolOffset(*SymA) : C;