diff --git a/lld/wasm/InputFiles.cpp b/lld/wasm/InputFiles.cpp --- a/lld/wasm/InputFiles.cpp +++ b/lld/wasm/InputFiles.cpp @@ -188,11 +188,11 @@ sym = symbols[reloc.Index]; // 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. + // in debug sections. We return -1 as a tombstone value so this will not + // produce a valid range conflicting with ranges of actual code. + if ((isa(sym) || isa(sym)) && !sym->isLive()) - return reloc.Addend; + return -1; } switch (reloc.Type) {