Hi,
I investigate a debugging problem where it seems that some entries
in .debug_pubnames have faulty offsets. Not sure why, but it seems that
the debug information (C++, the compiler is Clang 3.5.2) is broken
The current code for handling this throws an exception (dwarfcache.c):
if (obj_offs >= unit_size) str_fmt_exception(ERR_INV_DWARF,
"Invalid object offset in %s section", pub_names->name);
For other errors, however the iteration of pubnames simply continues, and the
current pubname is ignored.
In my binary, the pubname string is valid (and non-empty).
I wonder if it would be possible to continue (and ignore the pubname) here as well,
if the name was read first. Reading the name I assume would be necessary to
keep iteration in sync? See diff below.
This would allow some debugging even though some .debug_pubnames entries would
not be found if offsets are broken.
Perhaps this is a bad workaround for broken debug information?
--- a/src/extensions/tcf-agent.mirror/tcf_agent/agent/tcf/services/dwarfcache.c
+++ b/src/extensions/tcf-agent.mirror/tcf_agent/agent/tcf/services/dwarfcache.c
@@ -1281,9 +1281,14 @@ static void load_pub_names(ELF_Section * debug_info, ELF_Section * pub_names) {
ObjectInfo * info = NULL;
U8_T obj_offs = dwarf64 ? dio_ReadU8() : (U8_T)dio_ReadU4();
if (obj_offs == 0) break;
- if (obj_offs >= unit_size) str_fmt_exception(ERR_INV_DWARF,
- "Invalid object offset in %s section", pub_names->name);
name = dio_ReadString();
+ if (obj_offs >= unit_size) {
+ trace(LOG_ALWAYS, "Invalid public name offset 0x%x for"
+ " '%s' in section '%s', CU 0x%x with size 0x%x",
+ obj_offs, name, pub_names->name, unit_addr,
+ unit_size);
+ continue;
+ }