Skip to content

Commit 5ca145c

Browse files
committed
[DWARF] Correctly update .debug_addr DWARF section.
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: #3460 Ref: emscripten-core/emscripten#13099 Bug: https://crbug.com/1161422
1 parent dc4288c commit 5ca145c

File tree

10 files changed

+13175
-0
lines changed

10 files changed

+13175
-0
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ full changeset diff at the end of each section.
1515
Current Trunk
1616
-------------
1717

18+
- `.debug_addr` sections (pre-DWARFv5) are now updated correctly when
19+
DWARF mode is enabled.
1820
- `RefFunc` C and JS API constructors (`BinaryenRefFunc` and `ref.func`
1921
respectively) now take an extra `type` parameter, similar to `RefNull`. This
2022
is necessary for typed function references support.

src/wasm/wasm-debug.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1045,6 +1045,19 @@ static void updateLoc(llvm::DWARFYAML::Data& yaml,
10451045
}
10461046
}
10471047

1048+
static void updateAddr(llvm::DWARFYAML::Data& yaml,
1049+
const LocationUpdater& locationUpdater) {
1050+
for (auto& addrTable : yaml.DebugAddr) {
1051+
for (auto& addr : addrTable.Addrs) {
1052+
BinaryLocation start = addr, newStart = 0;
1053+
if (!isTombstone(start)) {
1054+
newStart = locationUpdater.getNewStart(start);
1055+
}
1056+
addr = newStart;
1057+
}
1058+
}
1059+
}
1060+
10481061
void writeDWARFSections(Module& wasm, const BinaryLocations& newLocations) {
10491062
BinaryenDWARFInfo info(wasm);
10501063

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

10651078
updateLoc(data, locationUpdater);
10661079

1080+
updateAddr(data, locationUpdater);
1081+
10671082
// Convert to binary sections.
10681083
auto newSections =
10691084
EmitDebugSections(data, false /* EmitFixups for debug_info */);

0 commit comments

Comments
 (0)