diff options
author | Roland McGrath <roland@redhat.com> | 2010-05-10 20:05:48 -0700 |
---|---|---|
committer | Panu Matilainen <pmatilai@redhat.com> | 2010-05-11 15:09:53 +0300 |
commit | e6a0b0e5661f15fbb39f45f937aef4b0464be39c (patch) | |
tree | d8009757521b4082ad13132598a922da9481b18a /tools | |
parent | c4b63623533d8b7fa7b89ea5fe33dd02663c99c5 (diff) | |
download | rpm-e6a0b0e5661f15fbb39f45f937aef4b0464be39c.tar.gz rpm-e6a0b0e5661f15fbb39f45f937aef4b0464be39c.tar.bz2 rpm-e6a0b0e5661f15fbb39f45f937aef4b0464be39c.zip |
Make debugedit -i recompute build ID only when any DWARF was actually changed.
Diffstat (limited to 'tools')
-rw-r--r-- | tools/debugedit.c | 32 |
1 files changed, 21 insertions, 11 deletions
diff --git a/tools/debugedit.c b/tools/debugedit.c index 23a21a534..820e5aa29 100644 --- a/tools/debugedit.c +++ b/tools/debugedit.c @@ -454,6 +454,14 @@ has_prefix (const char *str, return strncmp (str, prefix, prefix_len) == 0; } +static int dirty_elf; +static void +dirty_section (unsigned int sec) +{ + elf_flagdata (debug_sections[sec].elf_data, ELF_C_SET, ELF_F_DIRTY); + dirty_elf = 1; +} + static int edit_dwarf2_line (DSO *dso, uint32_t off, char *comp_dir, int phase) { @@ -628,6 +636,8 @@ edit_dwarf2_line (DSO *dso, uint32_t off, char *comp_dir, int phase) size_t len = strlen ((char *)srcptr) + 1; const unsigned char *readptr = srcptr; + char *orig = strdup ((const char *) srcptr); + if (*srcptr == '/' && has_prefix ((char *)srcptr, base_dir)) { if (dest_len < base_len) @@ -644,8 +654,9 @@ edit_dwarf2_line (DSO *dso, uint32_t off, char *comp_dir, int phase) shrank -= len; ptr += len; - elf_flagdata (debug_sections[DEBUG_STR].elf_data, - ELF_C_SET, ELF_F_DIRTY); + if (memcmp (orig, ptr - len, len)) + dirty_section (DEBUG_STR); + free (orig); } if (shrank > 0) @@ -687,8 +698,7 @@ edit_dwarf2_line (DSO *dso, uint32_t off, char *comp_dir, int phase) len - base_len); ptr += dest_len - base_len; } - elf_flagdata (debug_sections[DEBUG_STR].elf_data, - ELF_C_SET, ELF_F_DIRTY); + dirty_section (DEBUG_STR); } else if (ptr != srcptr) memmove (ptr, srcptr, len); @@ -755,11 +765,9 @@ edit_attributes (DSO *dso, unsigned char *ptr, struct abbrev_tag *t, int phase) base_len - dest_len); } - elf_flagdata (debug_sections[DEBUG_INFO].elf_data, - ELF_C_SET, ELF_F_DIRTY); + dirty_section (DEBUG_INFO); } } - else if (form == DW_FORM_strp && debug_sections[DEBUG_STR].data) { @@ -782,8 +790,7 @@ edit_attributes (DSO *dso, unsigned char *ptr, struct abbrev_tag *t, int phase) memmove (dir + dest_len, dir + base_len, strlen (dir + base_len) + 1); } - elf_flagdata (debug_sections[DEBUG_STR].elf_data, - ELF_C_SET, ELF_F_DIRTY); + dirty_section (DEBUG_STR); } } } @@ -822,8 +829,7 @@ edit_attributes (DSO *dso, unsigned char *ptr, struct abbrev_tag *t, int phase) memmove (name + dest_len, name + base_len, strlen (name + base_len) + 1); } - elf_flagdata (debug_sections[DEBUG_STR].elf_data, - ELF_C_SET, ELF_F_DIRTY); + dirty_section (DEBUG_STR); } } @@ -1365,6 +1371,9 @@ handle_build_id (DSO *dso, Elf_Data *build_id, exit (1); } + if (!dirty_elf) + goto print; + if (elf_update (dso->elf, ELF_C_NULL) < 0) { fprintf (stderr, "Failed to update file: %s\n", @@ -1444,6 +1453,7 @@ handle_build_id (DSO *dso, Elf_Data *build_id, elf_flagdata (build_id, ELF_C_SET, ELF_F_DIRTY); + print: /* Now format the build ID bits in hex to print out. */ { const uint8_t * id = (uint8_t *)build_id->d_buf + build_id_offset; |