diff options
author | Fangrui Song <i@maskray.me> | 2025-04-16 00:07:16 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-04-16 00:07:16 -0700 |
commit | a630ef71e84a6bf09a99053ea42d37632ca0d18a (patch) | |
tree | 29810d7b0d6f18a6e34229fc6a85f97ce1ea6e20 /llvm/lib/MC/ELFObjectWriter.cpp | |
parent | c1fc4c6a69c6ca0ae6aa060e4377ab5040505a66 (diff) | |
download | llvm-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.cpp | 5 |
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; |