[PATCH] D43492: [WebAssembly] Check signatures of weakly defined funtions too

Phabricator via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 20 09:23:26 PST 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rL325598: [WebAssembly] Check signatures of weakly defined funtions too (authored by sbc, committed by ).

Repository:
  rL LLVM

https://reviews.llvm.org/D43492

Files:
  lld/trunk/test/wasm/Inputs/strong-symbol.ll
  lld/trunk/test/wasm/signature-mismatch-weak.ll
  lld/trunk/wasm/SymbolTable.cpp


Index: lld/trunk/test/wasm/Inputs/strong-symbol.ll
===================================================================
--- lld/trunk/test/wasm/Inputs/strong-symbol.ll
+++ lld/trunk/test/wasm/Inputs/strong-symbol.ll
@@ -0,0 +1,6 @@
+target triple = "wasm32-unknown-unknown-wasm"
+
+define i64 @weakFn() #0 {
+entry:
+  ret i64 1
+}
Index: lld/trunk/test/wasm/signature-mismatch-weak.ll
===================================================================
--- lld/trunk/test/wasm/signature-mismatch-weak.ll
+++ lld/trunk/test/wasm/signature-mismatch-weak.ll
@@ -0,0 +1,19 @@
+; RUN: llc -filetype=obj %p/Inputs/weak-symbol1.ll -o %t.weak.o
+; RUN: llc -filetype=obj %p/Inputs/strong-symbol.ll -o %t.strong.o
+; RUN: llc -filetype=obj %s -o %t.o
+; RUN: not wasm-ld --check-signatures -o %t.wasm %t.o %t.strong.o %t.weak.o 2>&1 | FileCheck %s
+; RUN: wasm-ld -o %t.wasm %t.o %t.strong.o %t.weak.o
+
+target triple = "wasm32-unknown-unknown-wasm"
+
+declare i32 @weakFn() local_unnamed_addr
+
+define void @_start() local_unnamed_addr {
+entry:
+  %call = call i32 @weakFn()
+  ret void
+}
+
+; CHECK: error: function signature mismatch: weakFn
+; CHECK-NEXT: >>> defined as () -> I32 in {{.*}}signature-mismatch-weak.ll.tmp.o
+; CHECK-NEXT: >>> defined as () -> I64 in {{.*}}signature-mismatch-weak.ll.tmp.strong.o
Index: lld/trunk/wasm/SymbolTable.cpp
===================================================================
--- lld/trunk/wasm/SymbolTable.cpp
+++ lld/trunk/wasm/SymbolTable.cpp
@@ -175,6 +175,7 @@
   } else if ((Flags & WASM_SYMBOL_BINDING_MASK) == WASM_SYMBOL_BINDING_WEAK) {
     // the new symbol is weak we can ignore it
     DEBUG(dbgs() << "existing symbol takes precedence\n");
+    CheckTypes = true;
   } else if (S->isWeak()) {
     // the existing symbol is, so we replace it
     DEBUG(dbgs() << "replacing existing weak symbol\n");


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D43492.135076.patch
Type: text/x-patch
Size: 1855 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180220/678a512f/attachment.bin>


More information about the llvm-commits mailing list