summaryrefslogtreecommitdiffstats
path: root/llvm/test/MC/WebAssembly
diff options
context:
space:
mode:
authorSam Clegg <sbc@chromium.org>2017-06-13 01:42:21 +0000
committerSam Clegg <sbc@chromium.org>2017-06-13 01:42:21 +0000
commit7736855dee38bb7abcb05ad665b8775e58c145d9 (patch)
tree5a5b3ea97c06fe39415fcb71b66c249768a05295 /llvm/test/MC/WebAssembly
parentf6137493829af06a98ec3d78f56e447c4de02909 (diff)
downloadbcm5719-llvm-7736855dee38bb7abcb05ad665b8775e58c145d9.tar.gz
bcm5719-llvm-7736855dee38bb7abcb05ad665b8775e58c145d9.zip
[WebAssembly] Fix symbol type for addresses of external functions
These symbols were previously not being marked as functions so were appearing as globals instead, and with the incorrect relocation type. Without this fix, objects that take address of external functions include them as global imports rather than function imports which then fails at link time. Differential Revision: https://reviews.llvm.org/D34068 llvm-svn: 305263
Diffstat (limited to 'llvm/test/MC/WebAssembly')
-rw-r--r--llvm/test/MC/WebAssembly/external-data.ll4
-rw-r--r--llvm/test/MC/WebAssembly/external-func-address.ll25
2 files changed, 27 insertions, 2 deletions
diff --git a/llvm/test/MC/WebAssembly/external-data.ll b/llvm/test/MC/WebAssembly/external-data.ll
index 91e05b3f13a..6914736ac67 100644
--- a/llvm/test/MC/WebAssembly/external-data.ll
+++ b/llvm/test/MC/WebAssembly/external-data.ll
@@ -2,10 +2,10 @@
; Verify relocations are correctly generated for addresses of externals
; in the data section.
-declare i32 @f1(...)
+@myimport = external global i32, align 4
@foo = global i64 7, align 4
-@far = local_unnamed_addr global i32 (...)* @f1, align 4
+@bar = hidden global i32* @myimport, align 4
; CHECK: - Type: DATA
; CHECK: Relocations:
diff --git a/llvm/test/MC/WebAssembly/external-func-address.ll b/llvm/test/MC/WebAssembly/external-func-address.ll
new file mode 100644
index 00000000000..4022b2c9bae
--- /dev/null
+++ b/llvm/test/MC/WebAssembly/external-func-address.ll
@@ -0,0 +1,25 @@
+; RUN: llc -mtriple wasm32-unknown-unknown-wasm -filetype=obj %s -o - | obj2yaml | FileCheck %s
+; Verify that addresses of external functions generate correctly typed
+; imports and relocations or type R_TABLE_INDEX_I32.
+
+declare void @f1() #1
+@ptr_to_f1 = hidden global void ()* @f1, align 4
+
+
+; CHECK: - Type: IMPORT
+; CHECK: Imports:
+; CHECK: - Module: env
+; CHECK: Field: f1
+; CHECK: Kind: FUNCTION
+; CHECK: SigIndex: 0
+; CHECK: - Type: ELEM
+; CHECK: Segments:
+; CHECK: - Offset:
+; CHECK: Opcode: I32_CONST
+; CHECK: Value: 0
+; CHECK: Functions: [ 0 ]
+; CHECK: - Type: DATA
+; CHECK: Relocations:
+; CHECK: - Type: R_WEBASSEMBLY_TABLE_INDEX_I32
+; CHECK: Index: 0
+; CHECK: Offset: 0x00000006
OpenPOWER on IntegriCloud