Index: lib/MC/WasmObjectWriter.cpp =================================================================== --- lib/MC/WasmObjectWriter.cpp +++ lib/MC/WasmObjectWriter.cpp @@ -492,9 +492,9 @@ WasmObjectWriter::getProvisionalValue(const WasmRelocationEntry &RelEntry) { const MCSymbolWasm *Sym = ResolveSymbol(*RelEntry.Symbol); - // For undefined symbols, use a hopefully invalid value. + // For undefined symbols, use zero if (!Sym->isDefined(/*SetUsed=*/false)) - return UINT32_MAX; + return 0; uint32_t GlobalIndex = SymbolIndices[Sym]; const WasmGlobal& Global = Globals[GlobalIndex - NumGlobalImports]; Index: test/MC/WebAssembly/external-data.ll =================================================================== --- test/MC/WebAssembly/external-data.ll +++ test/MC/WebAssembly/external-data.ll @@ -24,4 +24,4 @@ ; CHECK-NEXT: Offset: ; CHECK-NEXT: Opcode: I32_CONST ; CHECK-NEXT: Value: 8 -; CHECK-NEXT: Content: FFFFFFFF +; CHECK-NEXT: Content: '00000000' Index: test/MC/WebAssembly/init-fini-array.ll =================================================================== --- test/MC/WebAssembly/init-fini-array.ll +++ test/MC/WebAssembly/init-fini-array.ll @@ -113,11 +113,11 @@ ; CHECK-NEXT: - Locals: ; CHECK-NEXT: Body: 1080808080000B ; CHECK-NEXT: - Locals: -; CHECK-NEXT: Body: 0240418080808000410041FFFFFFFF7F1081808080000D000F0B00000B +; CHECK-NEXT: Body: 024041808080800041004180808080001081808080000D000F0B00000B ; CHECK-NEXT: - Locals: ; CHECK-NEXT: Body: 1082808080000B ; CHECK-NEXT: - Locals: -; CHECK-NEXT: Body: 0240418180808000410041FFFFFFFF7F1081808080000D000F0B00000B +; CHECK-NEXT: Body: 024041818080800041004180808080001081808080000D000F0B00000B ; CHECK-NEXT: - Type: DATA ; CHECK-NEXT: Segments: ; CHECK-NEXT: - SectionOffset: 6