Skip to content

Commit 3ff634d

Browse files
committed
Revert "ELFObjectWriter: Disable STT_SECTION adjustment for .reloc"
This reverts commit 1c5961c. Inadvertently pushed.
1 parent 1c5961c commit 3ff634d

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

llvm/lib/MC/ELFObjectWriter.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1390,8 +1390,9 @@ void ELFObjectWriter::recordRelocation(MCAssembler &Asm,
13901390
if (UseSectionSym) {
13911391
UseSectionSym = useSectionSymbol(Asm, Target, SymA, C, Type);
13921392

1393-
// Disable STT_SECTION adjustment for .reloc directives.
1394-
UseSectionSym &= Fixup.getKind() >= FirstLiteralRelocationKind;
1393+
// Disable STT_SECTION adjustment for CG Profile to help with --cg-profile.
1394+
const auto *Parent = cast<MCSectionELF>(Fragment->getParent());
1395+
UseSectionSym &= Parent->getType() != ELF::SHT_LLVM_CALL_GRAPH_PROFILE;
13951396
}
13961397

13971398
uint64_t Addend = UseSectionSym ? C + Asm.getSymbolOffset(*SymA) : C;

llvm/test/MC/ELF/reloc-directive.s

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,25 +8,24 @@
88
# ASM-NEXT: .Ltmp1:
99
# ASM-NEXT: .reloc .Ltmp1-1, R_X86_64_NONE, foo
1010
# ASM-NEXT: .Ltmp2:
11-
# ASM-NEXT: .reloc 2+.Ltmp2, R_X86_64_NONE, local
11+
# ASM-NEXT: .reloc 2+.Ltmp2, R_X86_64_NONE, foo
1212
# ASM-NEXT: .reloc 1+foo+3, R_X86_64_NONE, data+1
1313
# ASM-NEXT: .Ltmp3:
1414
# ASM-NEXT: .reloc .Ltmp3, BFD_RELOC_NONE, unused
1515

1616
# CHECK: 0x2 R_X86_64_NONE foo 0x0
1717
# CHECK-NEXT: 0x0 R_X86_64_NONE foo 0x0
18-
# CHECK-NEXT: 0x3 R_X86_64_NONE local 0x0
18+
# CHECK-NEXT: 0x3 R_X86_64_NONE foo 0x0
1919
# CHECK-NEXT: 0x4 R_X86_64_NONE data 0x1
2020
# CHECK-NEXT: 0x1 R_X86_64_NONE unused 0x0
2121

2222
.text
2323
.globl foo
2424
foo:
25-
local:
2625
ret
2726
.reloc .+3-2, R_X86_64_NONE, foo
2827
.reloc .-1, R_X86_64_NONE, foo
29-
.reloc 2+., R_X86_64_NONE, local
28+
.reloc 2+., R_X86_64_NONE, foo
3029
.reloc 1+foo+3, R_X86_64_NONE, data+1
3130
.reloc ., BFD_RELOC_NONE, unused
3231

0 commit comments

Comments
 (0)