Don't require the .debug_str section. It's only needed for DW_FORM_strp

attributes, but apparently those aren't generated by gcc 2.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31385 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Ingo Weinhold
2009-07-03 09:41:37 +00:00
parent b619e1873c
commit c93db3c16a
+8 -3
View File
@@ -74,9 +74,7 @@ DwarfFile::Load(const char* fileName)
// get the interesting sections // get the interesting sections
fDebugInfoSection = fElfFile->GetSection(".debug_info"); fDebugInfoSection = fElfFile->GetSection(".debug_info");
fDebugAbbrevSection = fElfFile->GetSection(".debug_abbrev"); fDebugAbbrevSection = fElfFile->GetSection(".debug_abbrev");
fDebugStringSection = fElfFile->GetSection(".debug_str"); if (fDebugInfoSection == NULL || fDebugAbbrevSection == NULL) {
if (fDebugInfoSection == NULL || fDebugAbbrevSection == NULL
|| fDebugStringSection == NULL) {
fprintf(stderr, "DwarfManager::File::Load(\"%s\"): no " fprintf(stderr, "DwarfManager::File::Load(\"%s\"): no "
".debug_info, .debug_abbrev, or .debug_str section.\n", ".debug_info, .debug_abbrev, or .debug_str section.\n",
fileName); fileName);
@@ -84,6 +82,7 @@ DwarfFile::Load(const char* fileName)
} }
// not mandatory sections // not mandatory sections
fDebugStringSection = fElfFile->GetSection(".debug_str");
fDebugRangesSection = fElfFile->GetSection(".debug_ranges"); fDebugRangesSection = fElfFile->GetSection(".debug_ranges");
fDebugLineSection = fElfFile->GetSection(".debug_line"); fDebugLineSection = fElfFile->GetSection(".debug_line");
@@ -477,6 +476,7 @@ DwarfFile::_ParseEntryAttributes(DataReader& dataReader,
break; break;
case DW_FORM_strp: case DW_FORM_strp:
{ {
if (fDebugStringSection != NULL) {
dwarf_off_t offset = dataReader.Read<dwarf_off_t>(0); dwarf_off_t offset = dataReader.Read<dwarf_off_t>(0);
if (offset >= fDebugStringSection->Size()) { if (offset >= fDebugStringSection->Size()) {
fprintf(stderr, "Invalid DW_FORM_strp offset: %lu\n", fprintf(stderr, "Invalid DW_FORM_strp offset: %lu\n",
@@ -485,6 +485,11 @@ DwarfFile::_ParseEntryAttributes(DataReader& dataReader,
} }
attributeValue.SetToString( attributeValue.SetToString(
(const char*)fDebugStringSection->Data() + offset); (const char*)fDebugStringSection->Data() + offset);
} else {
fprintf(stderr, "Invalid DW_FORM_strp: no string "
"section!\n");
return B_BAD_DATA;
}
break; break;
} }
case DW_FORM_udata: case DW_FORM_udata: