[PATCH] D37384: [WebAssembly] Fix getSymbolValue for exported globals

Phabricator via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 1 10:25:43 PDT 2017


This revision was automatically updated to reflect the committed changes.
Closed by commit rL312340: [WebAssembly] Fix getSymbolValue for exported globals (authored by sbc).

Repository:
  rL LLVM

https://reviews.llvm.org/D37384

Files:
  llvm/trunk/lib/Object/WasmObjectFile.cpp
  llvm/trunk/test/tools/llvm-nm/wasm/exports.yaml
  llvm/trunk/test/tools/llvm-nm/wasm/imports.yaml
  llvm/trunk/test/tools/llvm-nm/wasm/weak-symbols.yaml


Index: llvm/trunk/lib/Object/WasmObjectFile.cpp
===================================================================
--- llvm/trunk/lib/Object/WasmObjectFile.cpp
+++ llvm/trunk/lib/Object/WasmObjectFile.cpp
@@ -788,7 +788,7 @@
   case WasmSymbol::SymbolType::FUNCTION_EXPORT:
     return Exports[Sym.ElementIndex].Index;
   case WasmSymbol::SymbolType::GLOBAL_EXPORT: {
-    uint32_t GlobalIndex = Exports[Sym.ElementIndex].Index;
+    uint32_t GlobalIndex = Exports[Sym.ElementIndex].Index - NumImportedGlobals;
     assert(GlobalIndex < Globals.size());
     const wasm::WasmGlobal& Global = Globals[GlobalIndex];
     return Global.InitExpr.Value.Int32;
Index: llvm/trunk/test/tools/llvm-nm/wasm/weak-symbols.yaml
===================================================================
--- llvm/trunk/test/tools/llvm-nm/wasm/weak-symbols.yaml
+++ llvm/trunk/test/tools/llvm-nm/wasm/weak-symbols.yaml
@@ -1,4 +1,4 @@
-# RUN: yaml2obj < %s | llvm-nm - | FileCheck %s
+# RUN: yaml2obj < %s | llvm-nm - | FileCheck -strict-whitespace %s
 
 # That wasm exports of functions and globals are displayed as global data and
 # code symbols.
@@ -49,7 +49,7 @@
         Index:           0x00000004
       - Name:            weak_global_data
         Kind:            GLOBAL
-        Index:           0x00000002
+        Index:           0x00000003
   - Type:            CUSTOM
     Name:            linking
     DataSize:        0
Index: llvm/trunk/test/tools/llvm-nm/wasm/imports.yaml
===================================================================
--- llvm/trunk/test/tools/llvm-nm/wasm/imports.yaml
+++ llvm/trunk/test/tools/llvm-nm/wasm/imports.yaml
@@ -1,4 +1,4 @@
-# RUN: yaml2obj < %s | llvm-nm - | FileCheck %s
+# RUN: yaml2obj < %s | llvm-nm - | FileCheck -strict-whitespace %s
 
 --- !WASM
 FileHeader:
Index: llvm/trunk/test/tools/llvm-nm/wasm/exports.yaml
===================================================================
--- llvm/trunk/test/tools/llvm-nm/wasm/exports.yaml
+++ llvm/trunk/test/tools/llvm-nm/wasm/exports.yaml
@@ -1,4 +1,4 @@
-# RUN: yaml2obj < %s | llvm-nm - | FileCheck %s
+# RUN: yaml2obj < %s | llvm-nm - | FileCheck -strict-whitespace %s
 
 # That wasm exports of functions and globals are displayed as global data and
 # code symbols.
@@ -31,14 +31,27 @@
         InitExpr:
           Opcode:          I64_CONST
           Value:           1024
+  - Type:            IMPORT
+    Imports:
+      - Module:          env
+        Field:           fimport
+        Kind:            FUNCTION
+        SigIndex:        0
+      - Module:          env
+        Field:           gimport
+        Kind:            GLOBAL
+        GlobalType:      I32
+        GlobalMutable:   false
   - Type:            EXPORT
     Exports:
       - Name:            foo
         Kind:            FUNCTION
         Index:           0x00000004
       - Name:            bar
         Kind:            GLOBAL
-        Index:           0x00000002
+        Index:           0x00000003
 
-# CHECK: 00000400 D bar
-# CHECK: 00000004 T foo
+# CHECK:      00000400 D bar
+# CHECK-NEXT:          U fimport
+# CHECK-NEXT: 00000004 T foo
+# CHECK-NEXT:          U gimport


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D37384.113554.patch
Type: text/x-patch
Size: 3162 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170901/0e1c06d5/attachment.bin>


More information about the llvm-commits mailing list