From: Michael Tremer Date: Fri, 16 Dec 2011 14:33:33 +0000 (+0100) Subject: debuginfo: Add support for dwarf 4. X-Git-Tag: 0.9.19~2^2~1 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=c9ede3cbe2b953926f979c0e89f4c403656b98f5;p=pakfire.git debuginfo: Add support for dwarf 4. --- diff --git a/tools/Makefile b/tools/Makefile index db5c5f32..969254b6 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -36,7 +36,7 @@ all: $(SCRIPTS) $(CC) $(CFLAGS) -I. -o $@ -c $< debugedit: debugedit.o hashtab.o - $(CC) $(CFLAGS) -o $@ $? $(LIBS_BEECRYPT) $(LIBS_ELF) $(LIBS_POPT) + $(CC) $(CFLAGS) -o $@ $^ $(LIBS_BEECRYPT) $(LIBS_ELF) $(LIBS_POPT) .PHONY: install install: $(SCRIPTS) diff --git a/tools/debugedit.c b/tools/debugedit.c index bc6bf70c..320d8e17 100644 --- a/tools/debugedit.c +++ b/tools/debugedit.c @@ -70,6 +70,10 @@ #include #define DW_TAG_partial_unit 0x3c +#define DW_FORM_sec_offset 0x17 +#define DW_FORM_exprloc 0x18 +#define DW_FORM_flag_present 0x19 +#define DW_FORM_ref_sig8 0x20 char *base_dir = NULL; char *dest_dir = NULL; @@ -246,6 +250,7 @@ static struct #define DEBUG_STR 8 #define DEBUG_FRAME 9 #define DEBUG_RANGES 10 +#define DEBUG_TYPES 11 { ".debug_info", NULL, NULL, 0, 0, 0 }, { ".debug_abbrev", NULL, NULL, 0, 0, 0 }, { ".debug_line", NULL, NULL, 0, 0, 0 }, @@ -257,6 +262,7 @@ static struct { ".debug_str", NULL, NULL, 0, 0, 0 }, { ".debug_frame", NULL, NULL, 0, 0, 0 }, { ".debug_ranges", NULL, NULL, 0, 0, 0 }, + { ".debug_types", NULL, NULL, 0, 0, 0 }, { NULL, NULL, NULL, 0, 0, 0 } }; @@ -349,7 +355,8 @@ no_memory: goto no_memory; } form = read_uleb128 (ptr); - if (form == 2 || form > DW_FORM_indirect) + if (form == 2 + || (form > DW_FORM_flag_present && form != DW_FORM_ref_sig8)) { error (0, 0, "%s: Unknown DWARF DW_FORM_%d", dso->filename, form); htab_delete (h); @@ -513,7 +520,7 @@ edit_dwarf2_line (DSO *dso, rpmuint32_t off, char *comp_dir, int phase) } value = read_16 (ptr); - if (value != 2 && value != 3) + if (value != 2 && value != 3 && value != 4) { error (0, 0, "%s: DWARF version %d unhandled", dso->filename, value); @@ -529,8 +536,8 @@ edit_dwarf2_line (DSO *dso, rpmuint32_t off, char *comp_dir, int phase) return 1; } - opcode_base = ptr[4]; - ptr = dir = ptr + 4 + opcode_base; + opcode_base = ptr[4 + (value >= 4)]; + ptr = dir = ptr + 4 + (value >= 4) + opcode_base; /* dir table: */ value = 1; @@ -758,7 +765,8 @@ edit_attributes (DSO *dso, unsigned char *ptr, struct abbrev_tag *t, int phase) { if (t->attr[i].attr == DW_AT_stmt_list) { - if (form == DW_FORM_data4) + if (form == DW_FORM_data4 + || form == DW_FORM_sec_offset) { list_offs = do_read_32_relocated (ptr); found_list_offs = 1; @@ -864,6 +872,8 @@ edit_attributes (DSO *dso, unsigned char *ptr, struct abbrev_tag *t, int phase) else ptr += 4; break; + case DW_FORM_flag_present: + break; case DW_FORM_addr: ptr += ptr_size; break; @@ -878,10 +888,12 @@ edit_attributes (DSO *dso, unsigned char *ptr, struct abbrev_tag *t, int phase) break; case DW_FORM_ref4: case DW_FORM_data4: + case DW_FORM_sec_offset: ptr += 4; break; case DW_FORM_ref8: case DW_FORM_data8: + case DW_FORM_ref_sig8: ptr += 8; break; case DW_FORM_sdata: @@ -910,6 +922,7 @@ edit_attributes (DSO *dso, unsigned char *ptr, struct abbrev_tag *t, int phase) form = DW_FORM_block1; break; case DW_FORM_block: + case DW_FORM_exprloc: len = read_uleb128 (ptr); form = DW_FORM_block1; assert (len < UINT_MAX); @@ -1213,7 +1226,7 @@ edit_dwarf2 (DSO *dso) } cu_version = read_16 (ptr); - if (cu_version != 2 && cu_version != 3) + if (cu_version != 2 && cu_version != 3 && cu_version != 4) { error (0, 0, "%s: DWARF version %d unhandled", dso->filename, cu_version);