This reverts commit
d806618636f8a82bfc3f620e1fad83af4d2a2575.
Review: https://reviews.llvm.org/D92215
We had issues where older versions of wasm-ld were crashing on object
files containing a table symbol. We decided that the best strategy
going forward is to only generate these symbol if refernece types is
enabled. Without reference types enabled we should never geneate a
table symbol or a TABLE_NUMBER relocation.
This revert is in addition to the one already reverted in
https://reviews.llvm.org/D95005.
The plan is to re-land these in updated form after the llvm 12 branch.
Differential Revision: https://reviews.llvm.org/D95420
Sym->setUndefined();
}
Sym->setUsedInReloc();
- // Any time we have a TABLE_INDEX relocation against a function symbol, we
- // need to ensure that table itself is part of the final output too. In the
- // future we may want to define a new kind of reloc against both the
- // function and the table, so that the linker can see that the function
- // symbol keeps the table alive, but for now manually mark the table as
- // live.
- Sym->setNoStrip();
Asm.registerSymbol(*Sym);
}
WS.setIndex(InvalidIndex);
continue;
}
+ if (WS.isTable() && WS.getName() == "__indirect_function_table") {
+ // For the moment, don't emit table symbols -- wasm-ld can't handle them.
+ continue;
+ }
LLVM_DEBUG(dbgs() << "adding to symtab: " << WS << "\n");
uint32_t Flags = 0;
; CHECK-NEXT: }
; CHECK-NEXT: Section {
; CHECK-NEXT: Type: CUSTOM (0x0)
-; CHECK-NEXT: Size: 95
+; CHECK-NEXT: Size: 91
; CHECK-NEXT: Offset: 731
; CHECK-NEXT: Name: linking
; CHECK-NEXT: }
; CHECK-NEXT: Section {
; CHECK-NEXT: Type: CUSTOM (0x0)
; CHECK-NEXT: Size: 9
-; CHECK-NEXT: Offset: 840
+; CHECK-NEXT: Offset: 836
; CHECK-NEXT: Name: reloc.DATA
; CHECK-NEXT: }
; CHECK-NEXT: Section {
; CHECK-NEXT: Type: CUSTOM (0x0)
; CHECK-NEXT: Size: 61
-; CHECK-NEXT: Offset: 866
+; CHECK-NEXT: Offset: 862
; CHECK-NEXT: Name: reloc..debug_info
; CHECK-NEXT: }
; CHECK-NEXT: Section {
; CHECK-NEXT: Type: CUSTOM (0x0)
; CHECK-NEXT: Size: 6
-; CHECK-NEXT: Offset: 951
+; CHECK-NEXT: Offset: 947
; CHECK-NEXT: Name: reloc..debug_pubnames
; CHECK-NEXT: }
; CHECK-NEXT: Section {
; CHECK-NEXT: Type: CUSTOM (0x0)
; CHECK-NEXT: Size: 6
-; CHECK-NEXT: Offset: 985
+; CHECK-NEXT: Offset: 981
; CHECK-NEXT: Name: reloc..debug_pubtypes
; CHECK-NEXT: }
; CHECK-NEXT: Section {
; CHECK-NEXT: Type: CUSTOM (0x0)
; CHECK-NEXT: Size: 6
-; CHECK-NEXT: Offset: 1019
+; CHECK-NEXT: Offset: 1015
; CHECK-NEXT: Name: reloc..debug_line
; CHECK-NEXT: }
; CHECK-NEXT: Section {
; CHECK-NEXT: Type: CUSTOM (0x0)
; CHECK-NEXT: Size: 77
-; CHECK-NEXT: Offset: 1049
+; CHECK-NEXT: Offset: 1045
; CHECK-NEXT: Name: producers
; CHECK-NEXT: }
; CHECK-NEXT:]
; CHECK-NEXT: ]
; CHECK-NEXT: ElementIndex: 0xC
; CHECK-NEXT: }
-; CHECK-NEXT: Symbol {
-; CHECK-NEXT: Name: __indirect_function_table
-; CHECK-NEXT: Type: TABLE (0x5)
-; CHECK-NEXT: Flags [ (0x90)
-; CHECK-NEXT: NO_STRIP (0x80)
-; CHECK-NEXT: UNDEFINED (0x10)
-; CHECK-NEXT: ]
-; CHECK-NEXT: ImportModule: env
-; CHECK-NEXT: ElementIndex: 0x0
-; CHECK-NEXT: }
; CHECK-NEXT:]
; generated from the following C code using: clang --target=wasm32 -g -O0 -S -emit-llvm test.c
; CHECK-NEXT: }
; CHECK-NEXT: Section {
; CHECK-NEXT: Type: CUSTOM (0x0)
-; CHECK-NEXT: Size: 95
+; CHECK-NEXT: Size: 91
; CHECK-NEXT: Offset: 759
; CHECK-NEXT: Name: linking
; CHECK-NEXT: }
; CHECK-NEXT: Section {
; CHECK-NEXT: Type: CUSTOM (0x0)
; CHECK-NEXT: Size: 9
-; CHECK-NEXT: Offset: 868
+; CHECK-NEXT: Offset: 864
; CHECK-NEXT: Name: reloc.DATA
; CHECK-NEXT: }
; CHECK-NEXT: Section {
; CHECK-NEXT: Type: CUSTOM (0x0)
; CHECK-NEXT: Size: 61
-; CHECK-NEXT: Offset: 894
+; CHECK-NEXT: Offset: 890
; CHECK-NEXT: Name: reloc..debug_info
; CHECK-NEXT: }
; CHECK-NEXT: Section {
; CHECK-NEXT: Type: CUSTOM (0x0)
; CHECK-NEXT: Size: 6
-; CHECK-NEXT: Offset: 979
+; CHECK-NEXT: Offset: 975
; CHECK-NEXT: Name: reloc..debug_pubnames
; CHECK-NEXT: }
; CHECK-NEXT: Section {
; CHECK-NEXT: Type: CUSTOM (0x0)
; CHECK-NEXT: Size: 6
-; CHECK-NEXT: Offset: 1013
+; CHECK-NEXT: Offset: 1009
; CHECK-NEXT: Name: reloc..debug_pubtypes
; CHECK-NEXT: }
; CHECK-NEXT: Section {
; CHECK-NEXT: Type: CUSTOM (0x0)
; CHECK-NEXT: Size: 6
-; CHECK-NEXT: Offset: 1047
+; CHECK-NEXT: Offset: 1043
; CHECK-NEXT: Name: reloc..debug_line
; CHECK-NEXT: }
; CHECK-NEXT: Section {
; CHECK-NEXT: Type: CUSTOM (0x0)
; CHECK-NEXT: Size: 77
-; CHECK-NEXT: Offset: 1077
+; CHECK-NEXT: Offset: 1073
; CHECK-NEXT: Name: producers
; CHECK-NEXT: }
; CHECK-NEXT: ]
; CHECK-NEXT: ]
; CHECK-NEXT: ElementIndex: 0xC
; CHECK-NEXT: }
-; CHECK-NEXT: Symbol {
-; CHECK-NEXT: Name: __indirect_function_table
-; CHECK-NEXT: Type: TABLE (0x5)
-; CHECK-NEXT: Flags [ (0x90)
-; CHECK-NEXT: NO_STRIP (0x80)
-; CHECK-NEXT: UNDEFINED (0x10)
-; CHECK-NEXT: ]
-; CHECK-NEXT: ImportModule: env
-; CHECK-NEXT: ElementIndex: 0x0
-; CHECK-NEXT: }
; CHECK-NEXT: ]
; generated from the following C code using: clang --target=wasm64 -g -O0 -S -emit-llvm test.c
; CHECK-NEXT: ]
; CHECK-NEXT: ElementIndex: 0x0
; CHECK-NEXT: }
-; CHECK-NEXT: Symbol {
-; CHECK-NEXT: Name: __indirect_function_table
-; CHECK-NEXT: Type: TABLE (0x5)
-; CHECK-NEXT: Flags [ (0x90)
-; CHECK-NEXT: NO_STRIP (0x80)
-; CHECK-NEXT: UNDEFINED (0x10)
-; CHECK-NEXT: ]
-; CHECK-NEXT: ImportModule: env
-; CHECK-NEXT: ElementIndex: 0x0
-; CHECK-NEXT: }
; CHECK-NEXT: ]
; CHECK-NEXT: Name: func0
; CHECK-NEXT: Flags: [ UNDEFINED ]
; CHECK-NEXT: Function: 4
-; CHECK-NEXT: - Index: 11
-; CHECK-NEXT: Kind: TABLE
-; CHECK-NEXT: Name: __indirect_function_table
-; CHECK-NEXT: Flags: [ UNDEFINED, NO_STRIP ]
-; CHECK-NEXT: Table: 0
; CHECK-NEXT: SegmentInfo:
; CHECK-NEXT: - Index: 0
; CHECK-NEXT: Name: .data.global1
# CHECK-NEXT: Name: hidden_func
# CHECK-NEXT: Flags: [ BINDING_LOCAL ]
# CHECK-NEXT: Function: 5
-# CHECK-NEXT: - Index: 10
-# CHECK-NEXT: Kind: TABLE
-# CHECK-NEXT: Name: __indirect_function_table
-# CHECK-NEXT: Flags: [ UNDEFINED, NO_STRIP ]
-# CHECK-NEXT: Table: 0
# CHECK-NEXT: SegmentInfo:
# CHECK-NEXT: - Index: 0
# CHECK-NEXT: Name: .rodata.hidden_data
# BIN-NEXT: Name: test0
# BIN-NEXT: Flags: [ BINDING_LOCAL ]
# BIN-NEXT: Function: 0
-# BIN-NEXT: - Index: 1
-# BIN-NEXT: Kind: TABLE
-# BIN-NEXT: Name: __indirect_function_table
-# BIN-NEXT: Flags: [ UNDEFINED, NO_STRIP ]
-# BIN-NEXT: Table: 0
# BIN-NEXT: ...
# CHECK-NEXT: Flags: [ BINDING_WEAK, VISIBILITY_HIDDEN, NO_STRIP ]
# CHECK-NEXT: Segment: 0
# CHECK-NEXT: Size: 4
-# CHECK-NEXT: - Index: 10
-# CHECK-NEXT: Kind: TABLE
-# CHECK-NEXT: Name: __indirect_function_table
-# CHECK-NEXT: Flags: [ UNDEFINED, NO_STRIP ]
-# CHECK-NEXT: Table: 0
# CHECK-NEXT: SegmentInfo:
# CHECK-NEXT: - Index: 0
# CHECK-NEXT: Name: .data.bar