1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-22 18:54:02 +01:00

[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 cbd1ba2fe2
commit b53932efa7
24 changed files with 3 additions and 43 deletions

View File

@ -158,7 +158,6 @@ struct WasmFunctionName {
}; };
struct WasmLinkingData { struct WasmLinkingData {
uint32_t DataSize;
std::vector<WasmInitFunc> InitFunctions; std::vector<WasmInitFunc> InitFunctions;
std::vector<WasmSymbolInfo> SymbolTable; std::vector<WasmSymbolInfo> SymbolTable;
}; };
@ -227,7 +226,6 @@ enum : unsigned {
// Kind codes used in the custom "linking" section // Kind codes used in the custom "linking" section
enum : unsigned { enum : unsigned {
WASM_DATA_SIZE = 0x3,
WASM_SEGMENT_INFO = 0x5, WASM_SEGMENT_INFO = 0x5,
WASM_INIT_FUNCS = 0x6, WASM_INIT_FUNCS = 0x6,
WASM_COMDAT_INFO = 0x7, WASM_COMDAT_INFO = 0x7,

View File

@ -195,7 +195,6 @@ struct LinkingSection : CustomSection {
return C && C->Name == "linking"; return C && C->Name == "linking";
} }
uint32_t DataSize;
std::vector<SymbolInfo> SymbolTable; std::vector<SymbolInfo> SymbolTable;
std::vector<SegmentInfo> SegmentInfos; std::vector<SegmentInfo> SegmentInfos;
std::vector<InitFunction> InitFunctions; std::vector<InitFunction> InitFunctions;

View File

@ -274,7 +274,7 @@ private:
void writeCodeRelocSection(); void writeCodeRelocSection();
void writeDataRelocSection(); void writeDataRelocSection();
void writeLinkingMetaDataSection( void writeLinkingMetaDataSection(
uint32_t DataSize, ArrayRef<wasm::WasmSymbolInfo> SymbolInfos, ArrayRef<wasm::WasmSymbolInfo> SymbolInfos,
ArrayRef<std::pair<uint16_t, uint32_t>> InitFuncs, ArrayRef<std::pair<uint16_t, uint32_t>> InitFuncs,
const std::map<StringRef, std::vector<WasmComdatEntry>> &Comdats); const std::map<StringRef, std::vector<WasmComdatEntry>> &Comdats);
@ -862,7 +862,7 @@ void WasmObjectWriter::writeDataRelocSection() {
} }
void WasmObjectWriter::writeLinkingMetaDataSection( void WasmObjectWriter::writeLinkingMetaDataSection(
uint32_t DataSize, ArrayRef<wasm::WasmSymbolInfo> SymbolInfos, ArrayRef<wasm::WasmSymbolInfo> SymbolInfos,
ArrayRef<std::pair<uint16_t, uint32_t>> InitFuncs, ArrayRef<std::pair<uint16_t, uint32_t>> InitFuncs,
const std::map<StringRef, std::vector<WasmComdatEntry>> &Comdats) { const std::map<StringRef, std::vector<WasmComdatEntry>> &Comdats) {
SectionBookkeeping Section; SectionBookkeeping Section;
@ -897,12 +897,6 @@ void WasmObjectWriter::writeLinkingMetaDataSection(
endSection(SubSection); endSection(SubSection);
} }
if (DataSize > 0) {
startSection(SubSection, wasm::WASM_DATA_SIZE);
encodeULEB128(DataSize, getStream());
endSection(SubSection);
}
if (DataSegments.size()) { if (DataSegments.size()) {
startSection(SubSection, wasm::WASM_SEGMENT_INFO); startSection(SubSection, wasm::WASM_SEGMENT_INFO);
encodeULEB128(DataSegments.size(), getStream()); encodeULEB128(DataSegments.size(), getStream());
@ -1316,7 +1310,7 @@ void WasmObjectWriter::writeObject(MCAssembler &Asm,
writeDataSection(); writeDataSection();
writeCodeRelocSection(); writeCodeRelocSection();
writeDataRelocSection(); writeDataRelocSection();
writeLinkingMetaDataSection(DataSize, SymbolInfos, InitFuncs, Comdats); writeLinkingMetaDataSection(SymbolInfos, InitFuncs, Comdats);
// TODO: Translate the .comment section to the output. // TODO: Translate the .comment section to the output.
// TODO: Translate debug sections 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) WasmObjectFile::WasmObjectFile(MemoryBufferRef Buffer, Error &Err)
: ObjectFile(Binary::ID_Wasm, Buffer) { : ObjectFile(Binary::ID_Wasm, Buffer) {
LinkingData.DataSize = 0;
ErrorAsOutParameter ErrAsOutParam(&Err); ErrorAsOutParameter ErrAsOutParam(&Err);
Header.Magic = getData().substr(0, 4); Header.Magic = getData().substr(0, 4);
if (Header.Magic != StringRef("\0asm", 4)) { if (Header.Magic != StringRef("\0asm", 4)) {
@ -334,9 +332,6 @@ Error WasmObjectFile::parseLinkingSection(const uint8_t *Ptr,
if (Error Err = parseLinkingSectionSymtab(Ptr, SubSectionEnd)) if (Error Err = parseLinkingSectionSymtab(Ptr, SubSectionEnd))
return Err; return Err;
break; break;
case wasm::WASM_DATA_SIZE:
LinkingData.DataSize = readVaruint32(Ptr);
break;
case wasm::WASM_SEGMENT_INFO: { case wasm::WASM_SEGMENT_INFO: {
uint32_t Count = readVaruint32(Ptr); uint32_t Count = readVaruint32(Ptr);
if (Count > DataSegments.size()) 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) { static void sectionMapping(IO &IO, WasmYAML::LinkingSection &Section) {
commonSectionMapping(IO, Section); commonSectionMapping(IO, Section);
IO.mapRequired("Name", Section.Name); IO.mapRequired("Name", Section.Name);
IO.mapRequired("DataSize", Section.DataSize);
IO.mapOptional("SymbolTable", Section.SymbolTable); IO.mapOptional("SymbolTable", Section.SymbolTable);
IO.mapOptional("SegmentInfo", Section.SegmentInfos); IO.mapOptional("SegmentInfo", Section.SegmentInfos);
IO.mapOptional("InitFunctions", Section.InitFunctions); IO.mapOptional("InitFunctions", Section.InitFunctions);

View File

@ -14,7 +14,6 @@ target triple = "wasm32-unknown-unknown-wasm"
; CHECK: - Type: CUSTOM ; CHECK: - Type: CUSTOM
; CHECK-NEXT: Name: linking ; CHECK-NEXT: Name: linking
; CHECK-NEXT: DataSize: 2
; CHECK-NEXT: SymbolTable: ; CHECK-NEXT: SymbolTable:
; CHECK-NEXT: - Index: 0 ; CHECK-NEXT: - Index: 0
; CHECK-NEXT: Kind: DATA ; CHECK-NEXT: Kind: DATA

View File

@ -37,7 +37,6 @@ target triple = "wasm32-unknown-unknown-wasm"
; CHECK-NEXT: Content: '' ; CHECK-NEXT: Content: ''
; CHECK-NEXT: - Type: CUSTOM ; CHECK-NEXT: - Type: CUSTOM
; CHECK-NEXT: Name: linking ; CHECK-NEXT: Name: linking
; CHECK-NEXT: DataSize: 8
; CHECK-NEXT: SymbolTable: ; CHECK-NEXT: SymbolTable:
; CHECK-NEXT: - Index: 0 ; CHECK-NEXT: - Index: 0
; CHECK-NEXT: Kind: DATA ; CHECK-NEXT: Kind: DATA

View File

@ -75,7 +75,6 @@ define linkonce_odr i32 @sharedFn() #1 comdat($sharedComdat) {
; CHECK-NEXT: Content: '616263' ; CHECK-NEXT: Content: '616263'
; CHECK-NEXT: - Type: CUSTOM ; CHECK-NEXT: - Type: CUSTOM
; CHECK-NEXT: Name: linking ; CHECK-NEXT: Name: linking
; CHECK-NEXT: DataSize: 3
; CHECK-NEXT: SymbolTable: ; CHECK-NEXT: SymbolTable:
; CHECK-NEXT: - Index: 0 ; CHECK-NEXT: - Index: 0
; CHECK-NEXT: Kind: FUNCTION ; CHECK-NEXT: Kind: FUNCTION

View File

@ -32,7 +32,6 @@ target triple = "wasm32-unknown-unknown-wasm"
; CHECK-NEXT: Content: '08000000' ; CHECK-NEXT: Content: '08000000'
; CHECK-NEXT: - Type: CUSTOM ; CHECK-NEXT: - Type: CUSTOM
; CHECK-NEXT: Name: linking ; CHECK-NEXT: Name: linking
; CHECK-NEXT: DataSize: 28
; CHECK-NEXT: SymbolTable: ; CHECK-NEXT: SymbolTable:
; CHECK-NEXT: - Index: 0 ; CHECK-NEXT: - Index: 0
; CHECK-NEXT: Kind: DATA ; CHECK-NEXT: Kind: DATA

View File

@ -110,7 +110,6 @@ declare void @func3()
; CHECK-NEXT: Content: '01040000' ; CHECK-NEXT: Content: '01040000'
; CHECK-NEXT: - Type: CUSTOM ; CHECK-NEXT: - Type: CUSTOM
; CHECK-NEXT: Name: linking ; CHECK-NEXT: Name: linking
; CHECK-NEXT: DataSize: 4
; CHECK-NEXT: SymbolTable: ; CHECK-NEXT: SymbolTable:
; CHECK-NEXT: - Index: 0 ; CHECK-NEXT: - Index: 0
; CHECK-NEXT: Kind: FUNCTION ; CHECK-NEXT: Kind: FUNCTION

View File

@ -44,7 +44,6 @@ target triple = "wasm32-unknown-unknown-wasm"
; CHECK-NEXT: Content: '06000000' ; CHECK-NEXT: Content: '06000000'
; CHECK-NEXT: - Type: CUSTOM ; CHECK-NEXT: - Type: CUSTOM
; CHECK-NEXT: Name: linking ; CHECK-NEXT: Name: linking
; CHECK-NEXT: DataSize: 28
; CHECK-NEXT: SymbolTable: ; CHECK-NEXT: SymbolTable:
; CHECK-NEXT: - Index: 0 ; CHECK-NEXT: - Index: 0
; CHECK-NEXT: Kind: DATA ; CHECK-NEXT: Kind: DATA

View File

@ -16,7 +16,6 @@ entry:
; CHECK: - Type: CUSTOM ; CHECK: - Type: CUSTOM
; CHECK-NEXT: Name: linking ; CHECK-NEXT: Name: linking
; CHECK-NEXT: DataSize: 0
; CHECK-NEXT: SymbolTable: ; CHECK-NEXT: SymbolTable:
; CHECK-NEXT: - Index: 0 ; CHECK-NEXT: - Index: 0
; CHECK-NEXT: Kind: FUNCTION ; CHECK-NEXT: Kind: FUNCTION

View File

@ -138,7 +138,6 @@ entry:
; CHECK-NEXT: Content: '01000000' ; CHECK-NEXT: Content: '01000000'
; CHECK-NEXT: - Type: CUSTOM ; CHECK-NEXT: - Type: CUSTOM
; CHECK-NEXT: Name: linking ; CHECK-NEXT: Name: linking
; CHECK-NEXT: DataSize: 20
; CHECK-NEXT: SymbolTable: ; CHECK-NEXT: SymbolTable:
; CHECK-NEXT: - Index: 0 ; CHECK-NEXT: - Index: 0
; CHECK-NEXT: Kind: FUNCTION ; CHECK-NEXT: Kind: FUNCTION

View File

@ -22,7 +22,6 @@ entry:
; CHECK: - Type: CUSTOM ; CHECK: - Type: CUSTOM
; CHECK-NEXT: Name: linking ; CHECK-NEXT: Name: linking
; CHECK-NEXT: DataSize: 0
; CHECK-NEXT: SymbolTable: ; CHECK-NEXT: SymbolTable:
; CHECK-NEXT: - Index: 0 ; CHECK-NEXT: - Index: 0
; CHECK-NEXT: Kind: DATA ; CHECK-NEXT: Kind: DATA

View File

@ -651,7 +651,6 @@ WASM-NEXT: FileHeader:
WASM-NEXT: Version: 0x00000001 WASM-NEXT: Version: 0x00000001
WASM: - Type: CUSTOM WASM: - Type: CUSTOM
WASM-NEXT: Name: linking WASM-NEXT: Name: linking
WASM-NEXT: DataSize: 20
WASM-NEXT: SymbolTable: WASM-NEXT: SymbolTable:
WASM-NEXT: - Index: 0 WASM-NEXT: - Index: 0
WASM-NEXT: Kind: FUNCTION WASM-NEXT: Kind: FUNCTION

View File

@ -29,7 +29,6 @@ Sections:
Content: '11110000' Content: '11110000'
- Type: CUSTOM - Type: CUSTOM
Name: linking Name: linking
DataSize: 999
SymbolTable: SymbolTable:
- Index: 0 - Index: 0
Kind: FUNCTION Kind: FUNCTION
@ -51,7 +50,6 @@ Sections:
... ...
# CHECK: - Type: CUSTOM # CHECK: - Type: CUSTOM
# CHECK-NEXT: Name: linking # CHECK-NEXT: Name: linking
# CHECK-NEXT: DataSize: 999
# CHECK-NEXT: SymbolTable: # CHECK-NEXT: SymbolTable:
# CHECK-NEXT: - Index: 0 # CHECK-NEXT: - Index: 0
# CHECK-NEXT: Kind: FUNCTION # CHECK-NEXT: Kind: FUNCTION

View File

@ -36,7 +36,6 @@ Sections:
Body: 00 Body: 00
- Type: CUSTOM - Type: CUSTOM
Name: linking Name: linking
DataSize: 10
SymbolTable: SymbolTable:
- Index: 0 - Index: 0
Kind: FUNCTION Kind: FUNCTION
@ -63,7 +62,6 @@ Sections:
# CHECK: Index: 0 # CHECK: Index: 0
# CHECK: - Type: CUSTOM # CHECK: - Type: CUSTOM
# CHECK: Name: linking # CHECK: Name: linking
# CHECK: DataSize: 10
# CHECK: SymbolTable: # CHECK: SymbolTable:
# CHECK: - Index: 0 # CHECK: - Index: 0
# CHECK: Kind: FUNCTION # CHECK: Kind: FUNCTION

View File

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

View File

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

View File

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

View File

@ -537,6 +537,5 @@ WASM-NEXT: Type: CUSTOM (0x0)
WASM-NEXT: Size: 72 WASM-NEXT: Size: 72
WASM-NEXT: Offset: 220 WASM-NEXT: Offset: 220
WASM-NEXT: Name: linking WASM-NEXT: Name: linking
WASM-NEXT: DataSize: 13
WASM-NEXT: } WASM-NEXT: }
WASM-NEXT: ] WASM-NEXT: ]

View File

@ -153,7 +153,6 @@ void WasmDumper::printSections() {
W.printString("Name", WasmSec.Name); W.printString("Name", WasmSec.Name);
if (WasmSec.Name == "linking") { if (WasmSec.Name == "linking") {
const wasm::WasmLinkingData &LinkingData = Obj->linkingData(); const wasm::WasmLinkingData &LinkingData = Obj->linkingData();
W.printNumber("DataSize", LinkingData.DataSize);
if (!LinkingData.InitFunctions.empty()) { if (!LinkingData.InitFunctions.empty()) {
ListScope Group(W, "InitFunctions"); ListScope Group(W, "InitFunctions");
for (const wasm::WasmInitFunc &F: LinkingData.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->SymbolTable.emplace_back(Info);
} }
LinkingSec->DataSize = Obj.linkingData().DataSize;
for (const wasm::WasmInitFunc &Func : Obj.linkingData().InitFunctions) { for (const wasm::WasmInitFunc &Func : Obj.linkingData().InitFunctions) {
WasmYAML::InitFunction F{Func.Priority, Func.Symbol}; WasmYAML::InitFunction F{Func.Priority, Func.Symbol};
LinkingSec->InitFunctions.emplace_back(F); LinkingSec->InitFunctions.emplace_back(F);

View File

@ -136,11 +136,6 @@ int WasmWriter::writeSectionContent(raw_ostream &OS, WasmYAML::LinkingSection &S
SubSectionWriter SubSection(OS); SubSectionWriter SubSection(OS);
// DATA_SIZE subsection
encodeULEB128(wasm::WASM_DATA_SIZE, OS);
encodeULEB128(Section.DataSize, SubSection.GetStream());
SubSection.Done();
// SYMBOL_TABLE subsection // SYMBOL_TABLE subsection
if (Section.SymbolTable.size()) { if (Section.SymbolTable.size()) {
encodeULEB128(wasm::WASM_SYMBOL_TABLE, OS); encodeULEB128(wasm::WASM_SYMBOL_TABLE, OS);