diff --git a/lld/test/wasm/debug-removed-fn.ll b/lld/test/wasm/debug-removed-fn.ll --- a/lld/test/wasm/debug-removed-fn.ll +++ b/lld/test/wasm/debug-removed-fn.ll @@ -1,11 +1,16 @@ ; RUN: llc -filetype=obj < %s -o %t.o ; RUN: wasm-ld %t.o --no-entry --export=foo -o %t.wasm -; RUN: llvm-dwarfdump -debug-line %t.wasm | FileCheck %s +; RUN: llvm-dwarfdump -debug-line -debug-ranges %t.wasm | FileCheck %s ; CHECK: Address ; CHECK: 0x0000000000000005 ; CHECK: 0x0000000000000000 +; CHECK: .debug_ranges contents: +; CHECK: 00000000 {{[0-9]+}} {{[0-9]+}} +; CHECK: 00000000 {{[0-9]+}} {{[0-9]+}} +; CHECK: 00000000 + ; ModuleID = 't.bc' target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128" target triple = "wasm32-unknown-unknown-wasm" diff --git a/lld/wasm/InputFiles.cpp b/lld/wasm/InputFiles.cpp --- a/lld/wasm/InputFiles.cpp +++ b/lld/wasm/InputFiles.cpp @@ -168,9 +168,11 @@ sym = symbols[reloc.Index]; // We can end up with relocations against non-live symbols. For example - // in debug sections. + // 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) {