[PATCH] D60296: [WebAssembly] Include function in wasm table when used in R_WASM_TABLE_INDEX_REL_SLEB
Sam Clegg via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 4 17:24:40 PDT 2019
sbc100 created this revision.
Herald added subscribers: llvm-commits, arphaman, sunfish, aheejin, jgravelle-google, dschuff.
Herald added a project: LLVM.
This should have been part of rL357710 <https://reviews.llvm.org/rL357710> but was overlooked because
in our test code the function in question was also used in other
relocations that caused it to be added to the table anyway.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D60296
Files:
lld/test/wasm/shared.ll
lld/wasm/Writer.cpp
Index: lld/wasm/Writer.cpp
===================================================================
--- lld/wasm/Writer.cpp
+++ lld/wasm/Writer.cpp
@@ -1138,7 +1138,8 @@
for (const WasmRelocation &Reloc : Chunk->getRelocations()) {
switch (Reloc.Type) {
case R_WASM_TABLE_INDEX_I32:
- case R_WASM_TABLE_INDEX_SLEB: {
+ case R_WASM_TABLE_INDEX_SLEB:
+ case R_WASM_TABLE_INDEX_REL_SLEB: {
FunctionSymbol *Sym = File->getFunctionSymbol(Reloc.Index);
if (Sym->hasTableIndex() || !Sym->hasFunctionIndex())
continue;
Index: lld/test/wasm/shared.ll
===================================================================
--- lld/test/wasm/shared.ll
+++ lld/test/wasm/shared.ll
@@ -32,6 +32,13 @@
ret i8* bitcast (void ()* @func_external to i8*)
}
+define default i8* @get_local_func_address() {
+entry:
+ ; Verify that a function which is otherwise not address taken *is* added to
+ ; the wasm table with referenced via R_WASM_TABLE_INDEX_REL_SLEB
+ ret i8* bitcast (i8* ()* @get_func_address to i8*)
+}
+
declare void @func_external()
; check for dylink section at start
@@ -41,7 +48,7 @@
; CHECK-NEXT: Name: dylink
; CHECK-NEXT: MemorySize: 20
; CHECK-NEXT: MemoryAlignment: 2
-; CHECK-NEXT: TableSize: 2
+; CHECK-NEXT: TableSize: 3
; CHECK-NEXT: TableAlignment: 0
; CHECK-NEXT: Needed: []
; CHECK-NEXT: - Type: TYPE
@@ -61,7 +68,7 @@
; CHECK-NEXT: Table:
; CHECK-NEXT: ElemType: FUNCREF
; CHECK-NEXT: Limits:
-; CHECK-NEXT: Initial: 0x00000002
+; CHECK-NEXT: Initial: 0x00000003
; CHECK-NEXT: - Module: env
; CHECK-NEXT: Field: __stack_pointer
; CHECK-NEXT: Kind: GLOBAL
@@ -106,7 +113,7 @@
; CHECK-NEXT: - Offset:
; CHECK-NEXT: Opcode: GLOBAL_GET
; CHECK-NEXT: Index: 2
-; CHECK-NEXT: Functions: [ 3, 0 ]
+; CHECK-NEXT: Functions: [ 5, 3, 0 ]
; check the generated code in __wasm_call_ctors and __wasm_apply_relocs functions
; TODO(sbc): Disassemble and verify instructions.
@@ -118,7 +125,7 @@
; CHECK-NEXT: Body: 10020B
; CHECK-NEXT: - Index: 2
; CHECK-NEXT: Locals: []
-; CHECK-NEXT: Body: 230141046A230241006A360200230141086A230241016A3602002301410C6A230141006A360200230141106A23033602000B
+; CHECK-NEXT: Body: 230141046A230241016A360200230141086A230241026A3602002301410C6A230141006A360200230141106A23033602000B
; check the data segment initialized with __memory_base global as offset
@@ -129,4 +136,4 @@
; CHECK-NEXT: Offset:
; CHECK-NEXT: Opcode: GLOBAL_GET
; CHECK-NEXT: Index: 1
-; CHECK-NEXT: Content: '0200000000000000010000000000000000000000'
+; CHECK-NEXT: Content: '0200000001000000020000000000000000000000'
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D60296.193811.patch
Type: text/x-patch
Size: 3045 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190405/0b0407a1/attachment.bin>
More information about the llvm-commits
mailing list