[llvm-commits] [llvm] r139701 - in /llvm/trunk: lib/DebugInfo/DWARFDebugArangeSet.cpp tools/llvm-dwarfdump/llvm-dwarfdump.cpp
Benjamin Kramer
benny.kra at googlemail.com
Wed Sep 14 10:28:13 PDT 2011
Author: d0k
Date: Wed Sep 14 12:28:13 2011
New Revision: 139701
URL: http://llvm.org/viewvc/llvm-project?rev=139701&view=rev
Log:
llvm-dwarfdump: Make the "is debug info section" heuristic stricter so it doesn't accidentaly picks up the wrong section.
Also add some validation code to the aranges section parser.
Fixes PR10926.
Modified:
llvm/trunk/lib/DebugInfo/DWARFDebugArangeSet.cpp
llvm/trunk/tools/llvm-dwarfdump/llvm-dwarfdump.cpp
Modified: llvm/trunk/lib/DebugInfo/DWARFDebugArangeSet.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARFDebugArangeSet.cpp?rev=139701&r1=139700&r2=139701&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/DWARFDebugArangeSet.cpp (original)
+++ llvm/trunk/lib/DebugInfo/DWARFDebugArangeSet.cpp Wed Sep 14 12:28:13 2011
@@ -72,6 +72,13 @@
Header.AddrSize = data.getU8(offset_ptr);
Header.SegSize = data.getU8(offset_ptr);
+ // Perform basic validation of the header fields.
+ if (!data.isValidOffsetForDataOfSize(Offset, Header.Length) ||
+ (Header.AddrSize != 4 && Header.AddrSize != 8)) {
+ clear();
+ return false;
+ }
+
// The first tuple following the header in each set begins at an offset
// that is a multiple of the size of a single tuple (that is, twice the
// size of an address). The header is padded, if necessary, to the
Modified: llvm/trunk/tools/llvm-dwarfdump/llvm-dwarfdump.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-dwarfdump/llvm-dwarfdump.cpp?rev=139701&r1=139700&r2=139701&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-dwarfdump/llvm-dwarfdump.cpp (original)
+++ llvm/trunk/tools/llvm-dwarfdump/llvm-dwarfdump.cpp Wed Sep 14 12:28:13 2011
@@ -62,13 +62,17 @@
i->getName(name);
StringRef data;
i->getContents(data);
- if (name.endswith("debug_info"))
+
+ if (name.startswith("__DWARF,"))
+ name = name.substr(8); // Skip "__DWARF," prefix.
+ name = name.substr(name.find_first_not_of("._")); // Skip . and _ prefixes.
+ if (name == "debug_info")
DebugInfoSection = data;
- else if (name.endswith("debug_abbrev"))
+ else if (name == "debug_abbrev")
DebugAbbrevSection = data;
- else if (name.endswith("debug_line"))
+ else if (name == "debug_line")
DebugLineSection = data;
- else if (name.endswith("debug_aranges"))
+ else if (name == "debug_aranges")
DebugArangesSection = data;
}
More information about the llvm-commits
mailing list