Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEugene Tarassov2018-11-14 20:30:16 +0000
committerEugene Tarassov2018-11-14 20:30:16 +0000
commit9480886af764a51d5b1b419d0e7cf9f3fb2f6c15 (patch)
treef9bcaaf0d2a620553538e26643ce4c25b8d8c937 /agent/tcf/services
parent334f409c2ff1b0bbdfabb695b7a099dce65a6095 (diff)
downloadorg.eclipse.tcf.agent-9480886af764a51d5b1b419d0e7cf9f3fb2f6c15.tar.gz
org.eclipse.tcf.agent-9480886af764a51d5b1b419d0e7cf9f3fb2f6c15.tar.xz
org.eclipse.tcf.agent-9480886af764a51d5b1b419d0e7cf9f3fb2f6c15.zip
TCF Agent: DWARF reader: unlike GCC, IAR compiler does not align address range descriptors in the .debug_aranges section
Diffstat (limited to 'agent/tcf/services')
-rw-r--r--agent/tcf/services/dwarfcache.c23
-rw-r--r--agent/tcf/services/dwarfcache.h2
2 files changed, 24 insertions, 1 deletions
diff --git a/agent/tcf/services/dwarfcache.c b/agent/tcf/services/dwarfcache.c
index 0fcc707d..16af2b3b 100644
--- a/agent/tcf/services/dwarfcache.c
+++ b/agent/tcf/services/dwarfcache.c
@@ -906,6 +906,10 @@ static void read_object_info(U2_T Tag, U2_T Attr, U2_T Form) {
case AT_base_types:
Unit->mBaseTypes = add_comp_unit((ContextAddress)dio_gFormData);
break;
+ case AT_producer:
+ dio_ChkString(Form);
+ Unit->mProducer = (char *)dio_gFormDataAddr;
+ break;
case AT_language:
dio_ChkData(Form);
Unit->mLanguage = (U2_T)dio_gFormData;
@@ -1070,6 +1074,14 @@ static void add_object_addr_ranges(ObjectInfo * info) {
}
}
+static int is_debug_aranges_aligned(void) {
+ /* The DWARF standard does not require address range descriptors of .debug_aranges to be aligned,
+ * but some compilers (e.g. GCC) insert padding bytes to align descriptors at <address-size>*2 */
+ if (sCompUnit->mProducer == NULL) return 1;
+ if (strncmp(sCompUnit->mProducer, "IAR ", 4) == 0) return 0;
+ return 1;
+}
+
static void load_addr_ranges(ELF_Section * debug_info) {
Trap trap;
unsigned idx;
@@ -1093,6 +1105,10 @@ static void load_addr_ranges(ELF_Section * debug_info) {
size = dio_ReadU8();
}
next = dio_GetPos() + size;
+ if (next > sec->size) {
+ trace(LOG_ELF, "Ignoring entry in .debug_aranges section: invalid entry size.");
+ break;
+ }
if (dio_ReadU2() == 2) {
ELF_Section * unit_sec = NULL;
U8_T unit_addr = dio_ReadAddressX(&unit_sec, dwarf64 ? 8 : 4);
@@ -1103,7 +1119,9 @@ static void load_addr_ranges(ELF_Section * debug_info) {
sCompUnit = find_comp_unit(unit_sec, (ContextAddress)unit_addr);
if (sCompUnit == NULL) str_exception(ERR_INV_DWARF, "invalid .debug_aranges section");
sCompUnit->mObject->mFlags |= DOIF_aranges;
- while (dio_GetPos() % (addr_size * 2) != 0) dio_Skip(1);
+ if (is_debug_aranges_aligned()) {
+ while (dio_GetPos() % (addr_size * 2) != 0) dio_Skip(1);
+ }
for (;;) {
ELF_Section * addr_sec = NULL;
ELF_Section * size_sec = NULL;
@@ -1114,6 +1132,9 @@ static void load_addr_ranges(ELF_Section * debug_info) {
if (size != 0) add_addr_range(addr_sec, sCompUnit, addr, size);
}
}
+ else {
+ trace(LOG_ELF, "Ignoring entry in .debug_aranges section: unsupported version.");
+ }
dio_SetPos(next);
}
clear_trap(&trap);
diff --git a/agent/tcf/services/dwarfcache.h b/agent/tcf/services/dwarfcache.h
index ec5665dd..41d7c6c1 100644
--- a/agent/tcf/services/dwarfcache.h
+++ b/agent/tcf/services/dwarfcache.h
@@ -196,6 +196,8 @@ struct CompUnit {
ELF_File * mFile;
ELF_Section * mTextSection;
+ const char * mProducer;
+
U2_T mLanguage;
DIO_UnitDescriptor mDesc;

Back to the top