Skip to content

Commit 76243ad

Browse files
authored
[LLD][COFF] Merge .wowthk section to .text. (#76254)
.wowthk section is used by the compiler for ARM64EC entry thunks.
1 parent 8c24422 commit 76243ad

File tree

2 files changed

+47
-0
lines changed

2 files changed

+47
-0
lines changed

lld/COFF/Driver.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1951,6 +1951,9 @@ void LinkerDriver::linkerMain(ArrayRef<const char *> argsArr) {
19511951
parseMerge(".00cfg=.rdata");
19521952
parseMerge(".bss=.data");
19531953

1954+
if (isArm64EC(config->machine))
1955+
parseMerge(".wowthk=.text");
1956+
19541957
if (config->mingw) {
19551958
parseMerge(".ctors=.rdata");
19561959
parseMerge(".dtors=.rdata");

lld/test/COFF/merge-wowthk.s

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
// REQUIRES: aarch64
2+
3+
// RUN: llvm-mc -filetype=obj -triple=arm64ec-windows %s -o %t-arm64ec.obj
4+
// RUN: llvm-mc -filetype=obj -triple=aarch64-windows %s -o %t-arm64.obj
5+
// RUN: llvm-mc -filetype=obj -triple=arm64ec-windows %S/Inputs/loadconfig-arm64ec.s -o %t-loadcfg.obj
6+
7+
// Check that .wowthk section is merged into .text on ARM64EC target.
8+
9+
// RUN: lld-link -out:%t.dll -machine:arm64ec %t-arm64ec.obj %t-loadcfg.obj -dll -noentry
10+
// RUN: llvm-objdump -d %t.dll | FileCheck -check-prefix=DISASM %s
11+
// DISASM: 0000000180001000 <.text>:
12+
// DISASM-NEXT: 180001000: 52800040 mov w0, #0x2 // =2
13+
// DISASM-NEXT: 180001004: d65f03c0 ret
14+
// DISASM-NEXT: 180001008: 52800060 mov w0, #0x3 // =3
15+
// DISASM-NEXT: 18000100c: d65f03c0 ret
16+
17+
// Check that .wowthk section is not merged on aarch64 target.
18+
19+
// RUN: lld-link -out:%t.dll -machine:arm64 %t-arm64.obj -dll -noentry
20+
// RUN: llvm-objdump -d %t.dll | FileCheck -check-prefix=DISASM2 %s
21+
// DISASM2: 0000000180001000 <.text>:
22+
// DISASM2-NEXT: 180001000: 52800040 mov w0, #0x2 // =2
23+
// DISASM2-NEXT: 180001004: d65f03c0 ret
24+
// DISASM2-EMPTY:
25+
// DISASM2-NEXT: Disassembly of section .wowthk:
26+
// DISASM2-EMPTY:
27+
// DISASM2-NEXT: 0000000180002000 <.wowthk>:
28+
// DISASM2-NEXT: 180002000: 52800060 mov w0, #0x3 // =3
29+
// DISASM2-NEXT: 180002004: d65f03c0 ret
30+
31+
32+
.text
33+
.globl arm64ec_func_sym
34+
.p2align 2, 0x0
35+
arm64ec_func_sym:
36+
mov w0, #2
37+
ret
38+
39+
.section .wowthk$aa, "x"
40+
.globl wowthk_sym
41+
.p2align 3, 0x0
42+
wowthk_sym:
43+
mov w0, #3
44+
ret

0 commit comments

Comments
 (0)