Skip to content

Commit bed8997

Browse files
authored
AArch64: Replace @plt/%gotpcrel in data directives with %pltpcrel %gotpcrel (llvm#155776)
Similar to llvm#132569 for RISC-V, replace the unofficial `@plt` and `@gotpcrel` relocation specifiers, currently only used by clang -fexperimental-relative-c++-abi-vtables, with %pltpcrel %gotpcrel. The syntax is not used in humand-written assembly code, and is not supported by GNU assembler. Also replace the recent `@funcinit` with `%funcinit(x)`.
1 parent ce6a3d9 commit bed8997

17 files changed

Lines changed: 137 additions & 76 deletions

‎bolt/test/AArch64/skip-non-vfuncptr-reloc-in-relative-vtable.s‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,5 @@ _fake_rtti_data:
3131
_ZTV3gooE:
3232
.word 0
3333
.word _fake_rtti_data-_ZTV3gooE-8
34-
.word foo@PLT-_ZTV3gooE-8
34+
.word %pltpcrel(foo)
3535
.size _ZTV3gooE, 12

‎lld/test/ELF/aarch64-branch-to-branch.s‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,14 @@ vtable:
3535
# B2B-NEXT: [[VF:[0-9a-f]{8}]]
3636
# B2B-RELOC-NEXT: R_AARCH64_PLT32 f3
3737
# NOB2B-RELOC-NEXT: R_AARCH64_PLT32 f1
38-
.4byte f1@PLT - vtable
38+
.4byte %pltpcrel(f1)
3939
# B2B-SAME: [[VF]]
4040
# B2B-RELOC-NEXT: R_AARCH64_PLT32 f3+0x4
4141
# NOB2B-RELOC-NEXT: R_AARCH64_PLT32 f2+0x4
42-
.4byte f2@PLT - vtable
42+
.4byte %pltpcrel(f2+4)
4343
# B2B-SAME: [[VF]]
4444
# RELOC-NEXT: R_AARCH64_PLT32 f3+0x8
45-
.4byte f3@PLT - vtable
45+
.4byte %pltpcrel(f3+8)
4646

4747
.section .text._start,"ax"
4848
.globl _start

‎lld/test/ELF/aarch64-feature-bti.s‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,5 +290,5 @@ func1:
290290

291291
.ifdef RELVTABLE_PLT
292292
// R_AARCH64_PLT32
293-
.word funcRelVtable@PLT - .
293+
.word %pltpcrel(funcRelVtable)
294294
.endif

‎lld/test/ELF/aarch64-funcinit64-invalid.s‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55

66
.rodata
77
# ERR: error: relocation R_AARCH64_FUNCINIT64 cannot be used against local symbol
8-
.8byte func@FUNCINIT
8+
.8byte %funcinit(func)
99

1010
.data
1111
# ERR: error: relocation R_AARCH64_FUNCINIT64 cannot be used against ifunc symbol 'ifunc'
12-
.8byte ifunc@FUNCINIT
12+
.8byte %funcinit(ifunc)
1313

1414
.text
1515
func:

‎lld/test/ELF/aarch64-funcinit64.s‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
.data
1111
# CHECK: R_AARCH64_IRELATIVE [[FOO:[0-9a-f]*]]
1212
# ERR: relocation R_AARCH64_FUNCINIT64 cannot be used against preemptible symbol 'foo'
13-
.8byte foo@FUNCINIT
13+
.8byte %funcinit(foo)
1414

1515
.text
1616
# CHECK: {{0*}}[[FOO]] {{.*}} foo

‎lld/test/ELF/aarch64-range-thunk-extension-plt32.s‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
.global _start
2626
.type _start, %function
2727
_start:
28-
.word callee@PLT - .
28+
.word %pltpcrel(callee)
2929

3030
.section .text.2, "ax", %progbits
3131
.global callee

‎lld/test/ELF/aarch64-reloc-gotpcrel32.s‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ _start: // PC = 0x303a0
1717
// bar@GOTPCREL-4 = 0x20390 (got entry for `bar`) - 0x303a8 (.) - 4 = 0xe4fffeff
1818
// CHECK: Contents of section .data:
1919
// CHECK-NEXT: {{.*}} f0fffeff f0fffeff e4fffeff
20-
.word bar@GOTPCREL
21-
.word bar@GOTPCREL+4
22-
.word bar@GOTPCREL-4
20+
.word %gotpcrel(bar)
21+
.word %gotpcrel(bar+4)
22+
.word %gotpcrel(bar-4)
2323

2424
// WARN: relocation R_AARCH64_GOTPCREL32 out of range: {{.*}} is not in [-2147483648, 2147483647]; references 'baz'
2525
// WARN: relocation R_AARCH64_GOTPCREL32 out of range: {{.*}} is not in [-2147483648, 2147483647]; references 'baz'
26-
.word baz@GOTPCREL+0xffffffff
27-
.word baz@GOTPCREL-0xffffffff
26+
.word %gotpcrel(baz+0xffffffff)
27+
.word %gotpcrel(baz-0xffffffff)

‎lld/test/ELF/aarch64-reloc-plt32.s‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,6 @@
3232
.globl _start
3333
_start:
3434
.data
35-
.word foo@PLT - . + 2149589079
36-
.word foo@PLT - . - 2145378212
37-
.word foo@PLT - .
35+
.word %pltpcrel(foo + 2149589079)
36+
.word %pltpcrel(foo - 2145378212)
37+
.word %pltpcrel(foo)

‎lld/test/ELF/aarch64-undefined-weak.s‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ _start:
3737
// R_AARCH64_PREL16
3838
.hword target - .
3939
// R_AARCH64_PLT32
40-
.word target@PLT - .
40+
.word %pltpcrel(target)
4141

4242
bl_undefweak2:
4343
bl undefweak2

‎llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2671,8 +2671,9 @@ const MCExpr *AArch64AsmPrinter::emitPAuthRelocationAsIRelative(
26712671
MCInstBuilder(AArch64::RET).addReg(AArch64::LR), *STI);
26722672
OutStreamer->popSection();
26732673

2674-
return MCSymbolRefExpr::create(IRelativeSym, AArch64::S_FUNCINIT,
2675-
OutStreamer->getContext());
2674+
return MCSpecifierExpr::create(
2675+
MCSymbolRefExpr::create(IRelativeSym, OutStreamer->getContext()),
2676+
AArch64::S_FUNCINIT, OutStreamer->getContext());
26762677
}
26772678

26782679
const MCExpr *

0 commit comments

Comments
 (0)