Contents of /trunk/elfutils/patches/elfutils-0.137-fixes.patch
Parent Directory | Revision Log
Revision 737 -
(show annotations)
(download)
Fri Dec 26 11:32:39 2008 UTC (15 years, 9 months ago) by niro
File size: 5536 byte(s)
Fri Dec 26 11:32:39 2008 UTC (15 years, 9 months ago) by niro
File size: 5536 byte(s)
patches for elfutils-0.137
1 | --- elfutils-0.137/libdwfl/ChangeLog |
2 | +++ elfutils-0.137/libdwfl/ChangeLog |
3 | @@ -1,3 +1,17 @@ |
4 | +2008-09-29 Roland McGrath <roland@redhat.com> |
5 | + |
6 | + * segment.c (insert): Must realloc DWFL->lookup_module here too. |
7 | + (dwfl_report_segment): Clear DWFL->lookup_module before insert calls. |
8 | + |
9 | +2008-08-28 Roland McGrath <roland@redhat.com> |
10 | + |
11 | + * segment.c (reify_segments): Fix last change. |
12 | + |
13 | +2008-08-27 Roland McGrath <roland@redhat.com> |
14 | + |
15 | + * linux-proc-maps.c (read_proc_memory): Return 0 for EINVAL or EPERM |
16 | + failure from pread64. |
17 | + |
18 | 2008-08-26 Roland McGrath <roland@redhat.com> |
19 | |
20 | * segment.c (reify_segments): Insert a trailing segment for a module |
21 | --- elfutils-0.137/libdwfl/linux-proc-maps.c |
22 | +++ elfutils-0.137/libdwfl/linux-proc-maps.c |
23 | @@ -267,6 +267,9 @@ read_proc_memory (void *arg, void *data, |
24 | { |
25 | const int fd = *(const int *) arg; |
26 | ssize_t nread = pread64 (fd, data, maxread, (off64_t) address); |
27 | + /* Some kernels don't actually let us do this read, ignore those errors. */ |
28 | + if (nread < 0 && (errno == EINVAL || errno == EPERM)) |
29 | + return 0; |
30 | if (nread > 0 && (size_t) nread < minread) |
31 | nread = 0; |
32 | return nread; |
33 | --- elfutils-0.137/libdwfl/segment.c |
34 | +++ elfutils-0.137/libdwfl/segment.c |
35 | @@ -83,12 +83,26 @@ insert (Dwfl *dwfl, size_t i, GElf_Addr |
36 | int *nsegndx = realloc (dwfl->lookup_segndx, sizeof nsegndx[0] * n); |
37 | if (unlikely (nsegndx == NULL)) |
38 | { |
39 | - free (naddr); |
40 | + if (naddr != dwfl->lookup_addr) |
41 | + free (naddr); |
42 | return true; |
43 | } |
44 | dwfl->lookup_alloc = n; |
45 | dwfl->lookup_addr = naddr; |
46 | dwfl->lookup_segndx = nsegndx; |
47 | + |
48 | + if (dwfl->lookup_module != NULL) |
49 | + { |
50 | + /* Make sure this array is big enough too. */ |
51 | + Dwfl_Module **old = dwfl->lookup_module; |
52 | + dwfl->lookup_module = realloc (dwfl->lookup_module, |
53 | + sizeof dwfl->lookup_module[0] * n); |
54 | + if (unlikely (dwfl->lookup_module == NULL)) |
55 | + { |
56 | + free (old); |
57 | + return true; |
58 | + } |
59 | + } |
60 | } |
61 | |
62 | if (unlikely (i < dwfl->lookup_elts)) |
63 | @@ -175,9 +189,17 @@ reify_segments (Dwfl *dwfl) |
64 | return true; |
65 | ++idx; |
66 | } |
67 | + else if (dwfl->lookup_addr[idx] < start) |
68 | + { |
69 | + /* The module starts past the end of this segment. |
70 | + Add a new one. */ |
71 | + if (unlikely (insert (dwfl, idx + 1, start, end, -1))) |
72 | + return true; |
73 | + ++idx; |
74 | + } |
75 | |
76 | - if (((size_t) idx + 1 == dwfl->lookup_elts |
77 | - || end < dwfl->lookup_addr[idx + 1]) |
78 | + if ((size_t) idx + 1 < dwfl->lookup_elts |
79 | + && end < dwfl->lookup_addr[idx + 1] |
80 | /* The module ends in the middle of this segment. Split it. */ |
81 | && unlikely (insert (dwfl, idx + 1, |
82 | end, dwfl->lookup_addr[idx + 1], -1))) |
83 | @@ -261,6 +283,12 @@ dwfl_report_segment (Dwfl *dwfl, int ndx |
84 | phdr->p_align < dwfl->segment_align)) |
85 | dwfl->segment_align = phdr->p_align; |
86 | |
87 | + if (unlikely (dwfl->lookup_module != NULL)) |
88 | + { |
89 | + free (dwfl->lookup_module); |
90 | + dwfl->lookup_module = NULL; |
91 | + } |
92 | + |
93 | GElf_Addr start = segment_start (dwfl, bias + phdr->p_vaddr); |
94 | GElf_Addr end = segment_end (dwfl, bias + phdr->p_vaddr + phdr->p_memsz); |
95 | |
96 | @@ -289,12 +317,6 @@ dwfl_report_segment (Dwfl *dwfl, int ndx |
97 | dwfl->lookup_tail_offset = end - bias - phdr->p_vaddr + phdr->p_offset; |
98 | dwfl->lookup_tail_ndx = ndx + 1; |
99 | |
100 | - if (unlikely (dwfl->lookup_module != NULL)) |
101 | - { |
102 | - free (dwfl->lookup_module); |
103 | - dwfl->lookup_module = NULL; |
104 | - } |
105 | - |
106 | return ndx; |
107 | } |
108 | INTDEF (dwfl_report_segment) |
109 | --- elfutils-0.137/libelf/ChangeLog |
110 | +++ elfutils-0.137/libelf/ChangeLog |
111 | @@ -1,3 +1,9 @@ |
112 | +2008-08-27 Roland McGrath <roland@redhat.com> |
113 | + |
114 | + * elf_begin.c (get_shnum): Avoid misaligned reads for matching endian. |
115 | + |
116 | + * libelfP.h [!ALLOW_UNALIGNED] (__libelf_type_align): Fix CLASS index. |
117 | + |
118 | 2008-08-25 Roland McGrath <roland@redhat.com> |
119 | |
120 | * Makefile.am (libelf_so_LDLIBS): New variable. |
121 | --- elfutils-0.137/libelf/elf_begin.c |
122 | +++ elfutils-0.137/libelf/elf_begin.c |
123 | @@ -111,7 +111,11 @@ get_shnum (void *map_address, unsigned c |
124 | bool is32 = e_ident[EI_CLASS] == ELFCLASS32; |
125 | |
126 | /* Make the ELF header available. */ |
127 | - if (e_ident[EI_DATA] == MY_ELFDATA) |
128 | + if (e_ident[EI_DATA] == MY_ELFDATA |
129 | + && (ALLOW_UNALIGNED |
130 | + || (((size_t) e_ident |
131 | + & ((is32 ? __alignof__ (Elf32_Ehdr) : __alignof__ (Elf64_Ehdr)) |
132 | + - 1)) == 0))) |
133 | ehdr.p = e_ident; |
134 | else |
135 | { |
136 | @@ -130,8 +134,11 @@ get_shnum (void *map_address, unsigned c |
137 | else |
138 | memcpy (&ehdr_mem, e_ident, sizeof (Elf32_Ehdr)); |
139 | |
140 | - CONVERT (ehdr_mem.e32.e_shnum); |
141 | - CONVERT (ehdr_mem.e32.e_shoff); |
142 | + if (e_ident[EI_DATA] != MY_ELFDATA) |
143 | + { |
144 | + CONVERT (ehdr_mem.e32.e_shnum); |
145 | + CONVERT (ehdr_mem.e32.e_shoff); |
146 | + } |
147 | } |
148 | else |
149 | { |
150 | @@ -143,8 +150,11 @@ get_shnum (void *map_address, unsigned c |
151 | else |
152 | memcpy (&ehdr_mem, e_ident, sizeof (Elf64_Ehdr)); |
153 | |
154 | - CONVERT (ehdr_mem.e64.e_shnum); |
155 | - CONVERT (ehdr_mem.e64.e_shoff); |
156 | + if (e_ident[EI_DATA] != MY_ELFDATA) |
157 | + { |
158 | + CONVERT (ehdr_mem.e64.e_shnum); |
159 | + CONVERT (ehdr_mem.e64.e_shoff); |
160 | + } |
161 | } |
162 | } |
163 | |
164 | --- elfutils-0.137/libelf/libelfP.h |
165 | +++ elfutils-0.137/libelf/libelfP.h |
166 | @@ -460,7 +460,7 @@ extern const uint_fast8_t __libelf_type_ |
167 | version, binary class, and type. */ |
168 | extern const uint_fast8_t __libelf_type_aligns[EV_NUM - 1][ELFCLASSNUM - 1][ELF_T_NUM] attribute_hidden; |
169 | # define __libelf_type_align(class, type) \ |
170 | - (__libelf_type_aligns[LIBELF_EV_IDX][class][type] ?: 1) |
171 | + (__libelf_type_aligns[LIBELF_EV_IDX][class - 1][type] ?: 1) |
172 | #else |
173 | # define __libelf_type_align(class, type) 1 |
174 | #endif |