Skip to content

Commit 444441d

Browse files
committed
[𝘀𝗽𝗿] changes introduced through rebase
Created using spr 1.3.6-beta.1 [skip ci]
1 parent 6478b25 commit 444441d

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

lld/ELF/Arch/X86_64.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,13 @@ void X86_64::relaxCFIJumpTables() const {
376376
// because the last entry controls which output section the jump table is
377377
// placed into, which affects move eligibility for other sections.
378378
auto *lastSec = [&]() -> InputSection * {
379+
// If the jump table section is more aligned than the entry size, skip
380+
// this because there's no guarantee that we'll be able to emit a
381+
// padding section that places the last entry at a correctly aligned
382+
// address.
383+
if (sec->addralign > sec->entsize)
384+
return nullptr;
385+
379386
Relocation *lastReloc = sec->relocs().end();
380387
while (lastReloc != sec->relocs().begin() &&
381388
(lastReloc - 1)->offset >= sec->size - sec->entsize)

lld/test/ELF/x86_64-relax-jump-tables.s

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,23 @@ jmp f12.cfi
109109
f13:
110110
jmp f13.cfi
111111

112+
// Jumptable alignment > entsize prevents it from being moved before last
113+
// function, but moving non-last functions into the jumptable should work.
114+
// CHECK: <f14>:
115+
// CHECK-NEXT: <f14.cfi>:
116+
// CHECK-NEXT: retq $0xe
117+
.section .text.jt5,"ax",@llvm_cfi_jump_table,8
118+
.balign 16
119+
f14:
120+
jmp f14.cfi
121+
.balign 8, 0xcc
122+
123+
// CHECK: <f15>:
124+
// CHECK-NEXT: jmp {{.*}} <f15.cfi>
125+
f15:
126+
jmp f15.cfi
127+
.balign 8, 0xcc
128+
112129
// CHECK: <f1>:
113130
// CHECK-NEXT: <f1.cfi>:
114131
// CHECK-NEXT: retq $0x1
@@ -180,5 +197,15 @@ ret $12
180197
f13.cfi:
181198
ret $13
182199

200+
.section .text.f14,"ax",@progbits
201+
f14.cfi:
202+
ret $14
203+
204+
.section .text.f15,"ax",@progbits
205+
.balign 64
206+
f15.cfi:
207+
ret $15
208+
.zero 16
209+
183210
// CHECK: <.iplt>:
184211
// CHECK-NEXT: [[IPLT]]:

0 commit comments

Comments
 (0)