Skip to content

Correctly update .debug_addr DWARF section. #3461

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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