llvm.org GIT mirror llvm / e14b248
[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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@326267 91177308-0d34-0410-b5e6-96231b3b80d8 Sam Clegg 1 year, 5 months ago
24 changed file(s) with 3 addition(s) and 43 deletion(s). Raw diff Collapse all Expand all
157157 };
158158
159159 struct WasmLinkingData {
160 uint32_t DataSize;
161160 std::vector InitFunctions;
162161 std::vector SymbolTable;
163162 };
226225
227226 // Kind codes used in the custom "linking" section
228227 enum : unsigned {
229 WASM_DATA_SIZE = 0x3,
230228 WASM_SEGMENT_INFO = 0x5,
231229 WASM_INIT_FUNCS = 0x6,
232230 WASM_COMDAT_INFO = 0x7,
194194 return C && C->Name == "linking";
195195 }
196196
197 uint32_t DataSize;
198197 std::vector SymbolTable;
199198 std::vector SegmentInfos;
200199 std::vector InitFunctions;
273273 void writeCodeRelocSection();
274274 void writeDataRelocSection();
275275 void writeLinkingMetaDataSection(
276 uint32_t DataSize, ArrayRef SymbolInfos,
276 ArrayRef SymbolInfos,
277277 ArrayRef> InitFuncs,
278278 const std::map> &Comdats);
279279
861861 }
862862
863863 void WasmObjectWriter::writeLinkingMetaDataSection(
864 uint32_t DataSize, ArrayRef SymbolInfos,
864 ArrayRef SymbolInfos,
865865 ArrayRef> InitFuncs,
866866 const std::map> &Comdats) {
867867 SectionBookkeeping Section;
893893 llvm_unreachable("unexpected kind");
894894 }
895895 }
896 endSection(SubSection);
897 }
898
899 if (DataSize > 0) {
900 startSection(SubSection, wasm::WASM_DATA_SIZE);
901 encodeULEB128(DataSize, getStream());
902896 endSection(SubSection);
903897 }
904898
13151309 writeDataSection();
13161310 writeCodeRelocSection();
13171311 writeDataRelocSection();
1318 writeLinkingMetaDataSection(DataSize, SymbolInfos, InitFuncs, Comdats);
1312 writeLinkingMetaDataSection(SymbolInfos, InitFuncs, Comdats);
13191313
13201314 // TODO: Translate the .comment section to the output.
13211315 // TODO: Translate debug sections to the output.
196196
197197 WasmObjectFile::WasmObjectFile(MemoryBufferRef Buffer, Error &Err)
198198 : ObjectFile(Binary::ID_Wasm, Buffer) {
199 LinkingData.DataSize = 0;
200
201199 ErrorAsOutParameter ErrAsOutParam(&Err);
202200 Header.Magic = getData().substr(0, 4);
203201 if (Header.Magic != StringRef("\0asm", 4)) {
333331 if (Error Err = parseLinkingSectionSymtab(Ptr, SubSectionEnd))
334332 return Err;
335333 break;
336 case wasm::WASM_DATA_SIZE:
337 LinkingData.DataSize = readVaruint32(Ptr);
338 break;
339334 case wasm::WASM_SEGMENT_INFO: {
340335 uint32_t Count = readVaruint32(Ptr);
341336 if (Count > DataSegments.size())
5656 static void sectionMapping(IO &IO, WasmYAML::LinkingSection &Section) {
5757 commonSectionMapping(IO, Section);
5858 IO.mapRequired("Name", Section.Name);
59 IO.mapRequired("DataSize", Section.DataSize);
6059 IO.mapOptional("SymbolTable", Section.SymbolTable);
6160 IO.mapOptional("SegmentInfo", Section.SegmentInfos);
6261 IO.mapOptional("InitFunctions", Section.InitFunctions);
1313
1414 ; CHECK: - Type: CUSTOM
1515 ; CHECK-NEXT: Name: linking
16 ; CHECK-NEXT: DataSize: 2
1716 ; CHECK-NEXT: SymbolTable:
1817 ; CHECK-NEXT: - Index: 0
1918 ; CHECK-NEXT: Kind: DATA
3636 ; CHECK-NEXT: Content: ''
3737 ; CHECK-NEXT: - Type: CUSTOM
3838 ; CHECK-NEXT: Name: linking
39 ; CHECK-NEXT: DataSize: 8
4039 ; CHECK-NEXT: SymbolTable:
4140 ; CHECK-NEXT: - Index: 0
4241 ; CHECK-NEXT: Kind: DATA
7474 ; CHECK-NEXT: Content: '616263'
7575 ; CHECK-NEXT: - Type: CUSTOM
7676 ; CHECK-NEXT: Name: linking
77 ; CHECK-NEXT: DataSize: 3
7877 ; CHECK-NEXT: SymbolTable:
7978 ; CHECK-NEXT: - Index: 0
8079 ; CHECK-NEXT: Kind: FUNCTION
3131 ; CHECK-NEXT: Content: '08000000'
3232 ; CHECK-NEXT: - Type: CUSTOM
3333 ; CHECK-NEXT: Name: linking
34 ; CHECK-NEXT: DataSize: 28
3534 ; CHECK-NEXT: SymbolTable:
3635 ; CHECK-NEXT: - Index: 0
3736 ; CHECK-NEXT: Kind: DATA
109109 ; CHECK-NEXT: Content: '01040000'
110110 ; CHECK-NEXT: - Type: CUSTOM
111111 ; CHECK-NEXT: Name: linking
112 ; CHECK-NEXT: DataSize: 4
113112 ; CHECK-NEXT: SymbolTable:
114113 ; CHECK-NEXT: - Index: 0
115114 ; CHECK-NEXT: Kind: FUNCTION
4343 ; CHECK-NEXT: Content: '06000000'
4444 ; CHECK-NEXT: - Type: CUSTOM
4545 ; CHECK-NEXT: Name: linking
46 ; CHECK-NEXT: DataSize: 28
4746 ; CHECK-NEXT: SymbolTable:
4847 ; CHECK-NEXT: - Index: 0
4948 ; CHECK-NEXT: Kind: DATA
1515
1616 ; CHECK: - Type: CUSTOM
1717 ; CHECK-NEXT: Name: linking
18 ; CHECK-NEXT: DataSize: 0
1918 ; CHECK-NEXT: SymbolTable:
2019 ; CHECK-NEXT: - Index: 0
2120 ; CHECK-NEXT: Kind: FUNCTION
137137 ; CHECK-NEXT: Content: '01000000'
138138 ; CHECK-NEXT: - Type: CUSTOM
139139 ; CHECK-NEXT: Name: linking
140 ; CHECK-NEXT: DataSize: 20
141140 ; CHECK-NEXT: SymbolTable:
142141 ; CHECK-NEXT: - Index: 0
143142 ; CHECK-NEXT: Kind: FUNCTION
2121
2222 ; CHECK: - Type: CUSTOM
2323 ; CHECK-NEXT: Name: linking
24 ; CHECK-NEXT: DataSize: 0
2524 ; CHECK-NEXT: SymbolTable:
2625 ; CHECK-NEXT: - Index: 0
2726 ; CHECK-NEXT: Kind: DATA
650650 WASM-NEXT: Version: 0x00000001
651651 WASM: - Type: CUSTOM
652652 WASM-NEXT: Name: linking
653 WASM-NEXT: DataSize: 20
654653 WASM-NEXT: SymbolTable:
655654 WASM-NEXT: - Index: 0
656655 WASM-NEXT: Kind: FUNCTION
2828 Content: '11110000'
2929 - Type: CUSTOM
3030 Name: linking
31 DataSize: 999
3231 SymbolTable:
3332 - Index: 0
3433 Kind: FUNCTION
5049 ...
5150 # CHECK: - Type: CUSTOM
5251 # CHECK-NEXT: Name: linking
53 # CHECK-NEXT: DataSize: 999
5452 # CHECK-NEXT: SymbolTable:
5553 # CHECK-NEXT: - Index: 0
5654 # CHECK-NEXT: Kind: FUNCTION
3535 Body: 00
3636 - Type: CUSTOM
3737 Name: linking
38 DataSize: 10
3938 SymbolTable:
4039 - Index: 0
4140 Kind: FUNCTION
6261 # CHECK: Index: 0
6362 # CHECK: - Type: CUSTOM
6463 # CHECK: Name: linking
65 # CHECK: DataSize: 10
6664 # CHECK: SymbolTable:
6765 # CHECK: - Index: 0
6866 # CHECK: Kind: FUNCTION
3636 Content: '616263'
3737 - Type: CUSTOM
3838 Name: linking
39 DataSize: 3
4039 SymbolTable:
4140 - Index: 0
4241 Kind: FUNCTION
2424 GlobalMutable: false
2525 - Type: CUSTOM
2626 Name: linking
27 DataSize: 3
2827 SymbolTable:
2928 - Index: 0
3029 Kind: FUNCTION
4747 Content: '616263'
4848 - Type: CUSTOM
4949 Name: linking
50 DataSize: 3
5150 SymbolTable:
5251 - Index: 0
5352 Kind: DATA
536536 WASM-NEXT: Size: 72
537537 WASM-NEXT: Offset: 220
538538 WASM-NEXT: Name: linking
539 WASM-NEXT: DataSize: 13
540539 WASM-NEXT: }
541540 WASM-NEXT: ]
152152 W.printString("Name", WasmSec.Name);
153153 if (WasmSec.Name == "linking") {
154154 const wasm::WasmLinkingData &LinkingData = Obj->linkingData();
155 W.printNumber("DataSize", LinkingData.DataSize);
156155 if (!LinkingData.InitFunctions.empty()) {
157156 ListScope Group(W, "InitFunctions");
158157 for (const wasm::WasmInitFunc &F: LinkingData.InitFunctions)
108108 }
109109 LinkingSec->SymbolTable.emplace_back(Info);
110110 }
111 LinkingSec->DataSize = Obj.linkingData().DataSize;
112111 for (const wasm::WasmInitFunc &Func : Obj.linkingData().InitFunctions) {
113112 WasmYAML::InitFunction F{Func.Priority, Func.Symbol};
114113 LinkingSec->InitFunctions.emplace_back(F);
134134 writeStringRef(Section.Name, OS);
135135
136136 SubSectionWriter SubSection(OS);
137
138 // DATA_SIZE subsection
139 encodeULEB128(wasm::WASM_DATA_SIZE, OS);
140 encodeULEB128(Section.DataSize, SubSection.GetStream());
141 SubSection.Done();
142137
143138 // SYMBOL_TABLE subsection
144139 if (Section.SymbolTable.size()) {