diff --git a/lld/wasm/InputFiles.cpp b/lld/wasm/InputFiles.cpp --- a/lld/wasm/InputFiles.cpp +++ b/lld/wasm/InputFiles.cpp @@ -167,10 +167,12 @@ if (reloc.Type != R_WASM_TYPE_INDEX_LEB) { sym = symbols[reloc.Index]; - // We can end up with relocations against non-live symbols. For example - // in debug sections. + // We can end up with relocations against non-live symbols. For example + // in debug sections. We return reloc.Addend because always returning zero + // causes the generation of spurious range-list terminators in the + // .debug_ranges section. if ((isa(sym) || isa(sym)) && !sym->isLive()) - return 0; + return reloc.Addend; } switch (reloc.Type) {