Skip to content

Commit

Permalink
Fix debug information relocation (when imports present) (#1997)
Browse files Browse the repository at this point in the history
  • Loading branch information
yurydelendik authored Jul 9, 2020
1 parent 5c35a96 commit c53b253
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
4 changes: 3 additions & 1 deletion crates/obj/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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())
}
Expand Down
8 changes: 4 additions & 4 deletions tests/all/debug/testsuite/fraction-norm.cc
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -32,9 +32,9 @@ void norm(Fraction &n)
}
}

extern "C"
void _start()
int main()
{
Fraction c = {6, 27};
norm(c);
return 0;
}
Binary file modified tests/all/debug/testsuite/fraction-norm.wasm
Binary file not shown.

0 comments on commit c53b253

Please sign in to comment.