summaryrefslogtreecommitdiff
path: root/third_party/llvm-project/dwarf2yaml.cpp
diff options
context:
space:
mode:
authorAlon Zakai <azakai@google.com>2020-08-07 10:45:15 -0700
committerGitHub <noreply@github.com>2020-08-07 10:45:15 -0700
commita355a7ea6151d4bd6dbb7895317fba0f3e8e422f (patch)
tree5953bc902dfa2c968ba26b614ef8e39eb14e3f70 /third_party/llvm-project/dwarf2yaml.cpp
parentcdc38d3162eb62cb313704f264f17d230989084b (diff)
downloadbinaryen-a355a7ea6151d4bd6dbb7895317fba0f3e8e422f.tar.gz
binaryen-a355a7ea6151d4bd6dbb7895317fba0f3e8e422f.tar.bz2
binaryen-a355a7ea6151d4bd6dbb7895317fba0f3e8e422f.zip
DWARF: Fix debug_info references to the abbreviations section (#2997)
The previous code assumed that each compile unit had its own abbreviation section, and they are all in order. That's normally how LLVM emits things, but in #2992 there is a testcase in which linking of object files with IR files somehow ends up with a different order. The proper fix is to track the binary offsets of abbreviations in the abbreviation section. That section is comprised of null-terminated lists, which each CU has an offset to the beginning of. With those offsets, we can match things properly. Add a testcase that crashes without this, to prevent regressions. Fixes #2992 Fixes #3007
Diffstat (limited to 'third_party/llvm-project/dwarf2yaml.cpp')
-rw-r--r--third_party/llvm-project/dwarf2yaml.cpp2
1 files changed, 2 insertions, 0 deletions
diff --git a/third_party/llvm-project/dwarf2yaml.cpp b/third_party/llvm-project/dwarf2yaml.cpp
index 5e22e1989..7f160f7e5 100644
--- a/third_party/llvm-project/dwarf2yaml.cpp
+++ b/third_party/llvm-project/dwarf2yaml.cpp
@@ -27,6 +27,7 @@ void dumpDebugAbbrev(DWARFContext &DCtx, DWARFYAML::Data &Y) {
auto AbbrevSetPtr = DCtx.getDebugAbbrev();
if (AbbrevSetPtr) {
for (auto AbbrvDeclSet : *AbbrevSetPtr) {
+ auto ListOffset = AbbrvDeclSet.second.getOffset();
for (auto AbbrvDecl : AbbrvDeclSet.second) {
DWARFYAML::Abbrev Abbrv;
Abbrv.Code = AbbrvDecl.getCode();
@@ -41,6 +42,7 @@ void dumpDebugAbbrev(DWARFContext &DCtx, DWARFYAML::Data &Y) {
AttAbrv.Value = Attribute.getImplicitConstValue();
Abbrv.Attributes.push_back(AttAbrv);
}
+ Abbrv.ListOffset = ListOffset;
Y.AbbrevDecls.push_back(Abbrv);
}
// XXX BINARYEN: null-terminate the DeclSet. This is needed to separate