-
Notifications
You must be signed in to change notification settings - Fork 13.6k
ELFObjectWriter: Disable STT_SECTION adjustment for .reloc #135519
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
MaskRay
merged 2 commits into
main
from
users/MaskRay/spr/elfobjectwriter-disable-stt_section-adjustment-for-reloc
Apr 16, 2025
Merged
ELFObjectWriter: Disable STT_SECTION adjustment for .reloc #135519
MaskRay
merged 2 commits into
main
from
users/MaskRay/spr/elfobjectwriter-disable-stt_section-adjustment-for-reloc
Apr 16, 2025
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Created using spr 1.3.5-bogner
@llvm/pr-subscribers-mc Author: Fangrui Song (MaskRay) Changes... to match GNU Assembler. This generalizes the Targets that want STT_SECTION adjustment cannot use Full diff: https://github.com/llvm/llvm-project/pull/135519.diff 2 Files Affected:
diff --git a/llvm/lib/MC/ELFObjectWriter.cpp b/llvm/lib/MC/ELFObjectWriter.cpp
index 6e37dad7b753e..3a21ca2e4943d 100644
--- a/llvm/lib/MC/ELFObjectWriter.cpp
+++ b/llvm/lib/MC/ELFObjectWriter.cpp
@@ -1389,9 +1389,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;
diff --git a/llvm/test/MC/ELF/reloc-directive.s b/llvm/test/MC/ELF/reloc-directive.s
index f4121ef071810..42995aa9e7d81 100644
--- a/llvm/test/MC/ELF/reloc-directive.s
+++ b/llvm/test/MC/ELF/reloc-directive.s
@@ -8,24 +8,25 @@
# ASM-NEXT: .Ltmp1:
# ASM-NEXT: .reloc .Ltmp1-1, R_X86_64_NONE, foo
# ASM-NEXT: .Ltmp2:
-# ASM-NEXT: .reloc 2+.Ltmp2, R_X86_64_NONE, foo
+# ASM-NEXT: .reloc 2+.Ltmp2, R_X86_64_NONE, local
# ASM-NEXT: .reloc 1+foo+3, R_X86_64_NONE, data+1
# ASM-NEXT: .Ltmp3:
# ASM-NEXT: .reloc .Ltmp3, BFD_RELOC_NONE, unused
# CHECK: 0x2 R_X86_64_NONE foo 0x0
# CHECK-NEXT: 0x0 R_X86_64_NONE foo 0x0
-# CHECK-NEXT: 0x3 R_X86_64_NONE foo 0x0
+# CHECK-NEXT: 0x3 R_X86_64_NONE local 0x0
# CHECK-NEXT: 0x4 R_X86_64_NONE data 0x1
# CHECK-NEXT: 0x1 R_X86_64_NONE unused 0x0
.text
.globl foo
foo:
+local:
ret
.reloc .+3-2, R_X86_64_NONE, foo
.reloc .-1, R_X86_64_NONE, foo
- .reloc 2+., R_X86_64_NONE, foo
+ .reloc 2+., R_X86_64_NONE, local
.reloc 1+foo+3, R_X86_64_NONE, data+1
.reloc ., BFD_RELOC_NONE, unused
|
MaskRay
added a commit
that referenced
this pull request
Apr 13, 2025
Move `Fixup.getKind() >= FirstLiteralRelocationKind` from target hooks to ELFObjectWriter::recordRelocation. Currently, getRelocType cannot be skipped for LoongArch due to #135519
llvm-sync bot
pushed a commit
to arm/arm-toolchain
that referenced
this pull request
Apr 16, 2025
... 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: llvm/llvm-project#135519
var-const
pushed a commit
to ldionne/llvm-project
that referenced
this pull request
Apr 17, 2025
Move `Fixup.getKind() >= FirstLiteralRelocationKind` from target hooks to ELFObjectWriter::recordRelocation. Currently, getRelocType cannot be skipped for LoongArch due to llvm#135519
var-const
pushed a commit
to ldionne/llvm-project
that referenced
this pull request
Apr 17, 2025
... 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 llvm#135521 Pull Request: llvm#135519
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
... 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