summaryrefslogtreecommitdiff
path: root/third_party
diff options
context:
space:
mode:
authorPaolo Severini <paolosev@microsoft.com>2020-05-27 08:03:46 -0700
committerGitHub <noreply@github.com>2020-05-27 08:03:46 -0700
commita57ff3c61125b890dbd5f4937e6c9ea26c830cfc (patch)
treeb6bf2390b02deba82d9193e10fdc65b37e8af36c /third_party
parent25912210b32012bf64359a89baef4514a6b37205 (diff)
downloadbinaryen-a57ff3c61125b890dbd5f4937e6c9ea26c830cfc.tar.gz
binaryen-a57ff3c61125b890dbd5f4937e6c9ea26c830cfc.tar.bz2
binaryen-a57ff3c61125b890dbd5f4937e6c9ea26c830cfc.zip
Fix DWARF location list updating with nonzero compilation unit base addr (#2862)
In the .debug_loc section the Start/End address offsets in a location list are relative to the address of the compilation unit that refers that location list. There is a problem in function wasm::Debug:: updateLoc(), which compares these offsets with the actual module addresses of expressions and functions, causing the generation of invalid location lists. The fix is not trivial, because the DWARF debug_loc section does not specify which is the compilation unit associated to each location list entry. A simple workaround is to store, in LocationUpdater, a map of location list offsets to the base address of the compilation units referencing them, and that can be easily calculated in updateDIE().
Diffstat (limited to 'third_party')
-rw-r--r--third_party/llvm-project/dwarf2yaml.cpp3
-rw-r--r--third_party/llvm-project/include/llvm/ObjectYAML/DWARFYAML.h1
2 files changed, 4 insertions, 0 deletions
diff --git a/third_party/llvm-project/dwarf2yaml.cpp b/third_party/llvm-project/dwarf2yaml.cpp
index 52e875637..5e22e1989 100644
--- a/third_party/llvm-project/dwarf2yaml.cpp
+++ b/third_party/llvm-project/dwarf2yaml.cpp
@@ -120,6 +120,7 @@ void dumpDebugLoc(DWARFContext &DCtx, DWARFYAML::Data &Y) { // XXX BINARYEN
uint64_t offset = 0;
DWARFDebugLoc locList;
while (locsData.isValidOffset(offset)) {
+ uint64_t locListOffset = offset; // XXX BINARYEN
auto list = locList.parseOneLocationList(locsData, &offset);
if (!list) {
errs() << "debug_loc error\n";
@@ -132,11 +133,13 @@ void dumpDebugLoc(DWARFContext &DCtx, DWARFYAML::Data &Y) { // XXX BINARYEN
for (auto x : entry.Loc) {
loc.Location.push_back(x);
}
+ loc.CompileUnitOffset = locListOffset; // XXX BINARYEN
Y.Locs.push_back(loc);
}
DWARFYAML::Loc loc;
loc.Start = 0;
loc.End = 0;
+ loc.CompileUnitOffset = locListOffset; // XXX BINARYEN
Y.Locs.push_back(loc);
}
}
diff --git a/third_party/llvm-project/include/llvm/ObjectYAML/DWARFYAML.h b/third_party/llvm-project/include/llvm/ObjectYAML/DWARFYAML.h
index 948418c7b..bd4aa2007 100644
--- a/third_party/llvm-project/include/llvm/ObjectYAML/DWARFYAML.h
+++ b/third_party/llvm-project/include/llvm/ObjectYAML/DWARFYAML.h
@@ -82,6 +82,7 @@ struct Loc {
uint32_t Start;
uint32_t End;
std::vector<uint8_t> Location;
+ uint64_t CompileUnitOffset;
};
// XXX BINARYEN -->