; RELOC-NEXT: Index: 0
; RELOC-NEXT: ElemType: FUNCREF
; RELOC-NEXT: Limits:
-; RELOC-NEXT: Initial: 0x3
+; RELOC-NEXT: Initial: 0x7
; RELOC-NEXT: - Type: FUNCTION
; RELOC-NEXT: FunctionTypes: [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
; RELOC-NEXT: 0, 0 ]
--- /dev/null
+; RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown %p/Inputs/start.s -o %t.o
+; RUN: not wasm-ld -o %t.wasm --relocatable --export-table %t.o 2>&1 | FileCheck %s --check-prefix=EXPORT
+; RUN: not wasm-ld -o %t.wasm --relocatable --growable-table %t.o 2>&1 | FileCheck %s --check-prefix=GROWABLE
+
+; EXPORT: error: --relocatable is incompatible with --export-table
+; GROWABLE: error: --relocatable is incompatible with --growable-table
; CHECK-NEXT: - Type: IMPORT
; CHECK-NEXT: Imports:
; CHECK-NEXT: - Module: env
+; CHECK-NEXT: Field: __indirect_function_table
+; CHECK-NEXT: Kind: TABLE
+; CHECK-NEXT: Table:
+; CHECK-NEXT: Index: 0
+; CHECK-NEXT: ElemType: FUNCREF
+; CHECK-NEXT: Limits:
+; CHECK-NEXT: Initial: 0x4
+; CHECK-NEXT: - Module: env
; CHECK-NEXT: Field: puts
; CHECK-NEXT: Kind: FUNCTION
; CHECK-NEXT: SigIndex: 0
; CHECK-NEXT: Field: bar_import
; CHECK-NEXT: Kind: FUNCTION
; CHECK-NEXT: SigIndex: 1
-; CHECK-NEXT: - Module: env
-; CHECK-NEXT: Field: __indirect_function_table
-; CHECK-NEXT: Kind: TABLE
-; CHECK-NEXT: Table:
-; CHECK-NEXT: Index: 0
-; CHECK-NEXT: ElemType: FUNCREF
-; CHECK-NEXT: Limits:
-; CHECK-NEXT: Initial: 0x3
; CHECK-NEXT: - Type: FUNCTION
; CHECK-NEXT: FunctionTypes: [ 2, 1, 1, 2 ]
; CHECK-NEXT: - Type: MEMORY
; RELOC-NEXT: - Type: IMPORT
; RELOC-NEXT: Imports:
; RELOC-NEXT: - Module: env
-; RELOC-NEXT: Field: __stack_pointer
-; RELOC-NEXT: Kind: GLOBAL
-; RELOC-NEXT: GlobalType: I32
-; RELOC-NEXT: GlobalMutable: true
-; RELOC-NEXT: - Module: env
; RELOC-NEXT: Field: __indirect_function_table
; RELOC-NEXT: Kind: TABLE
; RELOC-NEXT: Table:
; RELOC-NEXT: Index: 0
; RELOC-NEXT: ElemType: FUNCREF
; RELOC-NEXT: Limits:
-; RELOC-NEXT: Initial: 0x1
+; RELOC-NEXT: Initial: 0x2
+; RELOC-NEXT: - Module: env
+; RELOC-NEXT: Field: __stack_pointer
+; RELOC-NEXT: Kind: GLOBAL
+; RELOC-NEXT: GlobalType: I32
+; RELOC-NEXT: GlobalMutable: true
; RELOC-NEXT: - Type: FUNCTION
; RELOC-NEXT: FunctionTypes: [ 0, 1, 1, 1, 1, 1 ]
; RELOC-NEXT: - Type: MEMORY
config->importTable = true;
}
+ if (config->relocatable) {
+ if (config->exportTable)
+ error("--relocatable is incompatible with --export-table");
+ if (config->growableTable)
+ error("--relocatable is incompatible with --growable-table");
+ // Ignore any --import-table, as it's redundant.
+ config->importTable = true;
+ }
+
if (config->shared) {
config->importMemory = true;
config->unresolvedSymbols = UnresolvedPolicy::ImportFuncs;
// Do size optimizations: garbage collection
markLive();
- if (!config->relocatable) {
- // Provide the indirect funciton table if needed.
- WasmSym::indirectFunctionTable = resolveIndirectFunctionTable();
+ // Provide the indirect funciton table if needed.
+ WasmSym::indirectFunctionTable = resolveIndirectFunctionTable();
- if (errorCount())
- return;
- }
+ if (errorCount())
+ return;
// Write the result to the file.
writeResult();