Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lld/ELF/Thunks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,8 @@ class PPC64PDLongBranchThunk final : public PPC64LongBranchThunk {

Defined *Thunk::addSymbol(StringRef name, uint8_t type, uint64_t value,
InputSectionBase &section) {
Defined *d = addSyntheticLocal(ctx, name, type, value, /*size=*/0, section);
Defined *d =
addSyntheticLocal(ctx, name, type, value + offset, /*size=*/0, section);
syms.push_back(d);
return d;
}
Expand Down
22 changes: 21 additions & 1 deletion lld/test/ELF/aarch64-thunk-bti-multipass.s
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
_start:
/// Call that requires a thunk.
bl fn1
bl fn2
/// padding so that the thunk for fn1 is placed after this section is
/// sufficiently close to the target to be within short range, but only
/// just so that a small displacement will mean a long thunk is needed.
Expand All @@ -39,13 +40,20 @@ _start:

// CHECK-LABEL: <_start>:
// CHECK-NEXT: 10001000: bl 0x10002008 <__AArch64AbsLongThunk_fn1>
// CHECK-NEXT: bl 0x10002018 <__AArch64AbsLongThunk_fn2>

// CHECK-LABEL: <__AArch64AbsLongThunk_fn1>:
// CHECK-NEXT: 10002008: ldr x16, 0x10002010 <__AArch64AbsLongThunk_fn1+0x8>
// CHECK-NEXT: br x16
// CHECK-NEXT: 00 30 00 18 .word 0x18003000
// CHECK-NEXT: 00 00 00 00 .word 0x00000000

// CHECK-LABEL: <__AArch64AbsLongThunk_fn2>:
// CHECK-NEXT: 10002018: ldr x16, 0x10002020 <__AArch64AbsLongThunk_fn2+0x8>
// CHECK-NEXT: br x16
// CHECK-NEXT: 04 40 00 18 .word 0x18004004
// CHECK-NEXT: 00 00 00 00 .word 0x00000000

.section .text.1, "ax", %progbits
.balign 0x1000
.global farcall
Expand Down Expand Up @@ -75,6 +83,12 @@ farcall:
fn1:
ret

.section .text.3, "ax", %progbits
.global fn2
.type fn2, %function
fn2:
ret

.section .text.far, "ax", %progbits
.type far, %function
.global far
Expand All @@ -88,6 +102,12 @@ far:
// CHECK-LABEL: <fn1>:
// CHECK-NEXT: 18004000: ret

// CHECK-LABEL: <__AArch64BTIThunk_fn2>:
// CHECK-NEXT: 18004004: bti c

// CHECK-LABEL: <fn2>:
// CHECK-NEXT: 18004008: ret

// CHECK-LABEL: <__AArch64BTIThunk_far>:
// CHECK-NEXT: 30000000: bti c

Expand All @@ -104,6 +124,6 @@ SECTIONS {
.rodata 0x10000000 : { *(.note.gnu.property) } :low
.text_low : { *(.text.0) } :low
.text 0x18001000 : { *(.text.1) } :mid
.text_aligned : { *(.text.2) } :mid
.text_aligned : { *(.text.2) *(.text.3) } :mid
.text_high 0x30000000 : { *(.text.far) } :high
}
Loading