[PATCH] D117747: llvm-readobj: support globals in initializer expressions
Sam Clegg via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Jan 19 21:35:43 PST 2022
sbc100 created this revision.
Herald added subscribers: wingo, rupprecht.
Herald added a reviewer: jhenderson.
sbc100 requested review of this revision.
Herald added subscribers: llvm-commits, MaskRay, aheejin.
Herald added a project: LLVM.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D117747
Files:
llvm/test/tools/llvm-readobj/wasm/globals.test
llvm/tools/llvm-readobj/WasmDumper.cpp
Index: llvm/tools/llvm-readobj/WasmDumper.cpp
===================================================================
--- llvm/tools/llvm-readobj/WasmDumper.cpp
+++ llvm/tools/llvm-readobj/WasmDumper.cpp
@@ -183,7 +183,10 @@
W.printNumber("Offset", Seg.Offset.Value.Int32);
else if (Seg.Offset.Opcode == wasm::WASM_OPCODE_I64_CONST)
W.printNumber("Offset", Seg.Offset.Value.Int64);
- else
+ else if (Seg.Offset.Opcode == wasm::WASM_OPCODE_GLOBAL_GET) {
+ ListScope Group(W, "Offset");
+ W.printNumber("Global", Seg.Offset.Value.Global);
+ } else
llvm_unreachable("unknown init expr opcode");
}
break;
Index: llvm/test/tools/llvm-readobj/wasm/globals.test
===================================================================
--- /dev/null
+++ llvm/test/tools/llvm-readobj/wasm/globals.test
@@ -0,0 +1,32 @@
+# RUN: yaml2obj %s | llvm-readobj --sections - | FileCheck %s
+
+# Test symbols with custom import module and name attributes.
+
+--- !WASM
+FileHeader:
+ Version: 0x00000001
+Sections:
+ - Type: DATA
+ Segments:
+ - SectionOffset: 6
+ InitFlags: 0
+ Offset:
+ Opcode: GLOBAL_GET
+ Index: 1
+ Content: '64'
+...
+
+# CHECK: Section {
+# CHECK-NEXT: Type: DATA (0xB)
+# CHECK-NEXT: Size: 7
+# CHECK-NEXT: Offset: 8
+# CHECK-NEXT: Segments [
+# CHECK-NEXT: Segment {
+# CHECK-NEXT: Size: 1
+# CHECK-NEXT: Offset [
+# CHECK-NEXT: Global: 1
+# CHECK-NEXT: ]
+# CHECK-NEXT: }
+# CHECK-NEXT: ]
+# CHECK-NEXT: }
+# CHECK-NEXT: ]
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D117747.401501.patch
Type: text/x-patch
Size: 1695 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220120/8f194879/attachment.bin>
More information about the llvm-commits
mailing list