]> git.pld-linux.org Git - packages/rpm.git/blame - rpm-rpm5-debugedit.patch
This commit was manufactured by cvs2git to create branch 'rpm-4_5'.
[packages/rpm.git] / rpm-rpm5-debugedit.patch
CommitLineData
62238cf9 1--- trunk/tools/debugedit.c 2010-01-27 18:57:49.758813670 +0200
2+++ rpm-4.5/tools/debugedit.c 2008-04-06 23:32:15.000000000 +0300
3@@ -1,4 +1,4 @@
4-/* Copyright (C) 2001, 2002, 2003, 2005, 2007, 2009 Red Hat, Inc.
5+/* Copyright (C) 2001, 2002, 2003, 2005, 2007 Red Hat, Inc.
6 Written by Alexander Larsson <alexl@redhat.com>, 2002
7 Based on code by Jakub Jelinek <jakub@redhat.com>, 2001.
8
9@@ -66,8 +66,8 @@
10 #define DW_FORM_indirect 0x16
11
12 #include <beecrypt/beecrypt.h>
13+
14 #include "hashtab.h"
15-#include <rpmtag.h>
16
17 #define DW_TAG_partial_unit 0x3c
18
19@@ -77,6 +77,9 @@
20 int list_file_fd = -1;
21 int do_build_id = 0;
22
23+typedef unsigned int uint_32;
24+typedef unsigned short uint_16;
25+
26 typedef struct
27 {
28 Elf *elf;
29@@ -90,7 +93,7 @@
30 typedef struct
31 {
32 unsigned char *ptr;
33- rpmuint32_t addend;
34+ uint_32 addend;
35 } REL;
36
37 #define read_uleb128(ptr) ({ \
38@@ -109,32 +112,31 @@
39 ret; \
40 })
41
42-static rpmuint16_t (*do_read_16) (unsigned char *ptr);
43-static rpmuint32_t (*do_read_32) (unsigned char *ptr);
44+static uint_16 (*do_read_16) (unsigned char *ptr);
45+static uint_32 (*do_read_32) (unsigned char *ptr);
46 static void (*write_32) (unsigned char *ptr, GElf_Addr val);
47
48 static int ptr_size;
49-static int cu_version;
50
51-static inline rpmuint16_t
52+static inline uint_16
53 buf_read_ule16 (unsigned char *data)
54 {
55 return data[0] | (data[1] << 8);
56 }
57
58-static inline rpmuint16_t
59+static inline uint_16
60 buf_read_ube16 (unsigned char *data)
61 {
62 return data[1] | (data[0] << 8);
63 }
64
65-static inline rpmuint32_t
66+static inline uint_32
67 buf_read_ule32 (unsigned char *data)
68 {
69 return data[0] | (data[1] << 8) | (data[2] << 16) | (data[3] << 24);
70 }
71
72-static inline rpmuint32_t
73+static inline uint_32
74 buf_read_ube32 (unsigned char *data)
75 {
76 return data[3] | (data[2] << 8) | (data[1] << 16) | (data[0] << 24);
77@@ -154,7 +156,7 @@
78 {
79 if (data->d_buf
80 && offset >= data->d_off
81- && offset < data->d_off + (off_t)data->d_size)
82+ && offset < data->d_off + data->d_size)
83 return (const char *) data->d_buf + (offset - data->d_off);
84 }
85 }
86@@ -166,13 +168,13 @@
87 #define read_1(ptr) *ptr++
88
89 #define read_16(ptr) ({ \
90- rpmuint16_t ret = do_read_16 (ptr); \
91+ uint_16 ret = do_read_16 (ptr); \
92 ptr += 2; \
93 ret; \
94 })
95
96 #define read_32(ptr) ({ \
97- rpmuint32_t ret = do_read_32 (ptr); \
98+ uint_32 ret = do_read_32 (ptr); \
99 ptr += 4; \
100 ret; \
101 })
102@@ -181,7 +183,7 @@
103 int reltype;
104
105 #define do_read_32_relocated(ptr) ({ \
106- rpmuint32_t dret = do_read_32 (ptr); \
107+ uint_32 dret = do_read_32 (ptr); \
108 if (relptr) \
109 { \
110 while (relptr < relend && relptr->ptr < ptr) \
111@@ -198,7 +200,7 @@
112 })
113
114 #define read_32_relocated(ptr) ({ \
115- rpmuint32_t ret = do_read_32_relocated (ptr); \
116+ uint_32 ret = do_read_32_relocated (ptr); \
117 ptr += 4; \
118 ret; \
119 })
120@@ -206,7 +208,7 @@
121 static void
122 dwarf2_write_le32 (unsigned char *p, GElf_Addr val)
123 {
124- rpmuint32_t v = (rpmuint32_t) val;
125+ uint_32 v = (uint_32) val;
126
127 p[0] = v;
128 p[1] = v >> 8;
129@@ -218,7 +220,7 @@
130 static void
131 dwarf2_write_be32 (unsigned char *p, GElf_Addr val)
132 {
133- rpmuint32_t v = (rpmuint32_t) val;
134+ uint_32 v = (uint_32) val;
135
136 p[3] = v;
137 p[2] = v >> 8;
138@@ -240,18 +242,16 @@
139 #define DEBUG_LINE 2
140 #define DEBUG_ARANGES 3
141 #define DEBUG_PUBNAMES 4
142-#define DEBUG_PUBTYPES 5
143-#define DEBUG_MACINFO 6
144-#define DEBUG_LOC 7
145-#define DEBUG_STR 8
146-#define DEBUG_FRAME 9
147-#define DEBUG_RANGES 10
148+#define DEBUG_MACINFO 5
149+#define DEBUG_LOC 6
150+#define DEBUG_STR 7
151+#define DEBUG_FRAME 8
152+#define DEBUG_RANGES 9
153 { ".debug_info", NULL, NULL, 0, 0, 0 },
154 { ".debug_abbrev", NULL, NULL, 0, 0, 0 },
155 { ".debug_line", NULL, NULL, 0, 0, 0 },
156 { ".debug_aranges", NULL, NULL, 0, 0, 0 },
157 { ".debug_pubnames", NULL, NULL, 0, 0, 0 },
158- { ".debug_pubtypes", NULL, NULL, 0, 0, 0 },
159 { ".debug_macinfo", NULL, NULL, 0, 0, 0 },
160 { ".debug_loc", NULL, NULL, 0, 0, 0 },
161 { ".debug_str", NULL, NULL, 0, 0, 0 },
162@@ -331,7 +331,7 @@
163 }
164 if (*slot != NULL)
165 {
166- error (0, 0, "%s: Duplicate DWARF abbreviation %d", dso->filename,
167+ error (0, 0, "%s: Duplicate DWARF-2 abbreviation %d", dso->filename,
168 t->entry);
169 free (t);
170 htab_delete (h);
171@@ -351,7 +351,7 @@
172 form = read_uleb128 (ptr);
173 if (form == 2 || form > DW_FORM_indirect)
174 {
175- error (0, 0, "%s: Unknown DWARF DW_FORM_%d", dso->filename, form);
176+ error (0, 0, "%s: Unknown DWARF-2 DW_FORM_%d", dso->filename, form);
177 htab_delete (h);
178 return NULL;
179 }
180@@ -361,7 +361,7 @@
181 }
182 if (read_uleb128 (ptr) != 0)
183 {
184- error (0, 0, "%s: DWARF abbreviation does not end with 2 zeros",
185+ error (0, 0, "%s: DWARF-2 abbreviation does not end with 2 zeros",
186 dso->filename);
187 htab_delete (h);
188 return NULL;
189@@ -468,8 +468,8 @@
190 has_prefix (const char *str,
191 const char *prefix)
192 {
193- size_t str_len;
194- size_t prefix_len;
195+ int str_len;
196+ int prefix_len;
197
198 str_len = strlen (str);
199 prefix_len = strlen (prefix);
200@@ -481,14 +481,14 @@
201 }
202
203 static int
204-edit_dwarf2_line (DSO *dso, rpmuint32_t off, char *comp_dir, int phase)
205+edit_dwarf2_line (DSO *dso, uint_32 off, char *comp_dir, int phase)
206 {
207 unsigned char *ptr = debug_sections[DEBUG_LINE].data, *dir;
208 unsigned char **dirt;
209 unsigned char *endsec = ptr + debug_sections[DEBUG_LINE].size;
210 unsigned char *endcu, *endprol;
211 unsigned char opcode_base;
212- rpmuint32_t value, dirt_cnt;
213+ uint_32 value, dirt_cnt;
214 size_t comp_dir_len = strlen (comp_dir);
215 size_t abs_file_cnt = 0, abs_dir_cnt = 0;
216
217@@ -513,7 +513,7 @@
218 }
219
220 value = read_16 (ptr);
221- if (value != 2 && value != 3)
222+ if (value != 2)
223 {
224 error (0, 0, "%s: DWARF version %d unhandled", dso->filename,
225 value);
226@@ -679,12 +679,9 @@
227 if (--shrank == 0)
228 error (EXIT_FAILURE, 0,
229 "canonicalization unexpectedly shrank by one character");
230- else
231- {
232- memset (ptr, 'X', shrank);
233- ptr += shrank;
234- *ptr++ = '\0';
235- }
236+ memset (ptr, 'X', shrank);
237+ ptr += shrank;
238+ *ptr++ = '\0';
239 }
240
241 if (abs_dir_cnt + abs_file_cnt != 0)
242@@ -740,7 +737,7 @@
243 edit_attributes (DSO *dso, unsigned char *ptr, struct abbrev_tag *t, int phase)
244 {
245 int i;
246- rpmuint32_t list_offs;
247+ uint_32 list_offs;
248 int found_list_offs;
249 char *comp_dir;
250
251@@ -749,9 +746,9 @@
252 found_list_offs = 0;
253 for (i = 0; i < t->nattr; ++i)
254 {
255- rpmuint32_t form = t->attr[i].form;
256- size_t len = 0;
257- size_t base_len, dest_len;
258+ uint_32 form = t->attr[i].form;
259+ uint_32 len = 0;
260+ int base_len, dest_len;
261
262
263 while (1)
264@@ -794,7 +791,7 @@
265 {
266 char *dir;
267
268- dir = (char *) debug_sections[DEBUG_STR].data
269+ dir = (char *)debug_sections[DEBUG_STR].data
270 + do_read_32_relocated (ptr);
271
272 free (comp_dir);
273@@ -824,7 +821,7 @@
274 {
275 char *name;
276
277- name = (char *) debug_sections[DEBUG_STR].data
278+ name = (char *)debug_sections[DEBUG_STR].data
279 + do_read_32_relocated (ptr);
280 if (*name == '/' && comp_dir == NULL)
281 {
282@@ -858,12 +855,7 @@
283
284 switch (form)
285 {
286- case DW_FORM_ref_addr:
287- if (cu_version == 2)
288- ptr += ptr_size;
289- else
290- ptr += 4;
291- break;
292+ case DW_FORM_ref_addr: /* ptr_size in DWARF 2, offset in DWARF 3 */
293 case DW_FORM_addr:
294 ptr += ptr_size;
295 break;
296@@ -915,7 +907,7 @@
297 assert (len < UINT_MAX);
298 break;
299 default:
300- error (0, 0, "%s: Unknown DWARF DW_FORM_%d", dso->filename,
301+ error (0, 0, "%s: Unknown DWARF-2 DW_FORM_%d", dso->filename,
302 form);
303 return NULL;
304 }
305@@ -926,34 +918,6 @@
306 break;
307 }
308 }
309-
310- /* Ensure the CU current directory will exist even if only empty. Source
311- filenames possibly located in its parent directories refer relatively to
312- it and the debugger (GDB) cannot safely optimize out the missing
313- CU current dir subdirectories. */
314- if (comp_dir && list_file_fd != -1)
315- {
316- char *p;
317- size_t size;
318-
319- if (base_dir && has_prefix (comp_dir, base_dir))
320- p = comp_dir + strlen (base_dir);
321- else if (dest_dir && has_prefix (comp_dir, dest_dir))
322- p = comp_dir + strlen (dest_dir);
323- else
324- p = comp_dir;
325-
326- size = strlen (p) + 1;
327- while (size > 0)
328- {
329- ssize_t ret = write (list_file_fd, p, size);
330- if (ret == -1)
331- break;
332- size -= ret;
333- p += ret;
334- }
335- }
336-
337 if (found_list_offs && comp_dir)
338 edit_dwarf2_line (dso, list_offs, comp_dir, phase);
339
340@@ -1070,7 +1034,7 @@
341 if (debug_sections[DEBUG_INFO].data != NULL)
342 {
343 unsigned char *ptr, *endcu, *endsec;
344- rpmuint32_t value;
345+ uint_32 value;
346 htab_t abbrev;
347 struct abbrev_tag tag, *t;
348 int phase;
349@@ -1212,11 +1176,11 @@
350 return 1;
351 }
352
353- cu_version = read_16 (ptr);
354- if (cu_version != 2 && cu_version != 3)
355+ value = read_16 (ptr);
356+ if (value != 2)
357 {
358 error (0, 0, "%s: DWARF version %d unhandled", dso->filename,
359- cu_version);
360+ value);
361 return 1;
362 }
363
364@@ -1226,7 +1190,7 @@
365 if (debug_sections[DEBUG_ABBREV].data == NULL)
366 error (0, 0, "%s: .debug_abbrev not present", dso->filename);
367 else
368- error (0, 0, "%s: DWARF CU abbrev offset too large",
369+ error (0, 0, "%s: DWARF-2 CU abbrev offset too large",
370 dso->filename);
371 return 1;
372 }
373@@ -1236,14 +1200,14 @@
374 ptr_size = read_1 (ptr);
375 if (ptr_size != 4 && ptr_size != 8)
376 {
377- error (0, 0, "%s: Invalid DWARF pointer size %d",
378+ error (0, 0, "%s: Invalid DWARF-2 pointer size %d",
379 dso->filename, ptr_size);
380 return 1;
381 }
382 }
383 else if (read_1 (ptr) != ptr_size)
384 {
385- error (0, 0, "%s: DWARF pointer size differs between CUs",
386+ error (0, 0, "%s: DWARF-2 pointer size differs between CUs",
387 dso->filename);
388 return 1;
389 }
390@@ -1261,7 +1225,7 @@
391 t = htab_find_with_hash (abbrev, &tag, tag.entry);
392 if (t == NULL)
393 {
394- error (0, 0, "%s: Could not find DWARF abbreviation %d",
395+ error (0, 0, "%s: Could not find DWARF-2 abbreviation %d",
396 dso->filename, tag.entry);
397 htab_delete (abbrev);
398 return 1;
399@@ -1410,12 +1374,12 @@
400 or Elf64 object, only that we are consistent in what bits feed the
401 hash so it comes out the same for the same file contents. */
402 {
403- auto inline void process (const void *data, size_t size);
404- auto inline void process (const void *data, size_t size)
405+ inline void process (const void *data, size_t size)
406 {
407 memchunk chunk = { .data = (void *) data, .size = size };
408 hashFunctionContextUpdateMC (&ctx, &chunk);
409 }
410+
411 union
412 {
413 GElf_Ehdr ehdr;
414@@ -1475,11 +1439,11 @@
415
416 /* Now format the build ID bits in hex to print out. */
417 {
418- const rpmuint8_t * id = (rpmuint8_t *)build_id->d_buf + build_id_offset;
419+ const unsigned char * id = (unsigned char *) build_id->d_buf + build_id_offset;
420 char hex[build_id_size * 2 + 1];
421 int n = snprintf (hex, 3, "%02" PRIx8, id[0]);
422 assert (n == 2);
423- for (i = 1; i < (int)build_id_size; ++i)
424+ for (i = 1; i < build_id_size; ++i)
425 {
426 n = snprintf (&hex[i * 2], 3, "%02" PRIx8, id[i]);
427 assert (n == 2);
428@@ -1502,7 +1466,8 @@
429 Elf_Data *build_id = NULL;
430 size_t build_id_offset = 0, build_id_size = 0;
431
432- optCon = poptGetContext("debugedit", argc, (const char **)argv, optionsTable, 0);
433+ optCon = poptGetContext("debugedit", argc, (const char **)argv,
434+ optionsTable, 0);
435
436 while ((nextopt = poptGetNextOpt (optCon)) > 0 || nextopt == POPT_ERROR_BADOPT)
437 /* do nothing */ ;
438@@ -1620,8 +1585,7 @@
439 Elf_Data src = dst;
440 src.d_buf = data->d_buf;
441 assert (sizeof (Elf32_Nhdr) == sizeof (Elf64_Nhdr));
442- while ((char *) data->d_buf + data->d_size -
443- (char *) src.d_buf > (int) sizeof nh
444+ while ((char *) data->d_buf + data->d_size - (char *) src.d_buf > (int) sizeof nh
445 && elf32_xlatetom (&dst, &src, dso->ehdr.e_ident[EI_DATA]))
446 {
447 Elf32_Word len = sizeof nh + nh.n_namesz;
448@@ -1631,8 +1595,7 @@
449 && !memcmp ((char *) src.d_buf + sizeof nh, "GNU", sizeof "GNU"))
450 {
451 build_id = data;
452- build_id_offset = (char *) src.d_buf + len -
453- (char *) data->d_buf;
454+ build_id_offset = (char *) src.d_buf + len - (char *) data->d_buf;
455 build_id_size = nh.n_descsz;
456 break;
457 }
This page took 1.772205 seconds and 4 git commands to generate.