rpm/debugedit-comp-dir.diff

52 lines
1.3 KiB
Diff

Include compilation directory in source file list if used.
--- ./tools/debugedit.c.orig 2017-03-01 12:51:20.851951816 +0000
+++ ./tools/debugedit.c 2017-03-01 12:54:14.020391379 +0000
@@ -512,6 +512,7 @@ edit_dwarf2_line (DSO *dso, uint32_t off
uint32_t value, dirt_cnt;
size_t comp_dir_len = !comp_dir ? 0 : strlen (comp_dir);
size_t abs_file_cnt = 0, abs_dir_cnt = 0;
+ int comp_dir_used = 0;
if (phase != 0)
return 0;
@@ -620,6 +621,7 @@ edit_dwarf2_line (DSO *dso, uint32_t off
memcpy (s, comp_dir, comp_dir_len);
s[comp_dir_len] = '/';
p += comp_dir_len + 1;
+ comp_dir_used = 1;
}
memcpy (p, dirt[value], dir_len);
p[dir_len] = '/';
@@ -657,6 +659,30 @@ edit_dwarf2_line (DSO *dso, uint32_t off
}
++ptr;
+ if (comp_dir_used && list_file_fd != -1
+ && (base_dir == NULL || has_prefix (comp_dir, base_dir)))
+ {
+ char *p;
+ size_t size;
+ ssize_t ret;
+
+ size = comp_dir_len + 1;
+ p = comp_dir;
+ if (base_dir)
+ {
+ p += strlen (base_dir);
+ size -= strlen (base_dir);
+ }
+ while (size > 0)
+ {
+ ret = write (list_file_fd, p, size);
+ if (ret == -1)
+ break;
+ size -= ret;
+ p += ret;
+ }
+ }
+
if (dest_dir)
{
unsigned char *srcptr, *buf = NULL;