diff options
author | Alon Zakai <azakai@google.com> | 2020-01-28 09:31:13 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-01-28 09:31:13 -0800 |
commit | b00f7f9b97631b214eff177b92639df6307db286 (patch) | |
tree | f94f584c5fc4af7bd44c0f8d23ba03319650bd9c /third_party/llvm-project/DWARFEmitter.cpp | |
parent | bfff812cdfe3caccbceee73cee168326d4b9dc63 (diff) | |
download | binaryen-b00f7f9b97631b214eff177b92639df6307db286.tar.gz binaryen-b00f7f9b97631b214eff177b92639df6307db286.tar.bz2 binaryen-b00f7f9b97631b214eff177b92639df6307db286.zip |
DWARF: Update DW_AT_stmt_list which are offsets into the debug_line section (#2628)
The debug_line section is the only one in which we change
sizes and so must update offsets. It turns out that there are such
offsets, DW_AT_stmt_list, so without updating them we can't
handle multi-unit dwarf files.
Diffstat (limited to 'third_party/llvm-project/DWARFEmitter.cpp')
-rw-r--r-- | third_party/llvm-project/DWARFEmitter.cpp | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/third_party/llvm-project/DWARFEmitter.cpp b/third_party/llvm-project/DWARFEmitter.cpp index b155fb807..92efcdfa0 100644 --- a/third_party/llvm-project/DWARFEmitter.cpp +++ b/third_party/llvm-project/DWARFEmitter.cpp @@ -256,8 +256,12 @@ static void EmitFileEntry(raw_ostream &OS, const DWARFYAML::File &File) { encodeULEB128(File.Length, OS); } -void DWARFYAML::EmitDebugLine(raw_ostream &RealOS, const DWARFYAML::Data &DI) { - for (const auto &LineTable : DI.DebugLines) { +// XXX BINARYEN: Refactor to an *Internal method that allows us to optionally +// compute the new lengths. +static void EmitDebugLineInternal(raw_ostream &RealOS, + const DWARFYAML::Data &DI, + std::vector<size_t>* computedLengths) { + for (auto &LineTable : DI.DebugLines) { // XXX BINARYEN We need to update each line table's length. Write to a // temp stream first, then get the size from that. std::string Buffer; @@ -348,11 +352,27 @@ void DWARFYAML::EmitDebugLine(raw_ostream &RealOS, const DWARFYAML::Data &DI) { if (Size >= UINT32_MAX) { llvm_unreachable("Table is too big"); } + if (computedLengths) { + computedLengths->push_back(Size); + } writeInteger((uint32_t)Size, RealOS, DI.IsLittleEndian); RealOS << OS.str(); } } +void DWARFYAML::EmitDebugLine(raw_ostream &RealOS, const DWARFYAML::Data &DI) { + EmitDebugLineInternal(RealOS, DI, nullptr); +} + +void DWARFYAML::ComputeDebugLine(Data &DI, + std::vector<size_t>& computedLengths) { + // TODO: Avoid writing out the data, or at least cache it so we don't need to + // do it again later. + std::string buffer; + llvm::raw_string_ostream tempStream(buffer); + EmitDebugLineInternal(tempStream, DI, &computedLengths); +} + using EmitFuncType = void (*)(raw_ostream &, const DWARFYAML::Data &); static void |