Index: test/wasm/alias.ll =================================================================== --- test/wasm/alias.ll +++ test/wasm/alias.ll @@ -88,9 +88,6 @@ ; CHECK-NEXT: Locals: ; CHECK-NEXT: Body: 0B ; CHECK-NEXT: - Type: CUSTOM -; CHECK-NEXT: Name: linking -; CHECK-NEXT: DataSize: 0 -; CHECK-NEXT: - Type: CUSTOM ; CHECK-NEXT: Name: name ; CHECK-NEXT: FunctionNames: ; CHECK-NEXT: - Index: 0 Index: test/wasm/call-indirect.ll =================================================================== --- test/wasm/call-indirect.ll +++ test/wasm/call-indirect.ll @@ -160,9 +160,6 @@ ; CHECK-NEXT: Value: 1024 ; CHECK-NEXT: Content: '010000000200000002000000' ; CHECK-NEXT: - Type: CUSTOM -; CHECK-NEXT: Name: linking -; CHECK-NEXT: DataSize: 12 -; CHECK-NEXT: - Type: CUSTOM ; CHECK-NEXT: Name: name ; CHECK-NEXT: FunctionNames: ; CHECK-NEXT: - Index: 0 Index: test/wasm/data-layout.ll =================================================================== --- test/wasm/data-layout.ll +++ test/wasm/data-layout.ll @@ -91,7 +91,3 @@ ; RELOC-NEXT: Opcode: I32_CONST ; RELOC-NEXT: Value: 28 ; RELOC-NEXT: Content: 68656C6C6F0A00 - -; RELOC: - Type: CUSTOM -; RELOC-NEXT: Name: linking -; RELOC-NEXT: DataSize: 35 Index: test/wasm/function-imports-first.ll =================================================================== --- test/wasm/function-imports-first.ll +++ test/wasm/function-imports-first.ll @@ -37,9 +37,6 @@ ; CHECK-NEXT: Locals: ; CHECK-NEXT: Body: 0B ; CHECK-NEXT: - Type: CUSTOM -; CHECK-NEXT: Name: linking -; CHECK-NEXT: DataSize: 0 -; CHECK-NEXT: - Type: CUSTOM ; CHECK-NEXT: Name: name ; CHECK-NEXT: FunctionNames: ; CHECK-NEXT: - Index: 0 Index: test/wasm/gc-sections.ll =================================================================== --- test/wasm/gc-sections.ll +++ test/wasm/gc-sections.ll @@ -47,9 +47,6 @@ ; CHECK-NEXT: Value: 1024 ; CHECK-NEXT: Content: '02000000' ; CHECK-NEXT: - Type: CUSTOM -; CHECK-NEXT: Name: linking -; CHECK-NEXT: DataSize: 4 -; CHECK-NEXT: - Type: CUSTOM ; CHECK-NEXT: Name: name ; CHECK-NEXT: FunctionNames: ; CHECK-NEXT: - Index: 0 @@ -85,9 +82,6 @@ ; NO-GC-NEXT: Value: 1024 ; NO-GC-NEXT: Content: '010000000000000002000000' ; NO-GC-NEXT: - Type: CUSTOM -; NO-GC-NEXT: Name: linking -; NO-GC-NEXT: DataSize: 12 -; NO-GC-NEXT: - Type: CUSTOM ; NO-GC-NEXT: Name: name ; NO-GC-NEXT: FunctionNames: ; NO-GC-NEXT: - Index: 0 Index: test/wasm/init-fini.ll =================================================================== --- test/wasm/init-fini.ll +++ test/wasm/init-fini.ll @@ -56,9 +56,6 @@ ; CHECK: Body: 100010011007100B100E100B10101000100A100B10120B ; CHECK-NEXT: - Type: CUSTOM -; CHECK-NEXT: Name: linking -; CHECK-NEXT: DataSize: 0 -; CHECK-NEXT: - Type: CUSTOM ; CHECK-NEXT: Name: name ; CHECK-NEXT: FunctionNames: ; CHECK-NEXT: - Index: 0 @@ -108,7 +105,6 @@ ; RUN: obj2yaml %t.reloc.wasm | FileCheck -check-prefix=RELOC %s ; RELOC: Name: linking -; RELOC-NEXT: DataSize: 0 ; RELOC-NEXT: SymbolInfo: ; RELOC-NEXT: - Name: __dso_handle ; RELOC-NEXT: Flags: [ BINDING_WEAK, VISIBILITY_HIDDEN ] Index: test/wasm/local-symbols.ll =================================================================== --- test/wasm/local-symbols.ll +++ test/wasm/local-symbols.ll @@ -106,9 +106,6 @@ ; CHECK-NEXT: Value: 1024 ; CHECK-NEXT: Content: '0100000003000000' ; CHECK-NEXT: - Type: CUSTOM -; CHECK-NEXT: Name: linking -; CHECK-NEXT: DataSize: 8 -; CHECK-NEXT: - Type: CUSTOM ; CHECK-NEXT: Name: name ; CHECK-NEXT: FunctionNames: ; CHECK-NEXT: - Index: 0 Index: test/wasm/locals-duplicate.test =================================================================== --- test/wasm/locals-duplicate.test +++ test/wasm/locals-duplicate.test @@ -184,9 +184,6 @@ ; CHECK-NEXT: Value: 1024 ; CHECK-NEXT: Content: '000000000000000000000000000000000000000000000000' ; CHECK-NEXT: - Type: CUSTOM -; CHECK-NEXT: Name: linking -; CHECK-NEXT: DataSize: 24 -; CHECK-NEXT: - Type: CUSTOM ; CHECK-NEXT: Name: name ; CHECK-NEXT: FunctionNames: ; CHECK-NEXT: - Index: 0 @@ -488,7 +485,6 @@ ; RELOC-NEXT: Content: '0000000000000000' ; RELOC-NEXT: - Type: CUSTOM ; RELOC-NEXT: Name: linking -; RELOC-NEXT: DataSize: 24 ; RELOC-NEXT: SymbolInfo: ; RELOC-NEXT: - Name: colliding_func1.1 ; RELOC-NEXT: Flags: [ BINDING_LOCAL ] Index: test/wasm/many-functions.ll =================================================================== --- test/wasm/many-functions.ll +++ test/wasm/many-functions.ll @@ -815,7 +815,6 @@ ; CHECK-NEXT: Content: '01000000' ; CHECK-NEXT: - Type: CUSTOM ; CHECK-NEXT: Name: linking -; CHECK-NEXT: DataSize: 8 ; CHECK-NEXT: SegmentInfo: ; CHECK-NEXT: - Index: 0 ; CHECK-NEXT: Name: .data.g0 Index: test/wasm/relocatable.ll =================================================================== --- test/wasm/relocatable.ll +++ test/wasm/relocatable.ll @@ -229,7 +229,6 @@ ; CHECK-NEXT: Content: '616263' ; CHECK-NEXT: - Type: CUSTOM ; CHECK-NEXT: Name: linking -; CHECK-NEXT: DataSize: 31 ; CHECK-NEXT: SymbolInfo: ; CHECK-NEXT: - Name: bar_import ; CHECK-NEXT: Flags: [ BINDING_WEAK ] Index: test/wasm/stack-pointer.ll =================================================================== --- test/wasm/stack-pointer.ll +++ test/wasm/stack-pointer.ll @@ -55,7 +55,6 @@ ; CHECK-NEXT: Body: 23808080800041106B1A41000B ; CHECK-NEXT: - Type: CUSTOM ; CHECK-NEXT: Name: linking -; CHECK-NEXT: DataSize: 0 ; CHECK-NEXT: - Type: CUSTOM ; CHECK-NEXT: Name: name ; CHECK-NEXT: FunctionNames: Index: test/wasm/weak-alias-overide.ll =================================================================== --- test/wasm/weak-alias-overide.ll +++ test/wasm/weak-alias-overide.ll @@ -141,9 +141,6 @@ ; CHECK-NEXT: Locals: ; CHECK-NEXT: Body: 0B ; CHECK-NEXT: - Type: CUSTOM -; CHECK-NEXT: Name: linking -; CHECK-NEXT: DataSize: 0 -; CHECK-NEXT: - Type: CUSTOM ; CHECK-NEXT: Name: name ; CHECK-NEXT: FunctionNames: ; CHECK-NEXT: - Index: 0 Index: test/wasm/weak-alias.ll =================================================================== --- test/wasm/weak-alias.ll +++ test/wasm/weak-alias.ll @@ -135,9 +135,6 @@ ; CHECK-NEXT: Locals: ; CHECK-NEXT: Body: 0B ; CHECK-NEXT: - Type: CUSTOM -; CHECK-NEXT: Name: linking -; CHECK-NEXT: DataSize: 0 -; CHECK-NEXT: - Type: CUSTOM ; CHECK-NEXT: Name: name ; CHECK-NEXT: FunctionNames: ; CHECK-NEXT: - Index: 0 @@ -285,7 +282,6 @@ ; RELOC-NEXT: Body: 23808080800041106B220024808080800020004181808080003602081081808080002101200041106A24808080800020010B ; RELOC-NEXT: - Type: CUSTOM ; RELOC-NEXT: Name: linking -; RELOC-NEXT: DataSize: 0 ; RELOC-NEXT: SymbolInfo: ; RELOC-NEXT: - Name: alias_fn ; RELOC-NEXT: Flags: [ BINDING_WEAK ] Index: test/wasm/weak-symbols.ll =================================================================== --- test/wasm/weak-symbols.ll +++ test/wasm/weak-symbols.ll @@ -127,9 +127,6 @@ ; CHECK-NEXT: Value: 1024 ; CHECK-NEXT: Content: '0100000002000000' ; CHECK-NEXT: - Type: CUSTOM -; CHECK-NEXT: Name: linking -; CHECK-NEXT: DataSize: 8 -; CHECK-NEXT: - Type: CUSTOM ; CHECK-NEXT: Name: name ; CHECK-NEXT: FunctionNames: ; CHECK-NEXT: - Index: 0 Index: test/wasm/weak-undefined.ll =================================================================== --- test/wasm/weak-undefined.ll +++ test/wasm/weak-undefined.ll @@ -113,7 +113,4 @@ ; CHECK-NEXT: - Index: 3 ; CHECK-NEXT: Locals: ; CHECK-NEXT: Body: 0B -; CHECK-NEXT: - Type: CUSTOM -; CHECK-NEXT: Name: linking -; CHECK-NEXT: DataSize: 0 ; CHECK-NEXT: ... Index: wasm/Writer.cpp =================================================================== --- wasm/Writer.cpp +++ wasm/Writer.cpp @@ -114,7 +114,6 @@ void writeSections(); uint64_t FileSize = 0; - uint32_t DataSize = 0; uint32_t NumMemoryPages = 0; std::vector Types; @@ -377,14 +376,6 @@ createSyntheticSection(WASM_SEC_CUSTOM, "linking"); raw_ostream &OS = Section->getStream(); - SubSection DataSizeSubSection(WASM_DATA_SIZE); - writeUleb128(DataSizeSubSection.getStream(), DataSize, "data size"); - DataSizeSubSection.finalizeContents(); - DataSizeSubSection.writeToStream(OS); - - if (!Config->Relocatable) - return; - std::vector> SymbolInfo; auto addSymInfo = [&](const Symbol *Sym, StringRef ExternalName) { uint32_t Flags = @@ -527,10 +518,8 @@ // - heap start / unallocated void Writer::layoutMemory() { uint32_t MemoryPtr = 0; - if (!Config->Relocatable) { - MemoryPtr = Config->GlobalBase; - debugPrint("mem: global base = %d\n", Config->GlobalBase); - } + MemoryPtr = Config->GlobalBase; + debugPrint("mem: global base = %d\n", Config->GlobalBase); createOutputSegments(); @@ -555,10 +544,7 @@ if (WasmSym::End) WasmSym::End->setVirtualAddress(MemoryPtr); - DataSize = MemoryPtr; - if (!Config->Relocatable) - DataSize -= Config->GlobalBase; - debugPrint("mem: static data = %d\n", DataSize); + debugPrint("mem: static data = %d\n", MemoryPtr - Config->GlobalBase); // Stack comes after static data and bss if (!Config->Relocatable) { @@ -605,9 +591,10 @@ createDataSection(); // Custom sections - if (Config->Relocatable) + if (Config->Relocatable) { createRelocSections(); - createLinkingSection(); + createLinkingSection(); + } if (!Config->StripDebug && !Config->StripAll) createNameSection(); @@ -889,6 +876,9 @@ } void Writer::run() { + if (Config->Relocatable) + Config->GlobalBase = 0; + log("-- calculateImports"); calculateImports(); log("-- assignIndexes");