When the debug info contains a relocation against a dead symbol, wasm-ld emits a range-list terminator entry (an entry with Start==0 and End==0).
This is not correct, because it incorrectly terminates the range list of that compilation unit, hiding the valid range entries that come after that invalid entry.
The behavior is different when compiling to native, in that case we get entries with Start==0 and End > 0:
.debug_ranges section
00004280 0000000000231030 000000000023105a
00004280 0000000000000000 0000000000000024
00004280 0000000000000000 000000000000007a
00004280 0000000000231060 00000000002310a7
...
while with Wasm we see range entries (0, 0) that spuriously terminate the sequence:
.debug_ranges contents:
00000000 000002ef 0000032d
00000000 00000357 00000360
00000000 <End of list>
00000028 000004ba 000004ff
00000028 00000576 000005c1
00000028 <End of list>
...
This patch fixes this problem by emitting the WasmRelocation Addend as End value for a non-live symbol.
I think this needs to be a wasm-ld test doesn't it?
I think it should live in lld/test/wasm. Also the test inputs should be .ll if possible to avoid depending on clang. Also, the first input can be inline within the test file itself (dbg-ranges-nonlive-symbols.ll).
Alternative we could modify an existing test.. wait there is already: lld/test/wasm/debug-removed-fn.ll. Is this change not already covered by that?