diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/format/dwarf/abbrev.c | 28 | ||||
-rw-r--r-- | src/format/dwarf/info.c | 57 |
2 files changed, 61 insertions, 24 deletions
diff --git a/src/format/dwarf/abbrev.c b/src/format/dwarf/abbrev.c index a9fee2c..ba6cfb0 100644 --- a/src/format/dwarf/abbrev.c +++ b/src/format/dwarf/abbrev.c @@ -397,11 +397,13 @@ bool _read_dwarf_abbrev_attribute(dwarf_format *format, off_t *pos, DwarfForm fo uint16_t *val16; /* Données sur 16 bits */ uint32_t *val32; /* Données sur 32 bits */ uint64_t *val64; /* Données sur 64 bits */ + uint64_t *sval64; /* Données sur 64 bits (signée)*/ bool *boolval; /* Valeur booléenne */ uint8_t tmp8; /* Données sur 8 bits */ uint16_t tmp16; /* Données sur 16 bits */ uint32_t tmp32; /* Données sur 32 bits */ uint64_t tmp64; /* Données sur 64 bits */ + uint64_t stmp64; /* Données sur 64 bits (signée)*/ uint64_t size_to_read; /* Nombre d'octets à lire */ off_t offset; /* Décallage dans une zone */ char **strval; /* Chaîne de caractères */ @@ -420,8 +422,7 @@ bool _read_dwarf_abbrev_attribute(dwarf_format *format, off_t *pos, DwarfForm fo { if (format->format == DWF_32_BITS) { - tmp32 = *((uint32_t *)&DBG_FORMAT(format)->content[*pos]); - //memcpy(&tmp32, &DBG_FORMAT(format)->content[*pos], 4); + memcpy(&tmp32, &DBG_FORMAT(format)->content[*pos], 4); *val64 = tmp32; } else memcpy(val64, &DBG_FORMAT(format)->content[*pos], 8); @@ -571,13 +572,11 @@ bool _read_dwarf_abbrev_attribute(dwarf_format *format, off_t *pos, DwarfForm fo break; case DWF_SDATA: - result = ((*pos + 4) <= DBG_FORMAT(format)->length); - - printf("bad\n"); exit(0); - + sval64 = va_arg(ap, int64_t *); + if (sval64 == NULL) sval64 = &stmp64; + result = read_uleb128(format, pos, sval64, true); break; - case DWF_STRP: result = read_abbrev_offset(format, pos, &offset); if (result) @@ -594,19 +593,16 @@ bool _read_dwarf_abbrev_attribute(dwarf_format *format, off_t *pos, DwarfForm fo } break; - case DWF_UDATA: - result = ((*pos + 4) <= DBG_FORMAT(format)->length); - - printf("bad\n"); exit(0); - + val64 = va_arg(ap, uint64_t *); + if (val64 == NULL) val64 = &tmp64; + result = read_uleb128(format, pos, val64, true); break; - case DWF_REF_ADDR: result = ((*pos + 4) <= DBG_FORMAT(format)->length); - printf("bad\n"); exit(0); + printf("bad at %d\n", __LINE__); exit(0); break; @@ -654,7 +650,7 @@ bool _read_dwarf_abbrev_attribute(dwarf_format *format, off_t *pos, DwarfForm fo case DWF_REF_UDATA: result = ((*pos + 4) <= DBG_FORMAT(format)->length); - printf("bad\n"); exit(0); + printf("bad at %d\n", __LINE__); exit(0); break; @@ -662,7 +658,7 @@ bool _read_dwarf_abbrev_attribute(dwarf_format *format, off_t *pos, DwarfForm fo case DWF_INDIRECT: result = ((*pos + 4) <= DBG_FORMAT(format)->length); - printf("bad\n"); exit(0); + printf("bad at %d\n", __LINE__); exit(0); break; diff --git a/src/format/dwarf/info.c b/src/format/dwarf/info.c index 30d2391..a45b556 100644 --- a/src/format/dwarf/info.c +++ b/src/format/dwarf/info.c @@ -558,7 +558,7 @@ bool look_for_dwarf_subprograms(dwarf_format *format, off_t *pos, const compil_u } - exit_loop: + exit_loop: proto_len += 1; prototype = (char *)realloc(prototype, (proto_len + 1) * sizeof(char)); @@ -584,10 +584,6 @@ bool look_for_dwarf_subprograms(dwarf_format *format, off_t *pos, const compil_u printf("error skipping :(\n"); - printf(" == progress %d\n", *pos - oldpos); - printf(" == %d < %d\n", *pos, cu->endpos); - - } @@ -634,11 +630,25 @@ char *resolve_dwarf_function_type(dwarf_format *format, const dw_abbrev *abbrev, switch (abbrev->tag) { - case DWT_BASE_TYPE: + /* 0x04 */ + case DWT_ENUMERATION_TYPE: + oldpos = *pos; - read_dwarf_abbrev_attribute(format, &oldpos, true, abbrev, DWA_NAME, &result); + read_dwarf_abbrev_attribute(format, &oldpos, true /* ??? */, abbrev, DWA_NAME, &result); + + if (result != NULL) + { + len = strlen(result); + + result = (char *)realloc(result, (strlen("enum ") + len + 1) * sizeof(char)); + memmove(&result[strlen("enum ")], result, len); + memcpy(result, "enum ", strlen("enum ")); + + } + break; + /* 0x0f */ case DWT_POINTER_TYPE: if (read_dwarf_abbrev_attribute(format, &oldpos, true, abbrev, DWA_TYPE, &type_pos)) @@ -675,6 +685,37 @@ char *resolve_dwarf_function_type(dwarf_format *format, const dw_abbrev *abbrev, break; + /* 0x13 */ + case DWT_STRUCTURE_TYPE: + + oldpos = *pos; + read_dwarf_abbrev_attribute(format, &oldpos, true /* ??? */, abbrev, DWA_NAME, &result); + + if (result != NULL) + { + len = strlen(result); + + result = (char *)realloc(result, (strlen("struct ") + len + 1) * sizeof(char)); + memmove(&result[strlen("struct ")], result, len); + memcpy(result, "struct ", strlen("struct ")); + + } + + break; + + /* 0x16 */ + case DWT_TYPEDEF: + oldpos = *pos; + read_dwarf_abbrev_attribute(format, &oldpos, true /* ??? */, abbrev, DWA_NAME, &result); + break; + + /* 0x24 */ + case DWT_BASE_TYPE: + oldpos = *pos; + read_dwarf_abbrev_attribute(format, &oldpos, true /* ??? */, abbrev, DWA_NAME, &result); + break; + + /* 0x26 */ case DWT_CONST_TYPE: @@ -702,7 +743,7 @@ char *resolve_dwarf_function_type(dwarf_format *format, const dw_abbrev *abbrev, { len = strlen(result); - result = (char *)realloc(result, (len + strlen("const ") + 1) * sizeof(char)); + result = (char *)realloc(result, (strlen("const ") + len + 1) * sizeof(char)); memmove(&result[strlen("const ")], result, len); memcpy(result, "const ", strlen("const ")); |