[llvm-branch-commits] [llvm] e65b9b0 - Revert "[WebAssembly] MC layer writes table symbols to object files"
Author: Derek Schuff Date: 2021-01-15T15:50:22-08:00 New Revision: e65b9b04cdeff17fbcdae8d2bb268da832e4a267 URL: https://github.com/llvm/llvm-project/commit/e65b9b04cdeff17fbcdae8d2bb268da832e4a267 DIFF: https://github.com/llvm/llvm-project/commit/e65b9b04cdeff17fbcdae8d2bb268da832e4a267.diff LOG: Revert "[WebAssembly] MC layer writes table symbols to object files" This reverts commit e9f1ed2306b1b3aedcb1acef2b50e252a77a04b9. Reverting because it depends on 38dfce706f Added: Modified: llvm/lib/MC/WasmObjectWriter.cpp llvm/test/MC/WebAssembly/debug-info.ll llvm/test/MC/WebAssembly/debug-info64.ll llvm/test/MC/WebAssembly/function-alias.ll llvm/test/MC/WebAssembly/global-ctor-dtor.ll llvm/test/MC/WebAssembly/reloc-pic.s llvm/test/MC/WebAssembly/type-index.s llvm/test/MC/WebAssembly/weak-alias.s Removed: diff --git a/llvm/lib/MC/WasmObjectWriter.cpp b/llvm/lib/MC/WasmObjectWriter.cpp index b2d94dcadd81..fb41c3763c15 100644 --- a/llvm/lib/MC/WasmObjectWriter.cpp +++ b/llvm/lib/MC/WasmObjectWriter.cpp @@ -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); } @@ -1677,6 +1670,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; diff --git a/llvm/test/MC/WebAssembly/debug-info.ll b/llvm/test/MC/WebAssembly/debug-info.ll index 88d19d9191a9..167d912c84a2 100644 --- a/llvm/test/MC/WebAssembly/debug-info.ll +++ b/llvm/test/MC/WebAssembly/debug-info.ll @@ -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:] @@ -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 diff --git a/llvm/test/MC/WebAssembly/debug-info64.ll b/llvm/test/MC/WebAssembly/debug-info64.ll index 1755f2b7ef5c..acba8aa27360 100644 --- a/llvm/test/MC/WebAssembly/debug-info64.ll +++ b/llvm/test/MC/WebAssembly/debug-info64.ll @@ -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: S
[llvm-branch-commits] [lld] 187d771 - Revert "[WebAssembly] Add support for table linking to wasm-ld"
Author: Derek Schuff Date: 2021-01-15T15:50:41-08:00 New Revision: 187d771d27ed9059675b53e92e8fb8aeee9c43d8 URL: https://github.com/llvm/llvm-project/commit/187d771d27ed9059675b53e92e8fb8aeee9c43d8 DIFF: https://github.com/llvm/llvm-project/commit/187d771d27ed9059675b53e92e8fb8aeee9c43d8.diff LOG: Revert "[WebAssembly] Add support for table linking to wasm-ld" This reverts commit 38dfce706f796dc109ea495dd69a8cb4c8fa819d. CI discovered a bug where the table is exported twice: see D91870 Added: Modified: lld/test/wasm/alias.s lld/test/wasm/init-fini.ll lld/test/wasm/local-symbols.ll lld/test/wasm/locals-duplicate.test lld/test/wasm/pie.ll lld/test/wasm/section-symbol-relocs.yaml lld/test/wasm/shared.ll lld/test/wasm/signature-mismatch.ll lld/test/wasm/stack-pointer.ll lld/test/wasm/weak-alias.ll lld/wasm/Driver.cpp lld/wasm/InputFiles.cpp lld/wasm/InputFiles.h lld/wasm/MarkLive.cpp lld/wasm/SymbolTable.cpp lld/wasm/SymbolTable.h lld/wasm/Symbols.cpp lld/wasm/Symbols.h lld/wasm/SyntheticSections.cpp lld/wasm/SyntheticSections.h lld/wasm/Writer.cpp Removed: diff --git a/lld/test/wasm/alias.s b/lld/test/wasm/alias.s index b2ab45e98d95..6c99f69da8b8 100644 --- a/lld/test/wasm/alias.s +++ b/lld/test/wasm/alias.s @@ -22,6 +22,14 @@ _start: # CHECK-NEXT: ReturnTypes: [] # CHECK-NEXT: - Type:FUNCTION # CHECK-NEXT: FunctionTypes: [ 0 ] +# CHECK-NEXT: - Type:TABLE +# CHECK-NEXT: Tables: +# CHECK-NEXT: - Index: 0 +# CHECK-NEXT: ElemType:FUNCREF +# CHECK-NEXT: Limits: +# CHECK-NEXT: Flags: [ HAS_MAX ] +# CHECK-NEXT: Initial: 0x1 +# CHECK-NEXT: Maximum: 0x1 # CHECK-NEXT: - Type:MEMORY # CHECK-NEXT: Memories: # CHECK-NEXT: - Initial: 0x2 diff --git a/lld/test/wasm/init-fini.ll b/lld/test/wasm/init-fini.ll index 5631d58d68e5..1e7644bc6d35 100644 --- a/lld/test/wasm/init-fini.ll +++ b/lld/test/wasm/init-fini.ll @@ -139,15 +139,15 @@ entry: ; RELOC-NEXT: InitFunctions [ ; RELOC-NEXT:0 (priority=101) ; RELOC-NEXT:1 (priority=101) -; RELOC-NEXT:15 (priority=101) -; RELOC-NEXT:11 (priority=101) -; RELOC-NEXT:21 (priority=101) -; RELOC-NEXT:11 (priority=202) -; RELOC-NEXT:23 (priority=202) +; RELOC-NEXT:14 (priority=101) +; RELOC-NEXT:10 (priority=101) +; RELOC-NEXT:20 (priority=101) +; RELOC-NEXT:10 (priority=202) +; RELOC-NEXT:22 (priority=202) ; RELOC-NEXT:0 (priority=1001) -; RELOC-NEXT:17 (priority=1001) -; RELOC-NEXT:11 (priority=2002) -; RELOC-NEXT:25 (priority=2002) +; RELOC-NEXT:16 (priority=1001) +; RELOC-NEXT:10 (priority=2002) +; RELOC-NEXT:24 (priority=2002) ; RELOC-NEXT:9 (priority=4000) -; RELOC-NEXT:19 (priority=4000) +; RELOC-NEXT:18 (priority=4000) ; RELOC-NEXT: ] diff --git a/lld/test/wasm/local-symbols.ll b/lld/test/wasm/local-symbols.ll index 216aced9cf07..13c200d648e9 100644 --- a/lld/test/wasm/local-symbols.ll +++ b/lld/test/wasm/local-symbols.ll @@ -35,6 +35,14 @@ entry: ; CHECK-NEXT: ReturnTypes: [] ; CHECK-NEXT: - Type:FUNCTION ; CHECK-NEXT: FunctionTypes: [ 0, 1 ] +; CHECK-NEXT: - Type:TABLE +; CHECK-NEXT: Tables: +; CHECK-NEXT: - Index: 0 +; CHECK-NEXT: ElemType:FUNCREF +; CHECK-NEXT: Limits: +; CHECK-NEXT: Flags: [ HAS_MAX ] +; CHECK-NEXT: Initial: 0x1 +; CHECK-NEXT: Maximum: 0x1 ; CHECK-NEXT: - Type:MEMORY ; CHECK-NEXT: Memories: ; CHECK-NEXT: - Initial: 0x2 diff --git a/lld/test/wasm/locals-duplicate.test b/lld/test/wasm/locals-duplicate.test index cf9a148d4ab7..07abb7485381 100644 --- a/lld/test/wasm/locals-duplicate.test +++ b/lld/test/wasm/locals-duplicate.test @@ -254,40 +254,40 @@ ; RELOC-NEXT: - Type:CODE ; RELOC-NEXT: Relocations: ; RELOC-NEXT: - Type:R_WASM_MEMORY_ADDR_SLEB -; RELOC-NEXT: Index: 19 +; RELOC-NEXT: Index: 18 ; RELOC-NEXT: Offset: 0x13 ; RELOC-NEXT: - Type:R_WASM_MEMORY_ADDR_SLEB ; RELOC-NEXT: Index: 3 ; RELOC-NEXT: Offset: 0x1C ; RELOC-NEXT: - Type:R_WASM_MEMORY_ADDR_SLEB -; RELOC-NEXT: Index: 20 +; RELOC-NEXT: Index: 19 ; RELOC-NEXT: Offset: 0x25 ; RELOC-NEXT: - Type:R_WASM_TABLE_INDEX_SLEB -; RELOC-NEXT: Index: 17 +; RELOC-NEXT: Index: 16 ; RELOC-NEXT: Offset: 0x2E ; RELOC-NEXT: - Type:R_WASM_TABLE_INDEX_SLEB ; RELOC
[llvm-branch-commits] [lld] cb77e87 - [WebAssembly][lld] Don't mark a file live from an undefine symbol
Author: Derek Schuff Date: 2020-12-17T11:05:36-08:00 New Revision: cb77e877f8132b885fcac8b7532c58072537b9ed URL: https://github.com/llvm/llvm-project/commit/cb77e877f8132b885fcac8b7532c58072537b9ed DIFF: https://github.com/llvm/llvm-project/commit/cb77e877f8132b885fcac8b7532c58072537b9ed.diff LOG: [WebAssembly][lld] Don't mark a file live from an undefine symbol Live symbols should only cause the files in which they are defined to become live. For now this is only tested in emscripten: we're continuing to work on reducing the test case further for an lld-style unit test. Differential Revision: https://reviews.llvm.org/D93472 Added: Modified: lld/wasm/Symbols.cpp Removed: diff --git a/lld/wasm/Symbols.cpp b/lld/wasm/Symbols.cpp index 9e41f7c6281d..aa3b6be8a9b8 100644 --- a/lld/wasm/Symbols.cpp +++ b/lld/wasm/Symbols.cpp @@ -137,7 +137,7 @@ bool Symbol::isLive() const { void Symbol::markLive() { assert(!isDiscarded()); - if (file != NULL) + if (file != NULL && isDefined()) file->markLive(); if (auto *g = dyn_cast(this)) g->global->live = true; ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [lld] cb77e87 - [WebAssembly][lld] Don't mark a file live from an undefine symbol
Author: Derek Schuff Date: 2020-12-17T11:05:36-08:00 New Revision: cb77e877f8132b885fcac8b7532c58072537b9ed URL: https://github.com/llvm/llvm-project/commit/cb77e877f8132b885fcac8b7532c58072537b9ed DIFF: https://github.com/llvm/llvm-project/commit/cb77e877f8132b885fcac8b7532c58072537b9ed.diff LOG: [WebAssembly][lld] Don't mark a file live from an undefine symbol Live symbols should only cause the files in which they are defined to become live. For now this is only tested in emscripten: we're continuing to work on reducing the test case further for an lld-style unit test. Differential Revision: https://reviews.llvm.org/D93472 Added: Modified: lld/wasm/Symbols.cpp Removed: diff --git a/lld/wasm/Symbols.cpp b/lld/wasm/Symbols.cpp index 9e41f7c6281d..aa3b6be8a9b8 100644 --- a/lld/wasm/Symbols.cpp +++ b/lld/wasm/Symbols.cpp @@ -137,7 +137,7 @@ bool Symbol::isLive() const { void Symbol::markLive() { assert(!isDiscarded()); - if (file != NULL) + if (file != NULL && isDefined()) file->markLive(); if (auto *g = dyn_cast(this)) g->global->live = true; ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [lld] 8b8088a - [lld] Use -1 as tombstone value for discarded code ranges
Author: Eric Leese Date: 2020-12-01T17:06:32-08:00 New Revision: 8b8088ac6ca977fbce52abd50ac88ecbe08d9cb2 URL: https://github.com/llvm/llvm-project/commit/8b8088ac6ca977fbce52abd50ac88ecbe08d9cb2 DIFF: https://github.com/llvm/llvm-project/commit/8b8088ac6ca977fbce52abd50ac88ecbe08d9cb2.diff LOG: [lld] Use -1 as tombstone value for discarded code ranges Under existing behavior discarded functions are relocated to have the start pc 0. This causes problems when debugging as they typically overlap the first function and lldb symbol resolution frequently chooses a discarded function instead of the correct one. Using the value -1 or -2 (depending on which DWARF section we are writing) is sufficient to prevent lldb from resolving to these symbols. Reviewed By: MaskRay, yurydelendik, sbc100 Differential Revision: https://reviews.llvm.org/D91803 Added: Modified: lld/test/wasm/debug-removed-fn.ll lld/test/wasm/debuginfo.test lld/wasm/InputChunks.cpp lld/wasm/InputChunks.h lld/wasm/InputFiles.cpp lld/wasm/InputFiles.h Removed: diff --git a/lld/test/wasm/debug-removed-fn.ll b/lld/test/wasm/debug-removed-fn.ll index 89a55a3d4187..9d2c5dc107de 100644 --- a/lld/test/wasm/debug-removed-fn.ll +++ b/lld/test/wasm/debug-removed-fn.ll @@ -4,11 +4,12 @@ ; CHECK: Address ; CHECK: 0x0005 -; CHECK: 0x +; CHECK-NEXT: 0x0006 +; CHECK-EMPTY: ; CHECK: .debug_ranges contents: ; CHECK: {{[0-9]+}} {{[0-9]+}} -; CHECK: {{[0-9]+}} {{[0-9]+}} +; CHECK: fffe fffe ; CHECK: ; ModuleID = 't.bc' diff --git a/lld/test/wasm/debuginfo.test b/lld/test/wasm/debuginfo.test index 2566b74d93bf..94d183a3c1d4 100644 --- a/lld/test/wasm/debuginfo.test +++ b/lld/test/wasm/debuginfo.test @@ -71,7 +71,7 @@ CHECK-NEXT:DW_AT_type (0x00a7 "int[2]") CHECK-NEXT:DW_AT_external (true) CHECK-NEXT:DW_AT_decl_file ("{{.*}}hi_foo.c") CHECK-NEXT:DW_AT_decl_line (8) -CHECK-NEXT:DW_AT_location (DW_OP_addr 0x0) +CHECK-NEXT:DW_AT_location (DW_OP_addr 0x) CHECK: DW_TAG_subprogram CHECK-NEXT:DW_AT_low_pc diff --git a/lld/wasm/InputChunks.cpp b/lld/wasm/InputChunks.cpp index 06a734b69a97..52d19e6ddc10 100644 --- a/lld/wasm/InputChunks.cpp +++ b/lld/wasm/InputChunks.cpp @@ -134,10 +134,11 @@ void InputChunk::writeTo(uint8_t *buf) const { LLVM_DEBUG(dbgs() << "applying relocations: " << toString(this) << " count=" << relocations.size() << "\n"); int32_t off = outputOffset - getInputSectionOffset(); + auto tombstone = getTombstone(); for (const WasmRelocation &rel : relocations) { uint8_t *loc = buf + rel.Offset + off; -auto value = file->calcNewValue(rel); +auto value = file->calcNewValue(rel, tombstone); LLVM_DEBUG(dbgs() << "apply reloc: type=" << relocTypeToString(rel.Type)); if (rel.Type != R_WASM_TYPE_INDEX_LEB) LLVM_DEBUG(dbgs() << " sym=" << file->getSymbols()[rel.Index]->getName()); @@ -291,11 +292,13 @@ void InputFunction::calculateSize() { uint32_t start = getInputSectionOffset(); uint32_t end = start + function->Size; + auto tombstone = getTombstone(); + uint32_t lastRelocEnd = start + functionSizeLength; for (const WasmRelocation &rel : relocations) { LLVM_DEBUG(dbgs() << " region: " << (rel.Offset - lastRelocEnd) << "\n"); compressedFuncSize += rel.Offset - lastRelocEnd; -compressedFuncSize += getRelocWidth(rel, file->calcNewValue(rel)); +compressedFuncSize += getRelocWidth(rel, file->calcNewValue(rel, tombstone)); lastRelocEnd = rel.Offset + getRelocWidthPadded(rel); } LLVM_DEBUG(dbgs() << " final region: " << (end - lastRelocEnd) << "\n"); @@ -323,6 +326,7 @@ void InputFunction::writeTo(uint8_t *buf) const { const uint8_t *secStart = file->codeSection->Content.data(); const uint8_t *funcStart = secStart + getInputSectionOffset(); const uint8_t *end = funcStart + function->Size; + auto tombstone = getTombstone(); uint32_t count; decodeULEB128(funcStart, &count); funcStart += count; @@ -335,7 +339,7 @@ void InputFunction::writeTo(uint8_t *buf) const { LLVM_DEBUG(dbgs() << " write chunk: " << chunkSize << "\n"); memcpy(buf, lastRelocEnd, chunkSize); buf += chunkSize; -buf += writeCompressedReloc(buf, rel, file->calcNewValue(rel)); +buf += writeCompressedReloc(buf, rel, file->calcNewValue(rel, tombstone)); lastRelocEnd = secStart + rel.Offset + getRelocWidthPadded(rel); } @@ -359,6 +363,7 @@ void InputSegment::generateRelocationCode(raw_ostream &os) const { ? WASM_OPCODE_I64_ADD : WASM_OPCODE_I32_ADD; + auto tombstone = getTombstone(); // TODO(sbc): Enc
[llvm-branch-commits] [llvm] 0a39106 - [WebAssembly] Add Object and ObjectWriter support for wasm COMDAT sections
Author: Derek Schuff Date: 2020-12-07T12:12:44-08:00 New Revision: 0a391060f16dc3e10bcb0b02036073021c414006 URL: https://github.com/llvm/llvm-project/commit/0a391060f16dc3e10bcb0b02036073021c414006 DIFF: https://github.com/llvm/llvm-project/commit/0a391060f16dc3e10bcb0b02036073021c414006.diff LOG: [WebAssembly] Add Object and ObjectWriter support for wasm COMDAT sections Allow sections to be placed into COMDAT groups, in addtion to functions and data segments. Also make section symbols unnamed, which allows sections with identical names (section names are independent of their section symbols, but previously we gave the symbols the same name as their sections, which results in collisions when sections are identically-named). Differential Revision: https://reviews.llvm.org/D92691 Added: llvm/test/MC/WebAssembly/comdat-sections.ll Modified: llvm/include/llvm/BinaryFormat/Wasm.h llvm/include/llvm/Object/Wasm.h llvm/lib/MC/MCContext.cpp llvm/lib/MC/MCObjectFileInfo.cpp llvm/lib/MC/WasmObjectWriter.cpp llvm/lib/Object/WasmObjectFile.cpp llvm/lib/ObjectYAML/WasmYAML.cpp llvm/test/DebugInfo/WebAssembly/dwarf-headers.ll llvm/tools/obj2yaml/wasm2yaml.cpp Removed: diff --git a/llvm/include/llvm/BinaryFormat/Wasm.h b/llvm/include/llvm/BinaryFormat/Wasm.h index d93587593ac3..760ddf5a2368 100644 --- a/llvm/include/llvm/BinaryFormat/Wasm.h +++ b/llvm/include/llvm/BinaryFormat/Wasm.h @@ -330,6 +330,8 @@ enum : unsigned { enum : unsigned { WASM_COMDAT_DATA = 0x0, WASM_COMDAT_FUNCTION = 0x1, + // GLOBAL, EVENT, and TABLE are in here but LLVM doesn't use them yet. + WASM_COMDAT_SECTION = 0x5, }; // Kind codes used in the custom "linking" section in the WASM_SYMBOL_TABLE diff --git a/llvm/include/llvm/Object/Wasm.h b/llvm/include/llvm/Object/Wasm.h index e5091f5a8552..089046d7d42f 100644 --- a/llvm/include/llvm/Object/Wasm.h +++ b/llvm/include/llvm/Object/Wasm.h @@ -108,6 +108,7 @@ struct WasmSection { uint32_t Type = 0; // Section type (See below) uint32_t Offset = 0; // Offset with in the file StringRef Name;// Section name (User-defined sections only) + uint32_t Comdat = UINT32_MAX; // From the "comdat info" section ArrayRef Content; // Section content std::vector Relocations; // Relocations for this section }; diff --git a/llvm/lib/MC/MCContext.cpp b/llvm/lib/MC/MCContext.cpp index 8b2925157ba5..fe84283a9112 100644 --- a/llvm/lib/MC/MCContext.cpp +++ b/llvm/lib/MC/MCContext.cpp @@ -644,7 +644,7 @@ MCSectionWasm *MCContext::getWasmSection(const Twine &Section, SectionKind Kind, StringRef CachedName = Entry.first.SectionName; - MCSymbol *Begin = createSymbol(CachedName, false, false); + MCSymbol *Begin = createSymbol(CachedName, true, false); cast(Begin)->setType(wasm::WASM_SYMBOL_TYPE_SECTION); MCSectionWasm *Result = new (WasmAllocator.Allocate()) diff --git a/llvm/lib/MC/MCObjectFileInfo.cpp b/llvm/lib/MC/MCObjectFileInfo.cpp index a67e4b33a33b..af1d7c099668 100644 --- a/llvm/lib/MC/MCObjectFileInfo.cpp +++ b/llvm/lib/MC/MCObjectFileInfo.cpp @@ -974,9 +974,6 @@ MCSection *MCObjectFileInfo::getDwarfComdatSection(const char *Name, return Ctx->getELFSection(Name, ELF::SHT_PROGBITS, ELF::SHF_GROUP, 0, utostr(Hash)); case Triple::Wasm: -// FIXME: When using dwarf 5, the .debug_info section is used for type units -// but that section already exists, so attempting to get it as a comdate -// section triggers an assert. return Ctx->getWasmSection(Name, SectionKind::getMetadata(), utostr(Hash), MCContext::GenericSectionID); case Triple::MachO: diff --git a/llvm/lib/MC/WasmObjectWriter.cpp b/llvm/lib/MC/WasmObjectWriter.cpp index 211f0de3d242..77df4acfe11a 100644 --- a/llvm/lib/MC/WasmObjectWriter.cpp +++ b/llvm/lib/MC/WasmObjectWriter.cpp @@ -1421,6 +1421,16 @@ uint64_t WasmObjectWriter::writeOneObject(MCAssembler &Asm, continue; } + // Custom sections can also belong to COMDAT groups. In this case the + // decriptor's "index" field is the section index (in the final object + // file), but that is not known until after layout, so it must be fixed up + // later + if (const MCSymbolWasm *C = Section.getGroup()) { +Comdats[C->getName()].emplace_back( +WasmComdatEntry{wasm::WASM_COMDAT_SECTION, +static_cast(CustomSections.size())}); + } + CustomSections.emplace_back(Name, &Section); } } @@ -1799,9 +1809,17 @@ uint64_t WasmObjectWriter::writeOneObject(MCAssembler &Asm, DataSectionIndex = writeDataSection(Layout); } - for (auto &CustomSection : CustomSections) { -writeCustomSection(CustomSection, Asm, Layout); + // The Sections in the COMDAT list have placeholder indices (their index among +
[llvm-branch-commits] [llvm] 4564553 - [WebAssembly] Support COMDAT sections in assembly syntax
Author: Derek Schuff Date: 2020-12-10T14:46:24-08:00 New Revision: 4564553b8d8ab81dc21431a35275581cb42329c8 URL: https://github.com/llvm/llvm-project/commit/4564553b8d8ab81dc21431a35275581cb42329c8 DIFF: https://github.com/llvm/llvm-project/commit/4564553b8d8ab81dc21431a35275581cb42329c8.diff LOG: [WebAssembly] Support COMDAT sections in assembly syntax This CL changes the asm syntax for section flags, making them more like ELF (previously "passive" was the only option). Now we also allow "G" to designate COMDAT group sections. In these sections we set the appropriate comdat flag on function symbols, and also avoid auto-creating a new section for them. This also adds asm-based tests for the changes D92691 to go along with the direct-to-object tests. Differential Revision: https://reviews.llvm.org/D92952 Added: llvm/test/MC/WebAssembly/comdat-sections.s Modified: llvm/lib/MC/MCParser/WasmAsmParser.cpp llvm/lib/MC/MCSectionWasm.cpp llvm/lib/MC/WasmObjectWriter.cpp llvm/lib/Target/WebAssembly/AsmParser/WebAssemblyAsmParser.cpp llvm/test/MC/WebAssembly/comdat-sections.ll llvm/test/MC/WebAssembly/comdat.ll Removed: diff --git a/llvm/lib/MC/MCParser/WasmAsmParser.cpp b/llvm/lib/MC/MCParser/WasmAsmParser.cpp index c8f9807d0c54..0c255ef02d2a 100644 --- a/llvm/lib/MC/MCParser/WasmAsmParser.cpp +++ b/llvm/lib/MC/MCParser/WasmAsmParser.cpp @@ -90,15 +90,40 @@ class WasmAsmParser : public MCAsmParserExtension { return false; } - bool parseSectionFlags(StringRef FlagStr, bool &Passive) { -SmallVector Flags; -// If there are no flags, keep Flags empty -FlagStr.split(Flags, ",", -1, false); -for (auto &Flag : Flags) { - if (Flag == "passive") + bool parseSectionFlags(StringRef FlagStr, bool &Passive, bool &Group) { +for (char C : FlagStr) { + switch (C) { + case 'p': Passive = true; - else -return error("Expected section flags, instead got: ", Lexer->getTok()); +break; + case 'G': +Group = true; +break; + default: +return Parser->Error(getTok().getLoc(), + StringRef("Unexepcted section flag: ") + FlagStr); + } +} +return false; + } + + bool parseGroup(StringRef &GroupName) { +if (Lexer->isNot(AsmToken::Comma)) + return TokError("expected group name"); +Lex(); +if (Lexer->is(AsmToken::Integer)) { + GroupName = getTok().getString(); + Lex(); +} else if (Parser->parseIdentifier(GroupName)) { + return TokError("invalid group name"); +} +if (Lexer->is(AsmToken::Comma)) { + Lex(); + StringRef Linkage; + if (Parser->parseIdentifier(Linkage)) +return TokError("invalid linkage"); + if (Linkage != "comdat") +return TokError("Linkage must be 'comdat'"); } return false; } @@ -130,27 +155,34 @@ class WasmAsmParser : public MCAsmParserExtension { if (!Kind.hasValue()) return Parser->Error(Lexer->getLoc(), "unknown section kind: " + Name); -MCSectionWasm *Section = getContext().getWasmSection(Name, Kind.getValue()); // Update section flags if present in this .section directive bool Passive = false; -if (parseSectionFlags(getTok().getStringContents(), Passive)) +bool Group = false; +if (parseSectionFlags(getTok().getStringContents(), Passive, Group)) return true; -if (Passive) { - if (!Section->isWasmData()) -return Parser->Error(getTok().getLoc(), - "Only data sections can be passive"); - Section->setPassive(); -} - Lex(); -if (expect(AsmToken::Comma, ",") || expect(AsmToken::At, "@") || -expect(AsmToken::EndOfStatement, "eol")) +if (expect(AsmToken::Comma, ",") || expect(AsmToken::At, "@")) + return true; + +StringRef GroupName; +if (Group && parseGroup(GroupName)) + return true; + +if (expect(AsmToken::EndOfStatement, "eol")) return true; -auto WS = getContext().getWasmSection(Name, Kind.getValue()); +// TODO: Parse UniqueID +MCSectionWasm *WS = getContext().getWasmSection( +Name, Kind.getValue(), GroupName, MCContext::GenericSectionID); +if (Passive) { + if (!WS->isWasmData()) +return Parser->Error(getTok().getLoc(), + "Only data sections can be passive"); + WS->setPassive(); +} getStreamer().SwitchSection(WS); return false; } @@ -189,9 +221,13 @@ class WasmAsmParser : public MCAsmParserExtension { Lexer->is(AsmToken::Identifier))) return error("Expected label,@type declaration, got: ", Lexer->getTok()); auto TypeName = Lexer->getTok().getString(); -if (TypeName == "function") +if (TypeName == "function") { WasmSym->setType(wasm::WASM_SYMBOL_TYPE_FUNCTION); -else if (TypeName =
[llvm-branch-commits] [llvm] dd1aa4f - Revert "[WebAssembly] Support COMDAT sections in assembly syntax"
Author: Derek Schuff Date: 2020-12-10T15:55:33-08:00 New Revision: dd1aa4fdd82bc4b33e9661eda6039760408501d9 URL: https://github.com/llvm/llvm-project/commit/dd1aa4fdd82bc4b33e9661eda6039760408501d9 DIFF: https://github.com/llvm/llvm-project/commit/dd1aa4fdd82bc4b33e9661eda6039760408501d9.diff LOG: Revert "[WebAssembly] Support COMDAT sections in assembly syntax" This reverts commit 4564553b8d8ab81dc21431a35275581cb42329c8. It broke several buildbots. Added: Modified: llvm/lib/MC/MCParser/WasmAsmParser.cpp llvm/lib/MC/MCSectionWasm.cpp llvm/lib/MC/WasmObjectWriter.cpp llvm/lib/Target/WebAssembly/AsmParser/WebAssemblyAsmParser.cpp llvm/test/MC/WebAssembly/comdat-sections.ll llvm/test/MC/WebAssembly/comdat.ll Removed: llvm/test/MC/WebAssembly/comdat-sections.s diff --git a/llvm/lib/MC/MCParser/WasmAsmParser.cpp b/llvm/lib/MC/MCParser/WasmAsmParser.cpp index 0c255ef02d2a..c8f9807d0c54 100644 --- a/llvm/lib/MC/MCParser/WasmAsmParser.cpp +++ b/llvm/lib/MC/MCParser/WasmAsmParser.cpp @@ -90,40 +90,15 @@ class WasmAsmParser : public MCAsmParserExtension { return false; } - bool parseSectionFlags(StringRef FlagStr, bool &Passive, bool &Group) { -for (char C : FlagStr) { - switch (C) { - case 'p': + bool parseSectionFlags(StringRef FlagStr, bool &Passive) { +SmallVector Flags; +// If there are no flags, keep Flags empty +FlagStr.split(Flags, ",", -1, false); +for (auto &Flag : Flags) { + if (Flag == "passive") Passive = true; -break; - case 'G': -Group = true; -break; - default: -return Parser->Error(getTok().getLoc(), - StringRef("Unexepcted section flag: ") + FlagStr); - } -} -return false; - } - - bool parseGroup(StringRef &GroupName) { -if (Lexer->isNot(AsmToken::Comma)) - return TokError("expected group name"); -Lex(); -if (Lexer->is(AsmToken::Integer)) { - GroupName = getTok().getString(); - Lex(); -} else if (Parser->parseIdentifier(GroupName)) { - return TokError("invalid group name"); -} -if (Lexer->is(AsmToken::Comma)) { - Lex(); - StringRef Linkage; - if (Parser->parseIdentifier(Linkage)) -return TokError("invalid linkage"); - if (Linkage != "comdat") -return TokError("Linkage must be 'comdat'"); + else +return error("Expected section flags, instead got: ", Lexer->getTok()); } return false; } @@ -155,34 +130,27 @@ class WasmAsmParser : public MCAsmParserExtension { if (!Kind.hasValue()) return Parser->Error(Lexer->getLoc(), "unknown section kind: " + Name); +MCSectionWasm *Section = getContext().getWasmSection(Name, Kind.getValue()); // Update section flags if present in this .section directive bool Passive = false; -bool Group = false; -if (parseSectionFlags(getTok().getStringContents(), Passive, Group)) - return true; - -Lex(); - -if (expect(AsmToken::Comma, ",") || expect(AsmToken::At, "@")) - return true; - -StringRef GroupName; -if (Group && parseGroup(GroupName)) - return true; - -if (expect(AsmToken::EndOfStatement, "eol")) +if (parseSectionFlags(getTok().getStringContents(), Passive)) return true; -// TODO: Parse UniqueID -MCSectionWasm *WS = getContext().getWasmSection( -Name, Kind.getValue(), GroupName, MCContext::GenericSectionID); if (Passive) { - if (!WS->isWasmData()) + if (!Section->isWasmData()) return Parser->Error(getTok().getLoc(), "Only data sections can be passive"); - WS->setPassive(); + Section->setPassive(); } + +Lex(); + +if (expect(AsmToken::Comma, ",") || expect(AsmToken::At, "@") || +expect(AsmToken::EndOfStatement, "eol")) + return true; + +auto WS = getContext().getWasmSection(Name, Kind.getValue()); getStreamer().SwitchSection(WS); return false; } @@ -221,13 +189,9 @@ class WasmAsmParser : public MCAsmParserExtension { Lexer->is(AsmToken::Identifier))) return error("Expected label,@type declaration, got: ", Lexer->getTok()); auto TypeName = Lexer->getTok().getString(); -if (TypeName == "function") { +if (TypeName == "function") WasmSym->setType(wasm::WASM_SYMBOL_TYPE_FUNCTION); - auto *Current = - cast(getStreamer().getCurrentSection().first); - if (Current->getGroup()) -WasmSym->setComdat(true); -} else if (TypeName == "global") +else if (TypeName == "global") WasmSym->setType(wasm::WASM_SYMBOL_TYPE_GLOBAL); else if (TypeName == "object") WasmSym->setType(wasm::WASM_SYMBOL_TYPE_DATA); diff --git a/llvm/lib/MC/MCSectionWasm.cpp b/llvm/lib/MC/MCSectionWasm.cpp index 81dc4329be6a..27ed51802a2e 100644 --- a/llv
[llvm-branch-commits] [llvm] 8d396ac - [WebAssembly] Support COMDAT sections in assembly syntax
Author: Derek Schuff Date: 2020-12-10T16:43:59-08:00 New Revision: 8d396acac3bc21f688ac707bb42e4698dbdcab7e URL: https://github.com/llvm/llvm-project/commit/8d396acac3bc21f688ac707bb42e4698dbdcab7e DIFF: https://github.com/llvm/llvm-project/commit/8d396acac3bc21f688ac707bb42e4698dbdcab7e.diff LOG: [WebAssembly] Support COMDAT sections in assembly syntax This CL changes the asm syntax for section flags, making them more like ELF (previously "passive" was the only option). Now we also allow "G" to designate COMDAT group sections. In these sections we set the appropriate comdat flag on function symbols, and also avoid auto-creating a new section for them. This also adds asm-based tests for the changes D92691 to go along with the direct-to-object tests. Differential Revision: https://reviews.llvm.org/D92952 This is a reland of rG4564553b8d8a with a fix to the lit pipeline in llvm/test/MC/WebAssembly/comdat.ll Added: llvm/test/MC/WebAssembly/comdat-sections.s Modified: llvm/lib/MC/MCParser/WasmAsmParser.cpp llvm/lib/MC/MCSectionWasm.cpp llvm/lib/MC/WasmObjectWriter.cpp llvm/lib/Target/WebAssembly/AsmParser/WebAssemblyAsmParser.cpp llvm/test/MC/WebAssembly/comdat-sections.ll llvm/test/MC/WebAssembly/comdat.ll Removed: diff --git a/llvm/lib/MC/MCParser/WasmAsmParser.cpp b/llvm/lib/MC/MCParser/WasmAsmParser.cpp index c8f9807d0c54..0c255ef02d2a 100644 --- a/llvm/lib/MC/MCParser/WasmAsmParser.cpp +++ b/llvm/lib/MC/MCParser/WasmAsmParser.cpp @@ -90,15 +90,40 @@ class WasmAsmParser : public MCAsmParserExtension { return false; } - bool parseSectionFlags(StringRef FlagStr, bool &Passive) { -SmallVector Flags; -// If there are no flags, keep Flags empty -FlagStr.split(Flags, ",", -1, false); -for (auto &Flag : Flags) { - if (Flag == "passive") + bool parseSectionFlags(StringRef FlagStr, bool &Passive, bool &Group) { +for (char C : FlagStr) { + switch (C) { + case 'p': Passive = true; - else -return error("Expected section flags, instead got: ", Lexer->getTok()); +break; + case 'G': +Group = true; +break; + default: +return Parser->Error(getTok().getLoc(), + StringRef("Unexepcted section flag: ") + FlagStr); + } +} +return false; + } + + bool parseGroup(StringRef &GroupName) { +if (Lexer->isNot(AsmToken::Comma)) + return TokError("expected group name"); +Lex(); +if (Lexer->is(AsmToken::Integer)) { + GroupName = getTok().getString(); + Lex(); +} else if (Parser->parseIdentifier(GroupName)) { + return TokError("invalid group name"); +} +if (Lexer->is(AsmToken::Comma)) { + Lex(); + StringRef Linkage; + if (Parser->parseIdentifier(Linkage)) +return TokError("invalid linkage"); + if (Linkage != "comdat") +return TokError("Linkage must be 'comdat'"); } return false; } @@ -130,27 +155,34 @@ class WasmAsmParser : public MCAsmParserExtension { if (!Kind.hasValue()) return Parser->Error(Lexer->getLoc(), "unknown section kind: " + Name); -MCSectionWasm *Section = getContext().getWasmSection(Name, Kind.getValue()); // Update section flags if present in this .section directive bool Passive = false; -if (parseSectionFlags(getTok().getStringContents(), Passive)) +bool Group = false; +if (parseSectionFlags(getTok().getStringContents(), Passive, Group)) return true; -if (Passive) { - if (!Section->isWasmData()) -return Parser->Error(getTok().getLoc(), - "Only data sections can be passive"); - Section->setPassive(); -} - Lex(); -if (expect(AsmToken::Comma, ",") || expect(AsmToken::At, "@") || -expect(AsmToken::EndOfStatement, "eol")) +if (expect(AsmToken::Comma, ",") || expect(AsmToken::At, "@")) + return true; + +StringRef GroupName; +if (Group && parseGroup(GroupName)) + return true; + +if (expect(AsmToken::EndOfStatement, "eol")) return true; -auto WS = getContext().getWasmSection(Name, Kind.getValue()); +// TODO: Parse UniqueID +MCSectionWasm *WS = getContext().getWasmSection( +Name, Kind.getValue(), GroupName, MCContext::GenericSectionID); +if (Passive) { + if (!WS->isWasmData()) +return Parser->Error(getTok().getLoc(), + "Only data sections can be passive"); + WS->setPassive(); +} getStreamer().SwitchSection(WS); return false; } @@ -189,9 +221,13 @@ class WasmAsmParser : public MCAsmParserExtension { Lexer->is(AsmToken::Identifier))) return error("Expected label,@type declaration, got: ", Lexer->getTok()); auto TypeName = Lexer->getTok().getString(); -if (TypeName == "function") +if (Type
[llvm-branch-commits] [lld] dd6412c - [WebAssembly][lld] Exclude COMDAT sections
Author: Derek Schuff Date: 2020-12-10T17:47:41-08:00 New Revision: dd6412c05c1039e582a970da1aee62cdde75c892 URL: https://github.com/llvm/llvm-project/commit/dd6412c05c1039e582a970da1aee62cdde75c892 DIFF: https://github.com/llvm/llvm-project/commit/dd6412c05c1039e582a970da1aee62cdde75c892.diff LOG: [WebAssembly][lld] Exclude COMDAT sections Allow exclusion/discarding of custom sections with COMDAT groups. It piggybacks on the existing COMDAT-handling code, but applies to custom sections as well. Differential Revision: https://reviews.llvm.org/D92950 Added: lld/test/wasm/Inputs/comdat1.s lld/test/wasm/Inputs/comdat2.s lld/test/wasm/comdat-sections.s Modified: lld/wasm/InputChunks.h lld/wasm/InputFiles.cpp lld/wasm/OutputSections.cpp lld/wasm/Writer.cpp Removed: diff --git a/lld/test/wasm/Inputs/comdat1.s b/lld/test/wasm/Inputs/comdat1.s new file mode 100644 index ..ff988ccef20f --- /dev/null +++ b/lld/test/wasm/Inputs/comdat1.s @@ -0,0 +1,13 @@ +.text +.section .text.foo,"G",@,foo,comdat +.globl foo +.type foo,@function +foo: +.functype foo () -> () +return +end_function + +.section .debug_foo,"G",@,foo,comdat +.int32 1 +.section .debug_foo,"G",@,duplicate,comdat +.int64 123 diff --git a/lld/test/wasm/Inputs/comdat2.s b/lld/test/wasm/Inputs/comdat2.s new file mode 100644 index ..f498fdd105d6 --- /dev/null +++ b/lld/test/wasm/Inputs/comdat2.s @@ -0,0 +1,13 @@ +.text +.section .text.foo,"G",@,foo,comdat +.globl foo +.type foo,@function +foo: +.functype foo () -> () +return +end_function + +.section .debug_foo,"G",@,foo,comdat +.int32 2 +.section .debug_foo,"G",@,duplicate,comdat +.int64 234 diff --git a/lld/test/wasm/comdat-sections.s b/lld/test/wasm/comdat-sections.s new file mode 100644 index ..fc8d2ded1980 --- /dev/null +++ b/lld/test/wasm/comdat-sections.s @@ -0,0 +1,22 @@ +# RUN: llvm-mc -triple=wasm32 -filetype=obj %p/Inputs/comdat1.s -o %t1.o +# RUN: llvm-mc -triple=wasm32 -filetype=obj %p/Inputs/comdat2.s -o %t2.o +# RUN: llvm-mc -triple=wasm32 -filetype=obj %s -o %t.o +# RUN: wasm-ld -o %t.wasm %t.o %t1.o %t2.o +# RUN: obj2yaml %t.wasm | FileCheck %s + + +.globl _start +.type _start,@function +_start: +.functype _start () -> () +call foo +end_function + +.functype foo () -> () + + +# Check that we got 1 copy of each of the .debug_foo sections from the 2 object +# files, and that they came from the same object. +# CHECK: - Type:CUSTOM +# CHECK-NEXT:Name:.debug_foo +# CHECK-NEXT:Payload: 01007B00 diff --git a/lld/wasm/InputChunks.h b/lld/wasm/InputChunks.h index ba4e2a591074..9082d1dada5f 100644 --- a/lld/wasm/InputChunks.h +++ b/lld/wasm/InputChunks.h @@ -221,7 +221,7 @@ class InputSection : public InputChunk { StringRef getName() const override { return section.Name; } StringRef getDebugName() const override { return StringRef(); } - uint32_t getComdat() const override { return UINT32_MAX; } + uint32_t getComdat() const override { return section.Comdat; } protected: ArrayRef data() const override { return section.Content; } diff --git a/lld/wasm/InputFiles.cpp b/lld/wasm/InputFiles.cpp index 2b3c2591058c..68a9472819e4 100644 --- a/lld/wasm/InputFiles.cpp +++ b/lld/wasm/InputFiles.cpp @@ -341,6 +341,12 @@ void ObjFile::parse(bool ignoreComdats) { } } + ArrayRef comdats = wasmObj->linkingData().Comdats; + for (StringRef comdat : comdats) { +bool isNew = ignoreComdats || symtab->addComdat(comdat); +keptComdats.push_back(isNew); + } + uint32_t sectionIndex = 0; // Bool for each symbol, true if called directly. This allows us to implement @@ -360,7 +366,9 @@ void ObjFile::parse(bool ignoreComdats) { assert(!dataSection); dataSection = §ion; } else if (section.Type == WASM_SEC_CUSTOM) { - customSections.emplace_back(make(section, this)); + auto *customSec = make(section, this); + customSec->discarded = isExcludedByComdat(customSec); + customSections.emplace_back(customSec); customSections.back()->setRelocations(section.Relocations); customSectionsByIndex[sectionIndex] = customSections.back(); } @@ -374,11 +382,6 @@ void ObjFile::parse(bool ignoreComdats) { typeMap.resize(getWasmObj()->types().size()); typeIsUsed.resize(getWasmObj()->types().size(), false); - ArrayRef comdats = wasmObj->linkingData().Comdats; - for (StringRef comdat : comdats) { -bool isNew = ignoreComdats || symtab->addComdat(comdat); -keptComdats.push_back(isNew); - } // Populate `Segments`. for (const WasmSegment &s : wasmObj->dataSegments()) { @@ -487,6 +490
[llvm-branch-commits] [llvm] release/19.x: [WebAssembly] Fix rethrow's index calculation (#114693) (PR #115844)
dschuff wrote: oh nevermind, I was confused; #114693 is closed, but this is the PR that implements the backport. https://github.com/llvm/llvm-project/pull/115844 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] release/19.x: [WebAssembly] Fix rethrow's index calculation (#114693) (PR #115844)
https://github.com/dschuff approved this pull request. LGTM, although it looks like this is already done? https://github.com/llvm/llvm-project/pull/115844 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [lld] release/19.x: [lld][WebAssembly] Fix use of uninitialized stack data with --wasm64 (#107780) (PR #119723)
https://github.com/dschuff approved this pull request. https://github.com/llvm/llvm-project/pull/119723 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [lld] release/19.x: [lld][WebAssembly] Fix use of uninitialized stack data with --wasm64 (#107780) (PR #119723)
https://github.com/dschuff updated https://github.com/llvm/llvm-project/pull/119723 >From fc310d328d3954207a775d0f0b17f9796912777a Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Mon, 9 Sep 2024 09:28:08 -0700 Subject: [PATCH] [lld][WebAssembly] Fix use of uninitialized stack data with --wasm64 (#107780) In the case of `--wasm64` we were setting the type of the init expression to be 64-bit but were only setting the low 32-bits of the value (by assigning to Int32). Fixes: https://github.com/emscripten-core/emscripten/issues/22538 (cherry picked from commit 5c8fd1eece8fff69871cef57a2363dc0f734a7d1) --- lld/wasm/SyntheticSections.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lld/wasm/SyntheticSections.cpp b/lld/wasm/SyntheticSections.cpp index f02f55519a2512..72d08b849d8e86 100644 --- a/lld/wasm/SyntheticSections.cpp +++ b/lld/wasm/SyntheticSections.cpp @@ -587,8 +587,7 @@ void ElemSection::writeBody() { initExpr.Inst.Value.Global = WasmSym::tableBase->getGlobalIndex(); } else { bool is64 = config->is64.value_or(false); -initExpr.Inst.Opcode = is64 ? WASM_OPCODE_I64_CONST : WASM_OPCODE_I32_CONST; -initExpr.Inst.Value.Int32 = config->tableBase; +initExpr = intConst(config->tableBase, is64); } writeInitExpr(os, initExpr); ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [lld] release/19.x: [lld][WebAssembly] Fix use of uninitialized stack data with --wasm64 (#107780) (PR #119723)
https://github.com/dschuff updated https://github.com/llvm/llvm-project/pull/119723 >From 3baa93367c6b0862279decc5d2400bc59fa1c485 Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Mon, 9 Sep 2024 09:28:08 -0700 Subject: [PATCH] [lld][WebAssembly] Fix use of uninitialized stack data with --wasm64 (#107780) In the case of `--wasm64` we were setting the type of the init expression to be 64-bit but were only setting the low 32-bits of the value (by assigning to Int32). Fixes: https://github.com/emscripten-core/emscripten/issues/22538 (cherry picked from commit 5c8fd1eece8fff69871cef57a2363dc0f734a7d1) --- lld/wasm/SyntheticSections.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lld/wasm/SyntheticSections.cpp b/lld/wasm/SyntheticSections.cpp index f02f55519a2512..72d08b849d8e86 100644 --- a/lld/wasm/SyntheticSections.cpp +++ b/lld/wasm/SyntheticSections.cpp @@ -587,8 +587,7 @@ void ElemSection::writeBody() { initExpr.Inst.Value.Global = WasmSym::tableBase->getGlobalIndex(); } else { bool is64 = config->is64.value_or(false); -initExpr.Inst.Opcode = is64 ? WASM_OPCODE_I64_CONST : WASM_OPCODE_I32_CONST; -initExpr.Inst.Value.Int32 = config->tableBase; +initExpr = intConst(config->tableBase, is64); } writeInitExpr(os, initExpr); ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits