Skip to content

Commit

Permalink
Revert "[WebAssembly] MC layer writes table symbols to object files"
Browse files Browse the repository at this point in the history
This reverts commit d806618.
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
  • Loading branch information
sbc100 committed Jan 26, 2021
1 parent 84c6f32 commit d705c2f
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 71 deletions.
11 changes: 4 additions & 7 deletions llvm/lib/MC/WasmObjectWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -519,13 +519,6 @@ void WasmObjectWriter::recordRelocation(MCAssembler &Asm,
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);
}

Expand Down Expand Up @@ -1678,6 +1671,10 @@ uint64_t WasmObjectWriter::writeOneObject(MCAssembler &Asm,
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;
Expand Down
24 changes: 7 additions & 17 deletions llvm/test/MC/WebAssembly/debug-info.ll
Original file line number Diff line number Diff line change
Expand Up @@ -89,44 +89,44 @@
; 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:]
Expand Down Expand Up @@ -238,16 +238,6 @@
; 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
Expand Down
24 changes: 7 additions & 17 deletions llvm/test/MC/WebAssembly/debug-info64.ll
Original file line number Diff line number Diff line change
Expand Up @@ -89,44 +89,44 @@
; 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: ]
Expand Down Expand Up @@ -238,16 +238,6 @@
; 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
Expand Down
10 changes: 0 additions & 10 deletions llvm/test/MC/WebAssembly/function-alias.ll
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,4 @@ define i8* @func() {
; 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: ]
5 changes: 0 additions & 5 deletions llvm/test/MC/WebAssembly/global-ctor-dtor.ll
Original file line number Diff line number Diff line change
Expand Up @@ -170,11 +170,6 @@ declare void @func3()
; 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
Expand Down
5 changes: 0 additions & 5 deletions llvm/test/MC/WebAssembly/reloc-pic.s
Original file line number Diff line number Diff line change
Expand Up @@ -190,11 +190,6 @@ hidden_func:
# 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
Expand Down
5 changes: 0 additions & 5 deletions llvm/test/MC/WebAssembly/type-index.s
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,4 @@ test0:
# 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: ...
5 changes: 0 additions & 5 deletions llvm/test/MC/WebAssembly/weak-alias.s
Original file line number Diff line number Diff line change
Expand Up @@ -227,11 +227,6 @@ alias_address:
# 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
Expand Down

0 comments on commit d705c2f

Please sign in to comment.