forked from OSchip/llvm-project
[lld][Wasm] Wasm-ld emits invalid .debug_ranges entries for non-live symbols
When the debug info contains a relocation against a dead symbol, wasm-ld may emit spurious range-list terminator entries (entries with Start==0 and End==0). This change fixes this by emitting the WasmRelocation Addend as End value for a non-live symbol. Reviewed by: sbc100, dblaikie Differential Revision: https://reviews.llvm.org/D74781
This commit is contained in:
parent
196286434d
commit
aff75e1a1f
|
@ -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 <End of list>
|
||||
|
||||
; ModuleID = 't.bc'
|
||||
target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128"
|
||||
target triple = "wasm32-unknown-unknown-wasm"
|
||||
|
|
|
@ -168,9 +168,11 @@ uint32_t ObjFile::calcNewValue(const WasmRelocation &reloc) const {
|
|||
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<FunctionSymbol>(sym) || isa<DataSymbol>(sym)) && !sym->isLive())
|
||||
return 0;
|
||||
return reloc.Addend;
|
||||
}
|
||||
|
||||
switch (reloc.Type) {
|
||||
|
|
Loading…
Reference in New Issue