Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[LLD][COFF] Merge .wowthk section to .text. #76254

Merged
merged 1 commit into from
Dec 25, 2023
Merged

Conversation

cjacek
Copy link
Contributor

@cjacek cjacek commented Dec 22, 2023

.wowthk section is used by the compiler for ARM64EC entry thunks.

.wowthk section is used by the compiler for ARM64EC entry thunks.
@llvmbot
Copy link
Collaborator

llvmbot commented Dec 22, 2023

@llvm/pr-subscribers-lld
@llvm/pr-subscribers-platform-windows

@llvm/pr-subscribers-lld-coff

Author: Jacek Caban (cjacek)

Changes

.wowthk section is used by the compiler for ARM64EC entry thunks.


Full diff: https://github.com/llvm/llvm-project/pull/76254.diff

2 Files Affected:

  • (modified) lld/COFF/Driver.cpp (+3)
  • (added) lld/test/COFF/merge-wowthk.s (+44)
diff --git a/lld/COFF/Driver.cpp b/lld/COFF/Driver.cpp
index 4f11affb35ed3e..cd2985b035bc0d 100644
--- a/lld/COFF/Driver.cpp
+++ b/lld/COFF/Driver.cpp
@@ -1951,6 +1951,9 @@ void LinkerDriver::linkerMain(ArrayRef<const char *> argsArr) {
   parseMerge(".00cfg=.rdata");
   parseMerge(".bss=.data");
 
+  if (isArm64EC(config->machine))
+    parseMerge(".wowthk=.text");
+
   if (config->mingw) {
     parseMerge(".ctors=.rdata");
     parseMerge(".dtors=.rdata");
diff --git a/lld/test/COFF/merge-wowthk.s b/lld/test/COFF/merge-wowthk.s
new file mode 100644
index 00000000000000..a1358fc30e4c5e
--- /dev/null
+++ b/lld/test/COFF/merge-wowthk.s
@@ -0,0 +1,44 @@
+// REQUIRES: aarch64
+
+// RUN: llvm-mc -filetype=obj -triple=arm64ec-windows %s -o %t-arm64ec.obj
+// RUN: llvm-mc -filetype=obj -triple=aarch64-windows %s -o %t-arm64.obj
+// RUN: llvm-mc -filetype=obj -triple=arm64ec-windows %S/Inputs/loadconfig-arm64ec.s -o %t-loadcfg.obj
+
+// Check that .wowthk section is merged into .text on ARM64EC target.
+
+// RUN: lld-link -out:%t.dll -machine:arm64ec %t-arm64ec.obj %t-loadcfg.obj -dll -noentry
+// RUN: llvm-objdump -d %t.dll | FileCheck  -check-prefix=DISASM %s
+// DISASM:      0000000180001000 <.text>:
+// DISASM-NEXT: 180001000: 52800040     mov     w0, #0x2                // =2
+// DISASM-NEXT: 180001004: d65f03c0     ret
+// DISASM-NEXT: 180001008: 52800060     mov     w0, #0x3                // =3
+// DISASM-NEXT: 18000100c: d65f03c0     ret
+
+// Check that .wowthk section is not merged on aarch64 target.
+
+// RUN: lld-link -out:%t.dll -machine:arm64 %t-arm64.obj -dll -noentry
+// RUN: llvm-objdump -d %t.dll | FileCheck -check-prefix=DISASM2 %s
+// DISASM2:      0000000180001000 <.text>:
+// DISASM2-NEXT: 180001000: 52800040     mov     w0, #0x2                // =2
+// DISASM2-NEXT: 180001004: d65f03c0     ret
+// DISASM2-EMPTY:
+// DISASM2-NEXT: Disassembly of section .wowthk:
+// DISASM2-EMPTY:
+// DISASM2-NEXT: 0000000180002000 <.wowthk>:
+// DISASM2-NEXT: 180002000: 52800060     mov     w0, #0x3                // =3
+// DISASM2-NEXT: 180002004: d65f03c0     ret
+
+
+        .text
+        .globl arm64ec_func_sym
+        .p2align 2, 0x0
+arm64ec_func_sym:
+        mov w0, #2
+        ret
+
+        .section .wowthk$aa, "x"
+        .globl wowthk_sym
+        .p2align 3, 0x0
+wowthk_sym:
+        mov w0, #3
+        ret

@cjacek cjacek merged commit 76243ad into llvm:main Dec 25, 2023
7 checks passed
@cjacek cjacek deleted the arm64ec-wowthk branch December 25, 2023 19:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants