From 1c0b24f91a5a6f3aeca483e753e7fd27357ecb71 Mon Sep 17 00:00:00 2001 From: Benjamin Kramer Date: Wed, 14 Sep 2011 17:28:13 +0000 Subject: 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@139701 91177308-0d34-0410-b5e6-96231b3b80d8 --- tools/llvm-dwarfdump/llvm-dwarfdump.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'tools/llvm-dwarfdump/llvm-dwarfdump.cpp') diff --git a/tools/llvm-dwarfdump/llvm-dwarfdump.cpp b/tools/llvm-dwarfdump/llvm-dwarfdump.cpp index 076dcd10fb..ef9a47b959 100644 --- a/tools/llvm-dwarfdump/llvm-dwarfdump.cpp +++ b/tools/llvm-dwarfdump/llvm-dwarfdump.cpp @@ -62,13 +62,17 @@ static void DumpInput(const StringRef &Filename) { 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; } -- cgit v1.2.3