Skip to content

Commit

Permalink
[WebAssembly] Remove DataSize from linking metadata section
Browse files Browse the repository at this point in the history
Neither the linker nor the runtime need this information
anymore.  We were originally using this to model BSS size
but the plan is now to use the segment metadata to allow
for BSS segments.

Differential Revision: https://reviews.llvm.org/D41366

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@326267 91177308-0d34-0410-b5e6-96231b3b80d8
sbc100 committed Feb 27, 2018
1 parent 6981292 commit e14b248
Showing 24 changed files with 3 additions and 43 deletions.
2 changes: 0 additions & 2 deletions include/llvm/BinaryFormat/Wasm.h
Original file line number Diff line number Diff line change
@@ -158,7 +158,6 @@ struct WasmFunctionName {
};

struct WasmLinkingData {
uint32_t DataSize;
std::vector<WasmInitFunc> InitFunctions;
std::vector<WasmSymbolInfo> SymbolTable;
};
@@ -227,7 +226,6 @@ enum : unsigned {

// Kind codes used in the custom "linking" section
enum : unsigned {
WASM_DATA_SIZE = 0x3,
WASM_SEGMENT_INFO = 0x5,
WASM_INIT_FUNCS = 0x6,
WASM_COMDAT_INFO = 0x7,
1 change: 0 additions & 1 deletion include/llvm/ObjectYAML/WasmYAML.h
Original file line number Diff line number Diff line change
@@ -195,7 +195,6 @@ struct LinkingSection : CustomSection {
return C && C->Name == "linking";
}

uint32_t DataSize;
std::vector<SymbolInfo> SymbolTable;
std::vector<SegmentInfo> SegmentInfos;
std::vector<InitFunction> InitFunctions;
12 changes: 3 additions & 9 deletions lib/MC/WasmObjectWriter.cpp
Original file line number Diff line number Diff line change
@@ -274,7 +274,7 @@ class WasmObjectWriter : public MCObjectWriter {
void writeCodeRelocSection();
void writeDataRelocSection();
void writeLinkingMetaDataSection(
uint32_t DataSize, ArrayRef<wasm::WasmSymbolInfo> SymbolInfos,
ArrayRef<wasm::WasmSymbolInfo> SymbolInfos,
ArrayRef<std::pair<uint16_t, uint32_t>> InitFuncs,
const std::map<StringRef, std::vector<WasmComdatEntry>> &Comdats);

@@ -862,7 +862,7 @@ void WasmObjectWriter::writeDataRelocSection() {
}

void WasmObjectWriter::writeLinkingMetaDataSection(
uint32_t DataSize, ArrayRef<wasm::WasmSymbolInfo> SymbolInfos,
ArrayRef<wasm::WasmSymbolInfo> SymbolInfos,
ArrayRef<std::pair<uint16_t, uint32_t>> InitFuncs,
const std::map<StringRef, std::vector<WasmComdatEntry>> &Comdats) {
SectionBookkeeping Section;
@@ -897,12 +897,6 @@ void WasmObjectWriter::writeLinkingMetaDataSection(
endSection(SubSection);
}

if (DataSize > 0) {
startSection(SubSection, wasm::WASM_DATA_SIZE);
encodeULEB128(DataSize, getStream());
endSection(SubSection);
}

if (DataSegments.size()) {
startSection(SubSection, wasm::WASM_SEGMENT_INFO);
encodeULEB128(DataSegments.size(), getStream());
@@ -1316,7 +1310,7 @@ void WasmObjectWriter::writeObject(MCAssembler &Asm,
writeDataSection();
writeCodeRelocSection();
writeDataRelocSection();
writeLinkingMetaDataSection(DataSize, SymbolInfos, InitFuncs, Comdats);
writeLinkingMetaDataSection(SymbolInfos, InitFuncs, Comdats);

// TODO: Translate the .comment section to the output.
// TODO: Translate debug sections to the output.
5 changes: 0 additions & 5 deletions lib/Object/WasmObjectFile.cpp
Original file line number Diff line number Diff line change
@@ -197,8 +197,6 @@ static Error readSection(WasmSection &Section, const uint8_t *&Ptr,

WasmObjectFile::WasmObjectFile(MemoryBufferRef Buffer, Error &Err)
: ObjectFile(Binary::ID_Wasm, Buffer) {
LinkingData.DataSize = 0;

ErrorAsOutParameter ErrAsOutParam(&Err);
Header.Magic = getData().substr(0, 4);
if (Header.Magic != StringRef("\0asm", 4)) {
@@ -334,9 +332,6 @@ Error WasmObjectFile::parseLinkingSection(const uint8_t *Ptr,
if (Error Err = parseLinkingSectionSymtab(Ptr, SubSectionEnd))
return Err;
break;
case wasm::WASM_DATA_SIZE:
LinkingData.DataSize = readVaruint32(Ptr);
break;
case wasm::WASM_SEGMENT_INFO: {
uint32_t Count = readVaruint32(Ptr);
if (Count > DataSegments.size())
1 change: 0 additions & 1 deletion lib/ObjectYAML/WasmYAML.cpp
Original file line number Diff line number Diff line change
@@ -57,7 +57,6 @@ static void sectionMapping(IO &IO, WasmYAML::NameSection &Section) {
static void sectionMapping(IO &IO, WasmYAML::LinkingSection &Section) {
commonSectionMapping(IO, Section);
IO.mapRequired("Name", Section.Name);
IO.mapRequired("DataSize", Section.DataSize);
IO.mapOptional("SymbolTable", Section.SymbolTable);
IO.mapOptional("SegmentInfo", Section.SegmentInfos);
IO.mapOptional("InitFunctions", Section.InitFunctions);
1 change: 0 additions & 1 deletion test/MC/WebAssembly/array-fill.ll
Original file line number Diff line number Diff line change
@@ -14,7 +14,6 @@ target triple = "wasm32-unknown-unknown-wasm"

; CHECK: - Type: CUSTOM
; CHECK-NEXT: Name: linking
; CHECK-NEXT: DataSize: 2
; CHECK-NEXT: SymbolTable:
; CHECK-NEXT: - Index: 0
; CHECK-NEXT: Kind: DATA
1 change: 0 additions & 1 deletion test/MC/WebAssembly/bss.ll
Original file line number Diff line number Diff line change
@@ -37,7 +37,6 @@ target triple = "wasm32-unknown-unknown-wasm"
; CHECK-NEXT: Content: ''
; CHECK-NEXT: - Type: CUSTOM
; CHECK-NEXT: Name: linking
; CHECK-NEXT: DataSize: 8
; CHECK-NEXT: SymbolTable:
; CHECK-NEXT: - Index: 0
; CHECK-NEXT: Kind: DATA
1 change: 0 additions & 1 deletion test/MC/WebAssembly/comdat.ll
Original file line number Diff line number Diff line change
@@ -75,7 +75,6 @@ define linkonce_odr i32 @sharedFn() #1 comdat($sharedComdat) {
; CHECK-NEXT: Content: '616263'
; CHECK-NEXT: - Type: CUSTOM
; CHECK-NEXT: Name: linking
; CHECK-NEXT: DataSize: 3
; CHECK-NEXT: SymbolTable:
; CHECK-NEXT: - Index: 0
; CHECK-NEXT: Kind: FUNCTION
1 change: 0 additions & 1 deletion test/MC/WebAssembly/explicit-sections.ll
Original file line number Diff line number Diff line change
@@ -32,7 +32,6 @@ target triple = "wasm32-unknown-unknown-wasm"
; CHECK-NEXT: Content: '08000000'
; CHECK-NEXT: - Type: CUSTOM
; CHECK-NEXT: Name: linking
; CHECK-NEXT: DataSize: 28
; CHECK-NEXT: SymbolTable:
; CHECK-NEXT: - Index: 0
; CHECK-NEXT: Kind: DATA
1 change: 0 additions & 1 deletion test/MC/WebAssembly/global-ctor-dtor.ll
Original file line number Diff line number Diff line change
@@ -110,7 +110,6 @@ declare void @func3()
; CHECK-NEXT: Content: '01040000'
; CHECK-NEXT: - Type: CUSTOM
; CHECK-NEXT: Name: linking
; CHECK-NEXT: DataSize: 4
; CHECK-NEXT: SymbolTable:
; CHECK-NEXT: - Index: 0
; CHECK-NEXT: Kind: FUNCTION
1 change: 0 additions & 1 deletion test/MC/WebAssembly/unnamed-data.ll
Original file line number Diff line number Diff line change
@@ -44,7 +44,6 @@ target triple = "wasm32-unknown-unknown-wasm"
; CHECK-NEXT: Content: '06000000'
; CHECK-NEXT: - Type: CUSTOM
; CHECK-NEXT: Name: linking
; CHECK-NEXT: DataSize: 28
; CHECK-NEXT: SymbolTable:
; CHECK-NEXT: - Index: 0
; CHECK-NEXT: Kind: DATA
1 change: 0 additions & 1 deletion test/MC/WebAssembly/visibility.ll
Original file line number Diff line number Diff line change
@@ -16,7 +16,6 @@ entry:

; CHECK: - Type: CUSTOM
; CHECK-NEXT: Name: linking
; CHECK-NEXT: DataSize: 0
; CHECK-NEXT: SymbolTable:
; CHECK-NEXT: - Index: 0
; CHECK-NEXT: Kind: FUNCTION
1 change: 0 additions & 1 deletion test/MC/WebAssembly/weak-alias.ll
Original file line number Diff line number Diff line change
@@ -138,7 +138,6 @@ entry:
; CHECK-NEXT: Content: '01000000'
; CHECK-NEXT: - Type: CUSTOM
; CHECK-NEXT: Name: linking
; CHECK-NEXT: DataSize: 20
; CHECK-NEXT: SymbolTable:
; CHECK-NEXT: - Index: 0
; CHECK-NEXT: Kind: FUNCTION
1 change: 0 additions & 1 deletion test/MC/WebAssembly/weak.ll
Original file line number Diff line number Diff line change
@@ -22,7 +22,6 @@ entry:

; CHECK: - Type: CUSTOM
; CHECK-NEXT: Name: linking
; CHECK-NEXT: DataSize: 0
; CHECK-NEXT: SymbolTable:
; CHECK-NEXT: - Index: 0
; CHECK-NEXT: Kind: DATA
1 change: 0 additions & 1 deletion test/Object/obj2yaml.test
Original file line number Diff line number Diff line change
@@ -651,7 +651,6 @@ WASM-NEXT: FileHeader:
WASM-NEXT: Version: 0x00000001
WASM: - Type: CUSTOM
WASM-NEXT: Name: linking
WASM-NEXT: DataSize: 20
WASM-NEXT: SymbolTable:
WASM-NEXT: - Index: 0
WASM-NEXT: Kind: FUNCTION
2 changes: 0 additions & 2 deletions test/ObjectYAML/wasm/linking_section.yaml
Original file line number Diff line number Diff line change
@@ -29,7 +29,6 @@ Sections:
Content: '11110000'
- Type: CUSTOM
Name: linking
DataSize: 999
SymbolTable:
- Index: 0
Kind: FUNCTION
@@ -51,7 +50,6 @@ Sections:
...
# CHECK: - Type: CUSTOM
# CHECK-NEXT: Name: linking
# CHECK-NEXT: DataSize: 999
# CHECK-NEXT: SymbolTable:
# CHECK-NEXT: - Index: 0
# CHECK-NEXT: Kind: FUNCTION
2 changes: 0 additions & 2 deletions test/ObjectYAML/wasm/weak_symbols.yaml
Original file line number Diff line number Diff line change
@@ -36,7 +36,6 @@ Sections:
Body: 00
- Type: CUSTOM
Name: linking
DataSize: 10
SymbolTable:
- Index: 0
Kind: FUNCTION
@@ -63,7 +62,6 @@ Sections:
# CHECK: Index: 0
# CHECK: - Type: CUSTOM
# CHECK: Name: linking
# CHECK: DataSize: 10
# CHECK: SymbolTable:
# CHECK: - Index: 0
# CHECK: Kind: FUNCTION
1 change: 0 additions & 1 deletion test/tools/llvm-nm/wasm/exports.yaml
Original file line number Diff line number Diff line change
@@ -37,7 +37,6 @@ Sections:
Content: '616263'
- Type: CUSTOM
Name: linking
DataSize: 3
SymbolTable:
- Index: 0
Kind: FUNCTION
1 change: 0 additions & 1 deletion test/tools/llvm-nm/wasm/imports.yaml
Original file line number Diff line number Diff line change
@@ -25,7 +25,6 @@ Sections:
GlobalMutable: false
- Type: CUSTOM
Name: linking
DataSize: 3
SymbolTable:
- Index: 0
Kind: FUNCTION
1 change: 0 additions & 1 deletion test/tools/llvm-nm/wasm/weak-symbols.yaml
Original file line number Diff line number Diff line change
@@ -48,7 +48,6 @@ Sections:
Content: '616263'
- Type: CUSTOM
Name: linking
DataSize: 3
SymbolTable:
- Index: 0
Kind: DATA
1 change: 0 additions & 1 deletion test/tools/llvm-readobj/sections.test
Original file line number Diff line number Diff line change
@@ -537,6 +537,5 @@ WASM-NEXT: Type: CUSTOM (0x0)
WASM-NEXT: Size: 72
WASM-NEXT: Offset: 220
WASM-NEXT: Name: linking
WASM-NEXT: DataSize: 13
WASM-NEXT: }
WASM-NEXT: ]
1 change: 0 additions & 1 deletion tools/llvm-readobj/WasmDumper.cpp
Original file line number Diff line number Diff line change
@@ -153,7 +153,6 @@ void WasmDumper::printSections() {
W.printString("Name", WasmSec.Name);
if (WasmSec.Name == "linking") {
const wasm::WasmLinkingData &LinkingData = Obj->linkingData();
W.printNumber("DataSize", LinkingData.DataSize);
if (!LinkingData.InitFunctions.empty()) {
ListScope Group(W, "InitFunctions");
for (const wasm::WasmInitFunc &F: LinkingData.InitFunctions)
1 change: 0 additions & 1 deletion tools/obj2yaml/wasm2yaml.cpp
Original file line number Diff line number Diff line change
@@ -109,7 +109,6 @@ std::unique_ptr<WasmYAML::CustomSection> WasmDumper::dumpCustomSection(const Was
}
LinkingSec->SymbolTable.emplace_back(Info);
}
LinkingSec->DataSize = Obj.linkingData().DataSize;
for (const wasm::WasmInitFunc &Func : Obj.linkingData().InitFunctions) {
WasmYAML::InitFunction F{Func.Priority, Func.Symbol};
LinkingSec->InitFunctions.emplace_back(F);
5 changes: 0 additions & 5 deletions tools/yaml2obj/yaml2wasm.cpp
Original file line number Diff line number Diff line change
@@ -136,11 +136,6 @@ int WasmWriter::writeSectionContent(raw_ostream &OS, WasmYAML::LinkingSection &S

SubSectionWriter SubSection(OS);

// DATA_SIZE subsection
encodeULEB128(wasm::WASM_DATA_SIZE, OS);
encodeULEB128(Section.DataSize, SubSection.GetStream());
SubSection.Done();

// SYMBOL_TABLE subsection
if (Section.SymbolTable.size()) {
encodeULEB128(wasm::WASM_SYMBOL_TABLE, OS);

0 comments on commit e14b248

Please sign in to comment.