diff --git a/crates/obj/src/builder.rs b/crates/obj/src/builder.rs index ef4f33e94534..bb8197efaf51 100644 --- a/crates/obj/src/builder.rs +++ b/crates/obj/src/builder.rs @@ -448,7 +448,9 @@ impl<'a> ObjectBuilder<'a> { let section_id = *dwarf_sections_ids.get(name).unwrap(); for reloc in relocs { let target_symbol = match reloc.target { - DwarfSectionRelocTarget::Func(index) => func_symbols[FuncIndex::new(index)], + DwarfSectionRelocTarget::Func(index) => { + func_symbols[module.local.func_index(DefinedFuncIndex::new(index))] + } DwarfSectionRelocTarget::Section(name) => { obj.section_symbol(*dwarf_sections_ids.get(name).unwrap()) } diff --git a/tests/all/debug/testsuite/fraction-norm.cc b/tests/all/debug/testsuite/fraction-norm.cc index c896c3823829..ef4aab66ba48 100644 --- a/tests/all/debug/testsuite/fraction-norm.cc +++ b/tests/all/debug/testsuite/fraction-norm.cc @@ -1,6 +1,6 @@ // Compile with: -// clang++ --target=wasm32 fraction-norm.cc -o fraction-norm.wasm -g \ -// -O0 -nostdlib -fdebug-prefix-map=$PWD=. +// clang++ --target=wasm32-wasi fraction-norm.cc -o fraction-norm.wasm -g \ +// -O0 -fdebug-prefix-map=$PWD=. struct Fraction { long numerator; @@ -32,9 +32,9 @@ void norm(Fraction &n) } } -extern "C" -void _start() +int main() { Fraction c = {6, 27}; norm(c); + return 0; } diff --git a/tests/all/debug/testsuite/fraction-norm.wasm b/tests/all/debug/testsuite/fraction-norm.wasm index 23f34181a512..14c730a0d874 100755 Binary files a/tests/all/debug/testsuite/fraction-norm.wasm and b/tests/all/debug/testsuite/fraction-norm.wasm differ