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)
{
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)
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)
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);
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)
{
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);
}
}
}
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);
}
}
exit (1);
}
+ if (!dirty_elf)
+ goto print;
+
if (elf_update (dso->elf, ELF_C_NULL) < 0)
{
fprintf (stderr, "Failed to update file: %s\n",
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;