Skip to content

Commit

Permalink
[DWARF] Correctly update .debug_addr DWARF section.
Browse files Browse the repository at this point in the history
This is a minimal patch to add support for also updating the addresses
stored in the .debug_addr DWARF section, which is used to perform
address resolution at debug time with debug fission. This is minimal in
the sence that it only supports the pre-DWARFv5 .debug_addr format that
is emitted by Emscripten currently, and which only consists of a simple
list of addresses.

Ideally the copy of DWARFYAML in the Binaryen tree should be updated
with LLVM ToT at some point, which will provide full support for DWARFv5
index tables, including the new .debug_addr format.

Ref: WebAssembly#3460
Ref: emscripten-core/emscripten#13099
Bug: https://crbug.com/1161422
  • Loading branch information
bmeurer committed Dec 23, 2020
1 parent dc4288c commit 5ca145c
Show file tree
Hide file tree
Showing 10 changed files with 13,175 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ full changeset diff at the end of each section.
Current Trunk
-------------

- `.debug_addr` sections (pre-DWARFv5) are now updated correctly when
DWARF mode is enabled.
- `RefFunc` C and JS API constructors (`BinaryenRefFunc` and `ref.func`
respectively) now take an extra `type` parameter, similar to `RefNull`. This
is necessary for typed function references support.
Expand Down
15 changes: 15 additions & 0 deletions src/wasm/wasm-debug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1045,6 +1045,19 @@ static void updateLoc(llvm::DWARFYAML::Data& yaml,
}
}

static void updateAddr(llvm::DWARFYAML::Data& yaml,
const LocationUpdater& locationUpdater) {
for (auto& addrTable : yaml.DebugAddr) {
for (auto& addr : addrTable.Addrs) {
BinaryLocation start = addr, newStart = 0;
if (!isTombstone(start)) {
newStart = locationUpdater.getNewStart(start);
}
addr = newStart;
}
}
}

void writeDWARFSections(Module& wasm, const BinaryLocations& newLocations) {
BinaryenDWARFInfo info(wasm);

Expand All @@ -1064,6 +1077,8 @@ void writeDWARFSections(Module& wasm, const BinaryLocations& newLocations) {

updateLoc(data, locationUpdater);

updateAddr(data, locationUpdater);

// Convert to binary sections.
auto newSections =
EmitDebugSections(data, false /* EmitFixups for debug_info */);
Expand Down
Loading

0 comments on commit 5ca145c

Please sign in to comment.