From 7736855dee38bb7abcb05ad665b8775e58c145d9 Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Tue, 13 Jun 2017 01:42:21 +0000 Subject: [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 --- llvm/test/MC/WebAssembly/external-func-address.ll | 25 +++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 llvm/test/MC/WebAssembly/external-func-address.ll (limited to 'llvm/test/MC/WebAssembly/external-func-address.ll') 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 -- cgit v1.2.3