[PATCH] D60296: [WebAssembly] Include function in wasm table when used in R_WASM_TABLE_INDEX_REL_SLEB
Phabricator via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 4 17:35:27 PDT 2019
This revision was automatically updated to reflect the committed changes.
Closed by commit rL357737: [WebAssembly] Include function in wasm table when used in… (authored by sbc, committed by ).
Changed prior to commit:
https://reviews.llvm.org/D60296?vs=193811&id=193814#toc
Repository:
rL LLVM
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D60296/new/
https://reviews.llvm.org/D60296
Files:
lld/trunk/test/wasm/shared.ll
lld/trunk/wasm/Writer.cpp
Index: lld/trunk/test/wasm/shared.ll
===================================================================
--- lld/trunk/test/wasm/shared.ll
+++ lld/trunk/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'
Index: lld/trunk/wasm/Writer.cpp
===================================================================
--- lld/trunk/wasm/Writer.cpp
+++ lld/trunk/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;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D60296.193814.patch
Type: text/x-patch
Size: 3081 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190405/42cdb13c/attachment.bin>
More information about the llvm-commits
mailing list