[WebAssembly] Remove DataSize from linking metadata section

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

llvm-svn: 326267
This commit is contained in:
Sam Clegg 2018-02-27 23:57:37 +00:00
parent 48a533d005
commit 86b4a09a99
24 changed files with 3 additions and 43 deletions

View File

@ -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,

View File

@ -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;

View File

@ -274,7 +274,7 @@ private:
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.

View File

@ -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())

View File

@ -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);

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -37,7 +37,6 @@ Sections:
Content: '616263'
- Type: CUSTOM
Name: linking
DataSize: 3
SymbolTable:
- Index: 0
Kind: FUNCTION

View File

@ -25,7 +25,6 @@ Sections:
GlobalMutable: false
- Type: CUSTOM
Name: linking
DataSize: 3
SymbolTable:
- Index: 0
Kind: FUNCTION

View File

@ -48,7 +48,6 @@ Sections:
Content: '616263'
- Type: CUSTOM
Name: linking
DataSize: 3
SymbolTable:
- Index: 0
Kind: DATA

View File

@ -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: ]

View File

@ -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)

View File

@ -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);

View File

@ -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);