From 1663c9466f37ae123dad66dc863791d14bdf09dc Mon Sep 17 00:00:00 2001 From: Florian Hahn Date: Tue, 19 Mar 2019 20:37:06 +0000 Subject: [DwarfDebug] Skip entries to big for 16 bit size field in Dwarf < 5. Nothing prevents entries from being bigger than the 16 bit size field in Dwarf < 5. For entries that are too big, just emit an empty entry instead of crashing. This fixes PR41038. Reviewers: probinson, aprantl, davide Reviewed By: probinson Differential Revision: https://reviews.llvm.org/D59518 llvm-svn: 356514 --- llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp') diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp index 3e60f15a22d..0e0a5b24864 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp @@ -2037,8 +2037,14 @@ void DwarfDebug::emitDebugLocEntryLocation(const DebugLocStream::Entry &Entry, Asm->OutStreamer->AddComment("Loc expr size"); if (getDwarfVersion() >= 5) Asm->EmitULEB128(DebugLocs.getBytes(Entry).size()); - else + else if (DebugLocs.getBytes(Entry).size() <= std::numeric_limits::max()) Asm->emitInt16(DebugLocs.getBytes(Entry).size()); + else { + // The entry is too big to fit into 16 bit, drop it as there is nothing we + // can do. + Asm->emitInt16(0); + return; + } // Emit the entry. APByteStreamer Streamer(*Asm); emitDebugLocEntry(Streamer, Entry, CU); -- cgit v1.2.3