Skip to content

Commit cc767f2

Browse files
committed
Prepare for next PR
Created using spr 1.3.6-beta.1
2 parents 4359b41 + 9aa3e99 commit cc767f2

File tree

5 files changed

+20
-6
lines changed

5 files changed

+20
-6
lines changed

lld/ELF/Arch/X86_64.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ class X86_64 : public TargetInfo {
5050
bool deleteFallThruJmpInsn(InputSection &is, InputFile *file,
5151
InputSection *nextIS) const override;
5252
bool relaxOnce(int pass) const override;
53+
void relaxCFIJumpTables() const override;
5354
void applyBranchToBranchOpt() const override;
5455

5556
private:
@@ -317,7 +318,7 @@ bool X86_64::deleteFallThruJmpInsn(InputSection &is, InputFile *file,
317318
return true;
318319
}
319320

320-
static void relaxJumpTables(Ctx &ctx) {
321+
void X86_64::relaxCFIJumpTables() const {
321322
// Relax CFI jump tables.
322323
// - Split jump table into pieces and place target functions inside the jump
323324
// table if small enough.
@@ -482,9 +483,6 @@ static void relaxJumpTables(Ctx &ctx) {
482483
}
483484

484485
bool X86_64::relaxOnce(int pass) const {
485-
if (pass == 0)
486-
relaxJumpTables(ctx);
487-
488486
uint64_t minVA = UINT64_MAX, maxVA = 0;
489487
for (OutputSection *osec : ctx.outputSections) {
490488
if (!(osec->flags & SHF_ALLOC))

lld/ELF/Target.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,8 @@ class TargetInfo {
9696

9797
// Do a linker relaxation pass and return true if we changed something.
9898
virtual bool relaxOnce(int pass) const { return false; }
99+
// Relax CFI jump tables if implemented by target.
100+
virtual void relaxCFIJumpTables() const {}
99101
// Do finalize relaxation after collecting relaxation infos.
100102
virtual void finalizeRelax(int passes) const {}
101103

lld/ELF/Writer.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1528,6 +1528,8 @@ template <class ELFT> void Writer<ELFT>::finalizeAddressDependentContent() {
15281528
if (ctx.arg.randomizeSectionPadding)
15291529
randomizeSectionPadding(ctx);
15301530

1531+
ctx.target->relaxCFIJumpTables();
1532+
15311533
uint32_t pass = 0, assignPasses = 0;
15321534
for (;;) {
15331535
bool changed = ctx.target->needsThunks

llvm/lib/MC/MCSectionELF.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,11 +176,13 @@ void MCSectionELF::printSwitchToSection(const MCAsmInfo &MAI, const Triple &T,
176176
OS << "llvm_lto";
177177
else if (Type == ELF::SHT_LLVM_JT_SIZES)
178178
OS << "llvm_jt_sizes";
179+
else if (Type == ELF::SHT_LLVM_CFI_JUMP_TABLE)
180+
OS << "llvm_cfi_jump_table";
179181
else
180182
OS << "0x" << Twine::utohexstr(Type);
181183

182184
if (EntrySize) {
183-
assert(Flags & ELF::SHF_MERGE);
185+
assert((Flags & ELF::SHF_MERGE) || Type == ELF::SHT_LLVM_CFI_JUMP_TABLE);
184186
OS << "," << EntrySize;
185187
}
186188

llvm/test/MC/AsmParser/llvm_section_types.s

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,32 @@
1-
## Verify that LLVM-specific section types are correctly inferred from assembly input.
1+
## Verify that LLVM-specific section types are correctly inferred from assembly input and printed.
2+
# RUN: llvm-mc -triple i386-pc-linux %s | FileCheck --check-prefix=ASM %s
23
# RUN: llvm-mc -triple i386-pc-linux -filetype=obj -o %t %s
34
# RUN: llvm-readobj -S %t | FileCheck %s
5+
# ASM: .section .section1,"",@llvm_bb_addr_map
46
.section .section1,"",@llvm_bb_addr_map
57
.byte 1
8+
# ASM: .section .section2,"",@llvm_call_graph_profile
69
.section .section2,"",@llvm_call_graph_profile
710
.byte 1
11+
# ASM: .section .section3,"",@llvm_odrtab
812
.section .section3,"",@llvm_odrtab
913
.byte 1
14+
# ASM: .section .section4,"",@llvm_linker_options
1015
.section .section4,"",@llvm_linker_options
1116
.byte 1
17+
# ASM: .section .section5,"",@llvm_sympart
1218
.section .section5,"",@llvm_sympart
1319
.byte 1
20+
# ASM: .section .section6,"",@llvm_dependent_libraries
1421
.section .section6,"",@llvm_dependent_libraries
1522
.byte 1
23+
# ASM: .section .section7,"",@llvm_offloading
1624
.section .section7,"",@llvm_offloading
1725
.byte 1
26+
# ASM: .section .section8,"",@llvm_lto
1827
.section .section8,"",@llvm_lto
1928
.byte 1
29+
# ASM: .section .section9,"",@llvm_cfi_jump_table,1
2030
.section .section9,"",@llvm_cfi_jump_table,1
2131
.byte 1
2232

0 commit comments

Comments
 (0)