1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
| diff --git a/tools/debugedit.c b/tools/debugedit.c
index 0f85885..257f5f8 100644
--- a/tools/debugedit.c
+++ b/tools/debugedit.c
@@ -602,13 +602,14 @@ edit_dwarf2_line (DSO *dso, uint32_t off, char *comp_dir, int phase)
if (base_dir == NULL)
p = s;
else if (has_prefix (s, base_dir))
- p = s + strlen (base_dir);
+ { p = s + strlen (base_dir); while (*p == '/') p++; }
else if (has_prefix (s, dest_dir))
- p = s + strlen (dest_dir);
+ { p = s + strlen (dest_dir); while (*p == '/') p++; }
- if (p)
+ if (p && strlen (p) > 2 && flock(list_file_fd, LOCK_EX) == 0)
{
size_t size = strlen (p) + 1;
+
while (size > 0)
{
ssize_t ret = write (list_file_fd, p, size);
@@ -617,6 +618,7 @@ edit_dwarf2_line (DSO *dso, uint32_t off, char *comp_dir, int phase)
size -= ret;
p += ret;
}
+ flock(list_file_fd, LOCK_UN);
}
}
@@ -928,17 +930,18 @@ edit_attributes (DSO *dso, unsigned char *ptr, struct abbrev_tag *t, int phase)
it and the debugger (GDB) cannot safely optimize out the missing
CU current dir subdirectories. */
if (comp_dir && list_file_fd != -1)
- {
+ {
char *p;
size_t size;
if (base_dir && has_prefix (comp_dir, base_dir))
- p = comp_dir + strlen (base_dir);
+ { p = comp_dir + strlen (base_dir); while (*p == '/') p++; }
else if (dest_dir && has_prefix (comp_dir, dest_dir))
- p = comp_dir + strlen (dest_dir);
+ { p = comp_dir + strlen (dest_dir); while (*p == '/') p++; }
else
p = comp_dir;
+ if (p && strlen (p) > 2 && flock(list_file_fd, LOCK_EX) == 0) {
size = strlen (p) + 1;
while (size > 0)
{
@@ -949,6 +952,8 @@ edit_attributes (DSO *dso, unsigned char *ptr, struct abbrev_tag *t, int phase)
p += ret;
}
}
+ flock(list_file_fd, LOCK_UN);
+ }
if (found_list_offs && comp_dir)
edit_dwarf2_line (dso, list_offs, comp_dir, phase);
@@ -1548,7 +1553,7 @@ main (int argc, char *argv[])
canonicalize_path(dest_dir, dest_dir);
/* Make sure there are trailing slashes in dirs */
- if (base_dir != NULL && base_dir[strlen (base_dir)-1] != '/')
+ /*if (base_dir != NULL && base_dir[strlen (base_dir)-1] != '/')
{
p = malloc (strlen (base_dir) + 2);
strcpy (p, base_dir);
@@ -1563,7 +1568,7 @@ main (int argc, char *argv[])
strcat (p, "/");
free (dest_dir);
dest_dir = p;
- }
+ }*/
if (list_file != NULL)
{
|