Hi Claes,
If the section is corrupted, it would be best to skip loading the whole section, not just some of the entries.
debug_pubnames section is optional, so the debugger will work OK without loading it.
Could you create a Bugzilla and attach the ELF file as the test case?
Thanks,
Eugene
From: tcf-dev-bounces@xxxxxxxxxxx [mailto:tcf-dev-bounces@xxxxxxxxxxx]
On Behalf Of Lillieskold, Claes
Sent: Wednesday, March 08, 2017 2:46 AM
To: TCF Development
Subject: [tcf-dev] Continue if invalid public symbol object offset
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;
+ }
----------------------------------------------------------------------
Intel Sweden AB
Registered Office: Isafjordsgatan 30B, 164 40 Kista, Stockholm, Sweden
Registration Number: 556189-6027
This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.