[llvm] r358315 - [WebAssembly] Add DataCount section to object files
Thomas Lively via llvm-commits
llvm-commits at lists.llvm.org
Fri Apr 12 15:27:48 PDT 2019
Author: tlively
Date: Fri Apr 12 15:27:48 2019
New Revision: 358315
URL: http://llvm.org/viewvc/llvm-project?rev=358315&view=rev
Log:
[WebAssembly] Add DataCount section to object files
Summary:
This ensures that object files will continue to validate as
WebAssembly modules in the presence of bulk memory operations. Engines
that don't support bulk memory operations will not recognize the
DataCount section and will report validation errors, but that's ok
because object files aren't supposed to be run directly anyway.
Reviewers: aheejin, dschuff, sbc100
Subscribers: jgravelle-google, hiraditya, sunfish, rupprecht, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60623
Modified:
llvm/trunk/include/llvm/Object/Wasm.h
llvm/trunk/include/llvm/ObjectYAML/WasmYAML.h
llvm/trunk/lib/MC/WasmObjectWriter.cpp
llvm/trunk/lib/Object/WasmObjectFile.cpp
llvm/trunk/lib/ObjectYAML/WasmYAML.cpp
llvm/trunk/test/MC/WebAssembly/bss.ll
llvm/trunk/test/MC/WebAssembly/comdat.ll
llvm/trunk/test/MC/WebAssembly/data-section.s
llvm/trunk/test/MC/WebAssembly/debug-info.ll
llvm/trunk/test/MC/WebAssembly/explicit-sections.ll
llvm/trunk/test/MC/WebAssembly/external-data.ll
llvm/trunk/test/MC/WebAssembly/external-func-address.ll
llvm/trunk/test/MC/WebAssembly/global-ctor-dtor.ll
llvm/trunk/test/MC/WebAssembly/reloc-code.ll
llvm/trunk/test/MC/WebAssembly/reloc-data.ll
llvm/trunk/test/MC/WebAssembly/reloc-pic.s
llvm/trunk/test/MC/WebAssembly/unnamed-data.ll
llvm/trunk/test/MC/WebAssembly/weak-alias.ll
llvm/trunk/tools/llvm-readobj/WasmDumper.cpp
llvm/trunk/tools/obj2yaml/wasm2yaml.cpp
llvm/trunk/tools/yaml2obj/yaml2wasm.cpp
Modified: llvm/trunk/include/llvm/Object/Wasm.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Object/Wasm.h?rev=358315&r1=358314&r2=358315&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Object/Wasm.h (original)
+++ llvm/trunk/include/llvm/Object/Wasm.h Fri Apr 12 15:27:48 2019
@@ -247,6 +247,7 @@ private:
Error parseElemSection(ReadContext &Ctx);
Error parseCodeSection(ReadContext &Ctx);
Error parseDataSection(ReadContext &Ctx);
+ Error parseDataCountSection(ReadContext &Ctx);
// Custom section types
Error parseDylinkSection(ReadContext &Ctx);
@@ -273,6 +274,7 @@ private:
std::vector<wasm::WasmExport> Exports;
std::vector<wasm::WasmElemSegment> ElemSegments;
std::vector<WasmSegment> DataSegments;
+ llvm::Optional<size_t> DataCount;
std::vector<wasm::WasmFunction> Functions;
std::vector<WasmSymbol> Symbols;
std::vector<wasm::WasmFunctionName> DebugNames;
Modified: llvm/trunk/include/llvm/ObjectYAML/WasmYAML.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ObjectYAML/WasmYAML.h?rev=358315&r1=358314&r2=358315&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ObjectYAML/WasmYAML.h (original)
+++ llvm/trunk/include/llvm/ObjectYAML/WasmYAML.h Fri Apr 12 15:27:48 2019
@@ -379,6 +379,16 @@ struct DataSection : Section {
std::vector<DataSegment> Segments;
};
+struct DataCountSection : Section {
+ DataCountSection() : Section(wasm::WASM_SEC_DATACOUNT) {}
+
+ static bool classof(const Section *S) {
+ return S->Type == wasm::WASM_SEC_DATACOUNT;
+ }
+
+ uint32_t Count;
+};
+
struct Object {
FileHeader Header;
std::vector<std::unique_ptr<Section>> Sections;
Modified: llvm/trunk/lib/MC/WasmObjectWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/WasmObjectWriter.cpp?rev=358315&r1=358314&r2=358315&view=diff
==============================================================================
--- llvm/trunk/lib/MC/WasmObjectWriter.cpp (original)
+++ llvm/trunk/lib/MC/WasmObjectWriter.cpp Fri Apr 12 15:27:48 2019
@@ -326,6 +326,7 @@ private:
void writeFunctionSection(ArrayRef<WasmFunction> Functions);
void writeExportSection(ArrayRef<wasm::WasmExport> Exports);
void writeElemSection(ArrayRef<uint32_t> TableElems);
+ void writeDataCountSection();
void writeCodeSection(const MCAssembler &Asm, const MCAsmLayout &Layout,
ArrayRef<WasmFunction> Functions);
void writeDataSection();
@@ -849,6 +850,16 @@ void WasmObjectWriter::writeElemSection(
endSection(Section);
}
+void WasmObjectWriter::writeDataCountSection() {
+ if (DataSegments.empty())
+ return;
+
+ SectionBookkeeping Section;
+ startSection(Section, wasm::WASM_SEC_DATACOUNT);
+ encodeULEB128(DataSegments.size(), W.OS);
+ endSection(Section);
+}
+
void WasmObjectWriter::writeCodeSection(const MCAssembler &Asm,
const MCAsmLayout &Layout,
ArrayRef<WasmFunction> Functions) {
@@ -1600,6 +1611,7 @@ uint64_t WasmObjectWriter::writeObject(M
writeEventSection(Events);
writeExportSection(Exports);
writeElemSection(TableElems);
+ writeDataCountSection();
writeCodeSection(Asm, Layout, Functions);
writeDataSection();
for (auto &CustomSection : CustomSections)
Modified: llvm/trunk/lib/Object/WasmObjectFile.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/WasmObjectFile.cpp?rev=358315&r1=358314&r2=358315&view=diff
==============================================================================
--- llvm/trunk/lib/Object/WasmObjectFile.cpp (original)
+++ llvm/trunk/lib/Object/WasmObjectFile.cpp Fri Apr 12 15:27:48 2019
@@ -316,6 +316,8 @@ Error WasmObjectFile::parseSection(WasmS
return parseCodeSection(Ctx);
case wasm::WASM_SEC_DATA:
return parseDataSection(Ctx);
+ case wasm::WASM_SEC_DATACOUNT:
+ return parseDataCountSection(Ctx);
default:
return make_error<GenericBinaryError>("Bad section type",
object_error::parse_failed);
@@ -1201,6 +1203,9 @@ Error WasmObjectFile::parseElemSection(R
Error WasmObjectFile::parseDataSection(ReadContext &Ctx) {
DataSection = Sections.size();
uint32_t Count = readVaruint32(Ctx);
+ if (DataCount && Count != DataCount.getValue())
+ return make_error<GenericBinaryError>(
+ "Number of data segments does not match DataCount section");
DataSegments.reserve(Count);
while (Count--) {
WasmSegment Segment;
@@ -1234,6 +1239,11 @@ Error WasmObjectFile::parseDataSection(R
return Error::success();
}
+Error WasmObjectFile::parseDataCountSection(ReadContext &Ctx) {
+ DataCount = readVaruint32(Ctx);
+ return Error::success();
+}
+
const wasm::WasmObjectHeader &WasmObjectFile::getHeader() const {
return Header;
}
@@ -1399,6 +1409,7 @@ std::error_code WasmObjectFile::getSecti
ECase(ELEM);
ECase(CODE);
ECase(DATA);
+ ECase(DATACOUNT);
case wasm::WASM_SEC_CUSTOM:
Res = S.Name;
break;
Modified: llvm/trunk/lib/ObjectYAML/WasmYAML.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ObjectYAML/WasmYAML.cpp?rev=358315&r1=358314&r2=358315&view=diff
==============================================================================
--- llvm/trunk/lib/ObjectYAML/WasmYAML.cpp (original)
+++ llvm/trunk/lib/ObjectYAML/WasmYAML.cpp Fri Apr 12 15:27:48 2019
@@ -153,6 +153,11 @@ static void sectionMapping(IO &IO, WasmY
IO.mapRequired("Segments", Section.Segments);
}
+static void sectionMapping(IO &IO, WasmYAML::DataCountSection &Section) {
+ commonSectionMapping(IO, Section);
+ IO.mapRequired("Count", Section.Count);
+}
+
void MappingTraits<std::unique_ptr<WasmYAML::Section>>::mapping(
IO &IO, std::unique_ptr<WasmYAML::Section> &Section) {
WasmYAML::SectionType SectionType;
@@ -257,6 +262,11 @@ void MappingTraits<std::unique_ptr<WasmY
Section.reset(new WasmYAML::DataSection());
sectionMapping(IO, *cast<WasmYAML::DataSection>(Section.get()));
break;
+ case wasm::WASM_SEC_DATACOUNT:
+ if (!IO.outputting())
+ Section.reset(new WasmYAML::DataCountSection());
+ sectionMapping(IO, *cast<WasmYAML::DataCountSection>(Section.get()));
+ break;
default:
llvm_unreachable("Unknown section type");
}
@@ -278,6 +288,7 @@ void ScalarEnumerationTraits<WasmYAML::S
ECase(ELEM);
ECase(CODE);
ECase(DATA);
+ ECase(DATACOUNT);
#undef ECase
}
Modified: llvm/trunk/test/MC/WebAssembly/bss.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/WebAssembly/bss.ll?rev=358315&r1=358314&r2=358315&view=diff
==============================================================================
--- llvm/trunk/test/MC/WebAssembly/bss.ll (original)
+++ llvm/trunk/test/MC/WebAssembly/bss.ll Fri Apr 12 15:27:48 2019
@@ -9,7 +9,7 @@ target triple = "wasm32-unknown-unknown"
@foo = global %union.u1 zeroinitializer, align 1
@bar = global %union.u1 zeroinitializer, align 1
-; CHECK: - Type: DATA
+; CHECK: - Type: DATA{{$}}
; CHECK-NEXT: Segments:
; CHECK-NEXT: - SectionOffset: 6
; CHECK-NEXT: InitFlags: 0
Modified: llvm/trunk/test/MC/WebAssembly/comdat.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/WebAssembly/comdat.ll?rev=358315&r1=358314&r2=358315&view=diff
==============================================================================
--- llvm/trunk/test/MC/WebAssembly/comdat.ll (original)
+++ llvm/trunk/test/MC/WebAssembly/comdat.ll Fri Apr 12 15:27:48 2019
@@ -50,6 +50,8 @@ define linkonce_odr i32 @sharedFn() #1 c
; CHECK-NEXT: SigIndex: 0
; CHECK-NEXT: - Type: FUNCTION
; CHECK-NEXT: FunctionTypes: [ 0, 0, 0 ]
+; CHECK-NEXT: - Type: DATACOUNT
+; CHECK-NEXT: Count: 1
; CHECK-NEXT: - Type: CODE
; CHECK-NEXT: Relocations:
; CHECK-NEXT: - Type: R_WASM_FUNCTION_INDEX_LEB
Modified: llvm/trunk/test/MC/WebAssembly/data-section.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/WebAssembly/data-section.s?rev=358315&r1=358314&r2=358315&view=diff
==============================================================================
--- llvm/trunk/test/MC/WebAssembly/data-section.s (original)
+++ llvm/trunk/test/MC/WebAssembly/data-section.s Fri Apr 12 15:27:48 2019
@@ -53,6 +53,8 @@ test0:
# BIN-NEXT: Initial: 0x00000000
# BIN-NEXT: - Type: FUNCTION
# BIN-NEXT: FunctionTypes: [ 0 ]
+# BIN-NEXT: - Type: DATACOUNT
+# BIN-NEXT: Count: 1
# BIN-NEXT: - Type: CODE
# BIN-NEXT: Relocations:
# BIN-NEXT: - Type: R_WASM_MEMORY_ADDR_SLEB
@@ -91,4 +93,3 @@ test0:
# BIN-NEXT: Alignment: 0
# BIN-NEXT: Flags: [ ]
# BIN-NEXT: ...
-
Modified: llvm/trunk/test/MC/WebAssembly/debug-info.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/WebAssembly/debug-info.ll?rev=358315&r1=358314&r2=358315&view=diff
==============================================================================
--- llvm/trunk/test/MC/WebAssembly/debug-info.ll (original)
+++ llvm/trunk/test/MC/WebAssembly/debug-info.ll Fri Apr 12 15:27:48 2019
@@ -25,14 +25,19 @@
; CHECK-NEXT: Offset: 90
; CHECK-NEXT: }
; CHECK-NEXT: Section {
+; CHECK-NEXT: Type: DATACOUNT (0xC)
+; CHECK-NEXT: Size: 1
+; CHECK-NEXT: Offset: 103
+; CHECK-NEXT: }
+; CHECK-NEXT: Section {
; CHECK-NEXT: Type: CODE (0xA)
; CHECK-NEXT: Size: 4
-; CHECK-NEXT: Offset: 103
+; CHECK-NEXT: Offset: 110
; CHECK-NEXT: }
; CHECK-NEXT: Section {
; CHECK-NEXT: Type: DATA (0xB)
; CHECK-NEXT: Size: 19
-; CHECK-NEXT: Offset: 113
+; CHECK-NEXT: Offset: 120
; CHECK-NEXT: Segments [
; CHECK-NEXT: Segment {
; CHECK-NEXT: Name: .data.foo
@@ -49,94 +54,94 @@
; CHECK-NEXT: Section {
; CHECK-NEXT: Type: CUSTOM (0x0)
; CHECK-NEXT: Size: 121
-; CHECK-NEXT: Offset: 138
+; CHECK-NEXT: Offset: 145
; CHECK-NEXT: Name: .debug_str
; CHECK-NEXT: }
; CHECK-NEXT: Section {
; CHECK-NEXT: Type: CUSTOM (0x0)
; CHECK-NEXT: Size: 84
-; CHECK-NEXT: Offset: 276
+; CHECK-NEXT: Offset: 283
; CHECK-NEXT: Name: .debug_abbrev
; CHECK-NEXT: }
; CHECK-NEXT: Section {
; CHECK-NEXT: Type: CUSTOM (0x0)
; CHECK-NEXT: Size: 106
-; CHECK-NEXT: Offset: 380
+; CHECK-NEXT: Offset: 387
; CHECK-NEXT: Name: .debug_info
; CHECK-NEXT: }
; CHECK-NEXT: Section {
; CHECK-NEXT: Type: CUSTOM (0x0)
; CHECK-NEXT: Size: 1
-; CHECK-NEXT: Offset: 504
+; CHECK-NEXT: Offset: 511
; CHECK-NEXT: Name: .debug_macinfo
; CHECK-NEXT: }
; CHECK-NEXT: Section {
; CHECK-NEXT: Type: CUSTOM (0x0)
; CHECK-NEXT: Size: 42
-; CHECK-NEXT: Offset: 526
+; CHECK-NEXT: Offset: 533
; CHECK-NEXT: Name: .debug_pubnames
; CHECK-NEXT: }
; CHECK-NEXT: Section {
; CHECK-NEXT: Type: CUSTOM (0x0)
; CHECK-NEXT: Size: 26
-; CHECK-NEXT: Offset: 590
+; CHECK-NEXT: Offset: 597
; CHECK-NEXT: Name: .debug_pubtypes
; CHECK-NEXT: }
; CHECK-NEXT: Section {
; CHECK-NEXT: Type: CUSTOM (0x0)
; CHECK-NEXT: Size: 57
-; CHECK-NEXT: Offset: 638
+; CHECK-NEXT: Offset: 645
; CHECK-NEXT: Name: .debug_line
; CHECK-NEXT: }
; CHECK-NEXT: Section {
; CHECK-NEXT: Type: CUSTOM (0x0)
; CHECK-NEXT: Size: 88
-; CHECK-NEXT: Offset: 713
+; CHECK-NEXT: Offset: 720
; CHECK-NEXT: Name: linking
; CHECK-NEXT: }
; CHECK-NEXT: Section {
; CHECK-NEXT: Type: CUSTOM (0x0)
; CHECK-NEXT: Size: 9
-; CHECK-NEXT: Offset: 815
+; CHECK-NEXT: Offset: 822
; CHECK-NEXT: Name: reloc.DATA
; CHECK-NEXT: }
; CHECK-NEXT: Section {
; CHECK-NEXT: Type: CUSTOM (0x0)
; CHECK-NEXT: Size: 58
-; CHECK-NEXT: Offset: 841
+; CHECK-NEXT: Offset: 848
; CHECK-NEXT: Name: reloc..debug_info
; CHECK-NEXT: }
; CHECK-NEXT: Section {
; CHECK-NEXT: Type: CUSTOM (0x0)
; CHECK-NEXT: Size: 6
-; CHECK-NEXT: Offset: 923
+; CHECK-NEXT: Offset: 930
; CHECK-NEXT: Name: reloc..debug_pubnames
; CHECK-NEXT: }
; CHECK-NEXT: Section {
; CHECK-NEXT: Type: CUSTOM (0x0)
; CHECK-NEXT: Size: 6
-; CHECK-NEXT: Offset: 957
+; CHECK-NEXT: Offset: 964
; CHECK-NEXT: Name: reloc..debug_pubtypes
; CHECK-NEXT: }
; CHECK-NEXT: Section {
; CHECK-NEXT: Type: CUSTOM (0x0)
; CHECK-NEXT: Size: 6
-; CHECK-NEXT: Offset: 991
+; CHECK-NEXT: Offset: 998
; CHECK-NEXT: Name: reloc..debug_line
; CHECK-NEXT: }
; CHECK-NEXT: Section {
; CHECK-NEXT: Type: CUSTOM (0x0)
; CHECK-NEXT: Size: 77
-; CHECK-NEXT: Offset: 1021
+; CHECK-NEXT: Offset: 1028
; CHECK-NEXT: Name: producers
; CHECK-NEXT: }
; CHECK-NEXT:]
; CHECK-NEXT:Relocations [
-; CHECK-NEXT: Section (6) DATA {
+; CHECK-NEXT: Section (7) DATA {
; CHECK-NEXT: 0x6 R_WASM_MEMORY_ADDR_I32 myextern 0
; CHECK-NEXT: 0xF R_WASM_TABLE_INDEX_I32 f2
; CHECK-NEXT: }
-; CHECK-NEXT: Section (9) .debug_info {
+; CHECK-NEXT: Section (10) .debug_info {
; CHECK-NEXT: 0x6 R_WASM_SECTION_OFFSET_I32 .debug_abbrev 0
; CHECK-NEXT: 0xC R_WASM_SECTION_OFFSET_I32 .debug_str 0
; CHECK-NEXT: 0x12 R_WASM_SECTION_OFFSET_I32 .debug_str 55
@@ -151,13 +156,13 @@
; CHECK-NEXT: 0x5B R_WASM_FUNCTION_OFFSET_I32 f2 0
; CHECK-NEXT: 0x63 R_WASM_SECTION_OFFSET_I32 .debug_str 118
; CHECK-NEXT: }
-; CHECK-NEXT: Section (11) .debug_pubnames {
+; CHECK-NEXT: Section (12) .debug_pubnames {
; CHECK-NEXT: 0x6 R_WASM_SECTION_OFFSET_I32 .debug_info 0
; CHECK-NEXT: }
-; CHECK-NEXT: Section (12) .debug_pubtypes {
+; CHECK-NEXT: Section (13) .debug_pubtypes {
; CHECK-NEXT: 0x6 R_WASM_SECTION_OFFSET_I32 .debug_info 0
; CHECK-NEXT: }
-; CHECK-NEXT: Section (13) .debug_line {
+; CHECK-NEXT: Section (14) .debug_line {
; CHECK-NEXT: 0x2B R_WASM_FUNCTION_OFFSET_I32 f2 0
; CHECK-NEXT: }
; CHECK-NEXT:]
@@ -205,7 +210,7 @@
; CHECK-NEXT: Flags [ (0x2)
; CHECK-NEXT: BINDING_LOCAL (0x2)
; CHECK-NEXT: ]
-; CHECK-NEXT: ElementIndex: 0x6
+; CHECK-NEXT: ElementIndex: 0x7
; CHECK-NEXT: }
; CHECK-NEXT: Symbol {
; CHECK-NEXT: Name: .debug_abbrev
@@ -213,7 +218,7 @@
; CHECK-NEXT: Flags [ (0x2)
; CHECK-NEXT: BINDING_LOCAL (0x2)
; CHECK-NEXT: ]
-; CHECK-NEXT: ElementIndex: 0x7
+; CHECK-NEXT: ElementIndex: 0x8
; CHECK-NEXT: }
; CHECK-NEXT: Symbol {
; CHECK-NEXT: Name: .debug_info
@@ -221,7 +226,7 @@
; CHECK-NEXT: Flags [ (0x2)
; CHECK-NEXT: BINDING_LOCAL (0x2)
; CHECK-NEXT: ]
-; CHECK-NEXT: ElementIndex: 0x8
+; CHECK-NEXT: ElementIndex: 0x9
; CHECK-NEXT: }
; CHECK-NEXT: Symbol {
; CHECK-NEXT: Name: .debug_line
@@ -229,7 +234,7 @@
; CHECK-NEXT: Flags [ (0x2)
; CHECK-NEXT: BINDING_LOCAL (0x2)
; CHECK-NEXT: ]
-; CHECK-NEXT: ElementIndex: 0xC
+; CHECK-NEXT: ElementIndex: 0xD
; CHECK-NEXT: }
; CHECK-NEXT:]
Modified: llvm/trunk/test/MC/WebAssembly/explicit-sections.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/WebAssembly/explicit-sections.ll?rev=358315&r1=358314&r2=358315&view=diff
==============================================================================
--- llvm/trunk/test/MC/WebAssembly/explicit-sections.ll (original)
+++ llvm/trunk/test/MC/WebAssembly/explicit-sections.ll Fri Apr 12 15:27:48 2019
@@ -10,7 +10,7 @@ target triple = "wasm32-unknown-unknown"
@global3 = global i32 8, align 8, section ".sec2"
-; CHECK: - Type: DATA
+; CHECK: - Type: DATA{{$}}
; CHECK-NEXT: Segments:
; CHECK-NEXT: - SectionOffset: 6
; CHECK-NEXT: InitFlags: 0
Modified: llvm/trunk/test/MC/WebAssembly/external-data.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/WebAssembly/external-data.ll?rev=358315&r1=358314&r2=358315&view=diff
==============================================================================
--- llvm/trunk/test/MC/WebAssembly/external-data.ll (original)
+++ llvm/trunk/test/MC/WebAssembly/external-data.ll Fri Apr 12 15:27:48 2019
@@ -10,7 +10,7 @@ target triple = "wasm32-unknown-unknown"
@foo = global i64 7, align 4
@bar = hidden global i32* @myimport, align 4
-; CHECK: - Type: DATA
+; CHECK: - Type: DATA{{$}}
; CHECK-NEXT: Relocations:
; CHECK-NEXT: - Type: R_WASM_MEMORY_ADDR_I32
; CHECK-NEXT: Index: 2
Modified: llvm/trunk/test/MC/WebAssembly/external-func-address.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/WebAssembly/external-func-address.ll?rev=358315&r1=358314&r2=358315&view=diff
==============================================================================
--- llvm/trunk/test/MC/WebAssembly/external-func-address.ll (original)
+++ llvm/trunk/test/MC/WebAssembly/external-func-address.ll Fri Apr 12 15:27:48 2019
@@ -58,7 +58,7 @@ define void @call(i32) {
; CHECK-NEXT: Opcode: I32_CONST
; CHECK-NEXT: Value: 1
; CHECK-NEXT: Functions: [ 1, 2 ]
-; CHECK: - Type: DATA
+; CHECK: - Type: DATA{{$}}
; CHECK-NEXT: Relocations:
; CHECK-NEXT: - Type: R_WASM_TABLE_INDEX_I32
; CHECK-NEXT: Index: 3
Modified: llvm/trunk/test/MC/WebAssembly/global-ctor-dtor.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/WebAssembly/global-ctor-dtor.ll?rev=358315&r1=358314&r2=358315&view=diff
==============================================================================
--- llvm/trunk/test/MC/WebAssembly/global-ctor-dtor.ll (original)
+++ llvm/trunk/test/MC/WebAssembly/global-ctor-dtor.ll Fri Apr 12 15:27:48 2019
@@ -61,6 +61,8 @@ declare void @func3()
; CHECK-NEXT: Opcode: I32_CONST
; CHECK-NEXT: Value: 1
; CHECK-NEXT: Functions: [ 5, 7 ]
+; CHECK-NEXT: - Type: DATACOUNT
+; CHECK-NEXT: Count: 1
; CHECK-NEXT: - Type: CODE
; CHECK-NEXT: Relocations:
; CHECK-NEXT: - Type: R_WASM_FUNCTION_INDEX_LEB
Modified: llvm/trunk/test/MC/WebAssembly/reloc-code.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/WebAssembly/reloc-code.ll?rev=358315&r1=358314&r2=358315&view=diff
==============================================================================
--- llvm/trunk/test/MC/WebAssembly/reloc-code.ll (original)
+++ llvm/trunk/test/MC/WebAssembly/reloc-code.ll Fri Apr 12 15:27:48 2019
@@ -24,7 +24,7 @@ entry:
; CHECK: Format: WASM
; CHECK: Relocations [
-; CHECK-NEXT: Section (4) CODE {
+; CHECK-NEXT: Section (5) CODE {
; CHECK-NEXT: Relocation {
; CHECK-NEXT: Type: R_WASM_MEMORY_ADDR_LEB (3)
; CHECK-NEXT: Offset: 0x9
Modified: llvm/trunk/test/MC/WebAssembly/reloc-data.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/WebAssembly/reloc-data.ll?rev=358315&r1=358314&r2=358315&view=diff
==============================================================================
--- llvm/trunk/test/MC/WebAssembly/reloc-data.ll (original)
+++ llvm/trunk/test/MC/WebAssembly/reloc-data.ll Fri Apr 12 15:27:48 2019
@@ -13,7 +13,7 @@ target triple = "wasm32-unknown-unknown"
; CHECK: Format: WASM
; CHECK: Relocations [
-; CHECK-NEXT: Section (2) DATA {
+; CHECK-NEXT: Section (3) DATA {
; CHECK-NEXT: Relocation {
; CHECK-NEXT: Type: R_WASM_MEMORY_ADDR_I32 (5)
; CHECK-NEXT: Offset: 0x13
Modified: llvm/trunk/test/MC/WebAssembly/reloc-pic.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/WebAssembly/reloc-pic.s?rev=358315&r1=358314&r2=358315&view=diff
==============================================================================
--- llvm/trunk/test/MC/WebAssembly/reloc-pic.s (original)
+++ llvm/trunk/test/MC/WebAssembly/reloc-pic.s Fri Apr 12 15:27:48 2019
@@ -84,6 +84,8 @@ hidden_func:
# CHECK-NEXT: GlobalMutable: true
# CHECK-NEXT: - Type: FUNCTION
# CHECK-NEXT: FunctionTypes: [ 0, 0, 0, 0, 0 ]
+# CHECK-NEXT: - Type: DATACOUNT
+# CHECK-NEXT: Count: 1
# CHECK-NEXT: - Type: CODE
# CHECK-NEXT: Relocations:
# CHECK-NEXT: - Type: R_WASM_GLOBAL_INDEX_LEB
Modified: llvm/trunk/test/MC/WebAssembly/unnamed-data.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/WebAssembly/unnamed-data.ll?rev=358315&r1=358314&r2=358315&view=diff
==============================================================================
--- llvm/trunk/test/MC/WebAssembly/unnamed-data.ll (original)
+++ llvm/trunk/test/MC/WebAssembly/unnamed-data.ll Fri Apr 12 15:27:48 2019
@@ -9,7 +9,7 @@ target triple = "wasm32-unknown-unknown"
@b = global i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str2, i32 0, i32 0), align 8
-; CHECK: - Type: DATA
+; CHECK: - Type: DATA{{$}}
; CHECK-NEXT: Relocations:
; CHECK-NEXT: - Type: R_WASM_MEMORY_ADDR_I32
; CHECK-NEXT: Index: 0
Modified: llvm/trunk/test/MC/WebAssembly/weak-alias.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/WebAssembly/weak-alias.ll?rev=358315&r1=358314&r2=358315&view=diff
==============================================================================
--- llvm/trunk/test/MC/WebAssembly/weak-alias.ll (original)
+++ llvm/trunk/test/MC/WebAssembly/weak-alias.ll Fri Apr 12 15:27:48 2019
@@ -73,6 +73,8 @@ entry:
; CHECK-NEXT: Opcode: I32_CONST
; CHECK-NEXT: Value: 1
; CHECK-NEXT: Functions: [ 0 ]
+; CHECK-NEXT: - Type: DATACOUNT
+; CHECK-NEXT: Count: 3
; CHECK-NEXT: - Type: CODE
; CHECK-NEXT: Relocations:
; CHECK-NEXT: - Type: R_WASM_FUNCTION_INDEX_LEB
Modified: llvm/trunk/tools/llvm-readobj/WasmDumper.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-readobj/WasmDumper.cpp?rev=358315&r1=358314&r2=358315&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-readobj/WasmDumper.cpp (original)
+++ llvm/trunk/tools/llvm-readobj/WasmDumper.cpp Fri Apr 12 15:27:48 2019
@@ -32,11 +32,11 @@ static const EnumEntry<unsigned> WasmSym
static const EnumEntry<uint32_t> WasmSectionTypes[] = {
#define ENUM_ENTRY(X) \
{ #X, wasm::WASM_SEC_##X }
- ENUM_ENTRY(CUSTOM), ENUM_ENTRY(TYPE), ENUM_ENTRY(IMPORT),
- ENUM_ENTRY(FUNCTION), ENUM_ENTRY(TABLE), ENUM_ENTRY(MEMORY),
- ENUM_ENTRY(GLOBAL), ENUM_ENTRY(EVENT), ENUM_ENTRY(EXPORT),
- ENUM_ENTRY(START), ENUM_ENTRY(ELEM), ENUM_ENTRY(CODE),
- ENUM_ENTRY(DATA),
+ ENUM_ENTRY(CUSTOM), ENUM_ENTRY(TYPE), ENUM_ENTRY(IMPORT),
+ ENUM_ENTRY(FUNCTION), ENUM_ENTRY(TABLE), ENUM_ENTRY(MEMORY),
+ ENUM_ENTRY(GLOBAL), ENUM_ENTRY(EVENT), ENUM_ENTRY(EXPORT),
+ ENUM_ENTRY(START), ENUM_ENTRY(ELEM), ENUM_ENTRY(CODE),
+ ENUM_ENTRY(DATA), ENUM_ENTRY(DATACOUNT),
#undef ENUM_ENTRY
};
Modified: llvm/trunk/tools/obj2yaml/wasm2yaml.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/obj2yaml/wasm2yaml.cpp?rev=358315&r1=358314&r2=358315&view=diff
==============================================================================
--- llvm/trunk/tools/obj2yaml/wasm2yaml.cpp (original)
+++ llvm/trunk/tools/obj2yaml/wasm2yaml.cpp Fri Apr 12 15:27:48 2019
@@ -353,6 +353,12 @@ ErrorOr<WasmYAML::Object *> WasmDumper::
S = std::move(DataSec);
break;
}
+ case wasm::WASM_SEC_DATACOUNT: {
+ auto DataCountSec = make_unique<WasmYAML::DataCountSection>();
+ DataCountSec->Count = Obj.dataSegments().size();
+ S = std::move(DataCountSec);
+ break;
+ }
default:
llvm_unreachable("Unknown section type");
break;
Modified: llvm/trunk/tools/yaml2obj/yaml2wasm.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/yaml2obj/yaml2wasm.cpp?rev=358315&r1=358314&r2=358315&view=diff
==============================================================================
--- llvm/trunk/tools/yaml2obj/yaml2wasm.cpp (original)
+++ llvm/trunk/tools/yaml2obj/yaml2wasm.cpp Fri Apr 12 15:27:48 2019
@@ -43,6 +43,7 @@ private:
int writeSectionContent(raw_ostream &OS, WasmYAML::ElemSection &Section);
int writeSectionContent(raw_ostream &OS, WasmYAML::CodeSection &Section);
int writeSectionContent(raw_ostream &OS, WasmYAML::DataSection &Section);
+ int writeSectionContent(raw_ostream &OS, WasmYAML::DataCountSection &Section);
// Custom section types
int writeSectionContent(raw_ostream &OS, WasmYAML::DylinkSection &Section);
@@ -514,6 +515,12 @@ int WasmWriter::writeSectionContent(raw_
return 0;
}
+int WasmWriter::writeSectionContent(raw_ostream &OS,
+ WasmYAML::DataCountSection &Section) {
+ encodeULEB128(Section.Count, OS);
+ return 0;
+}
+
int WasmWriter::writeRelocSection(raw_ostream &OS, WasmYAML::Section &Sec,
uint32_t SectionIndex) {
switch (Sec.Type) {
@@ -614,6 +621,9 @@ int WasmWriter::writeWasm(raw_ostream &O
} else if (auto S = dyn_cast<WasmYAML::DataSection>(Sec.get())) {
if (auto Err = writeSectionContent(StringStream, *S))
return Err;
+ } else if (auto S = dyn_cast<WasmYAML::DataCountSection>(Sec.get())) {
+ if (auto Err = writeSectionContent(StringStream, *S))
+ return Err;
} else {
errs() << "Unknown section type: " << Sec->Type << "\n";
return 1;
More information about the llvm-commits
mailing list