[lld] [LLD][COFF] Handle imported weak aliases consistently (PR #109105)
Martin Storsjö via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 18 02:32:04 PDT 2024
================
@@ -0,0 +1,25 @@
+# REQUIRES: x86
+
+# RUN: split-file %s %t.dir
+# RUN: llc --filetype=obj -o %t.foo.obj %t.dir/foo.ll
+# RUN: llvm-mc --filetype=obj -triple=x86_64-windows-msvc %t.dir/qux.s -o %t.qux.obj
+# RUN: lld-link %t.qux.obj %t.foo.obj -out:%t.dll -dll 2>&1 | FileCheck %s
+#
+# CHECK-NOT: lld-link: error: undefined symbol: __declspec(dllimport) foo
+
+#--- foo.ll
+target datalayout = "e-m:w-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-pc-windows-msvc"
+
+ at foo = weak alias void(), ptr @bar
+
+define void @bar() {
+ ret void
+}
+
+#--- qux.s
+.text
+.global _DllMainCRTStartup
+_DllMainCRTStartup:
+ call __imp_foo
----------------
mstorsjo wrote:
I think it would be better for correctness, to have it with the `*` - that's what real code would use. (Or looking at the compiler output, it's actually `call *__imp_foo(%rip)`, not sure if that makes any difference.) Not that test code needs to be fully correct, but I'd find it preferrable.
It obviously doesn't make any difference for the outcome of the test, but without the `*` this would crash at execution, by jumping to execute the address as code.
https://github.com/llvm/llvm-project/pull/109105
More information about the llvm-commits
mailing list