projects/aports·blob master · refs

808 lines · 24.6 KiB

1--- a/subprojects/debugedit/tools/debugedit.c
2+++ b/subprojects/debugedit/tools/debugedit.c
3@@ -25,7 +25,7 @@
4 #include <byteswap.h>
5 #include <endian.h>
6 #include <errno.h>
7-#include <error.h>
8+#include <err.h>
9 #include <limits.h>
10 #include <string.h>
11 #include <stdlib.h>
12@@ -536,7 +535,7 @@
13 relbuf = malloc (maxndx * sizeof (REL));
14 *reltype = dso->shdr[i].sh_type;
15 if (relbuf == NULL)
16- error (1, errno, "%s: Could not allocate memory", dso->filename);
17+ err (1, "%s: Could not allocate memory", dso->filename);
18
19 symdata = elf_getdata (dso->scn[dso->shdr[i].sh_link], NULL);
20 assert (symdata != NULL && symdata->d_buf != NULL);
21@@ -626,7 +625,7 @@
22 #endif
23 default:
24 fail:
25- error (1, 0, "%s: Unhandled relocation %d at [%d] for %s section",
26+ err (1, "%s: Unhandled relocation %d at [%d] for %s section",
27 dso->filename, rtype, ndx, sec->name);
28 }
29 relend->ptr = sec->data
30@@ -669,17 +668,17 @@
31 int ndx = relptr->ndx;
32
33 if (gelf_getrela (data, ndx, &rela) == NULL)
34- error (1, 0, "Couldn't get relocation: %s",
35+ err (1, "Couldn't get relocation: %s",
36 elf_errmsg (-1));
37
38 if (gelf_getsym (symdata, GELF_R_SYM (rela.r_info),
39 &sym) == NULL)
40- error (1, 0, "Couldn't get symbol: %s", elf_errmsg (-1));
41+ err (1, "Couldn't get symbol: %s", elf_errmsg (-1));
42
43 rela.r_addend = relptr->addend - sym.st_value;
44
45 if (gelf_update_rela (data, ndx, &rela) == 0)
46- error (1, 0, "Couldn't update relocations: %s",
47+ err (1, "Couldn't update relocations: %s",
48 elf_errmsg (-1));
49
50 ++relptr;
51@@ -738,7 +737,7 @@
52 if (h == NULL)
53 {
54 no_memory:
55- error (0, ENOMEM, "%s: Could not read .debug_abbrev", dso->filename);
56+ err (0, "%s: Could not read .debug_abbrev", dso->filename);
57 if (h)
58 htab_delete (h);
59 return NULL;
60@@ -760,7 +759,7 @@
61 }
62 if (*slot != NULL)
63 {
64- error (0, 0, "%s: Duplicate DWARF abbreviation %d", dso->filename,
65+ err (0, "%s: Duplicate DWARF abbreviation %d", dso->filename,
66 t->entry);
67 free (t);
68 htab_delete (h);
69@@ -796,7 +795,7 @@
70 || form == DW_FORM_addrx3
71 || form == DW_FORM_addrx4)))
72 {
73- error (0, 0, "%s: Unknown DWARF DW_FORM_0x%x", dso->filename,
74+ err (0, "%s: Unknown DWARF DW_FORM_0x%x", dso->filename,
75 form);
76 htab_delete (h);
77 return NULL;
78@@ -812,7 +811,7 @@
79 }
80 if (read_uleb128 (ptr) != 0)
81 {
82- error (0, 0, "%s: DWARF abbreviation does not end with 2 zeros",
83+ err (0, "%s: DWARF abbreviation does not end with 2 zeros",
84 dso->filename);
85 htab_delete (h);
86 return NULL;
87@@ -1016,7 +1015,7 @@
88 + (STRIDXENTRIES * sizeof (struct stridxentry)));
89 struct strentblock *newentries = malloc (entriessz);
90 if (newentries == NULL)
91- error (1, errno, "Couldn't allocate new string entries block");
92+ err (1, "Couldn't allocate new string entries block");
93 else
94 {
95 if (strings->entries == NULL)
96@@ -1036,7 +1035,7 @@
97 struct stridxentry **tres = tsearch (entry, &strings->strent_root,
98 strent_compare);
99 if (tres == NULL)
100- error (1, ENOMEM, "Couldn't insert new strtab idx");
101+ err (1, "Couldn't insert new strtab idx");
102 else if (*tres == entry)
103 {
104 /* idx not yet seen, must add actual str. */
105@@ -1078,7 +1077,7 @@
106 debug_section *sec = &debug_sections[line_strp
107 ? DEBUG_LINE_STR : DEBUG_STR];
108 if (old_idx >= sec->size)
109- error (1, 0, "Bad string pointer index %zd (%s)", old_idx, sec->name);
110+ err (1, "Bad string pointer index %zd (%s)", old_idx, sec->name);
111
112 Strent *strent;
113 const char *old_str = (char *)sec->data + old_idx;
114@@ -1099,7 +1098,7 @@
115 nsize += 1 + file_len; /* + '/' */
116 char *nname = new_string_storage (strings, nsize);
117 if (nname == NULL)
118- error (1, ENOMEM, "Couldn't allocate new string storage");
119+ err (1, "Couldn't allocate new string storage");
120 memcpy (nname, dest_dir, dest_len);
121 if (file_len > 0)
122 {
123@@ -1113,7 +1112,7 @@
124 ret = true;
125 }
126 if (strent == NULL)
127- error (1, ENOMEM, "Could not create new string table entry");
128+ err (1, "Could not create new string table entry");
129 else
130 entry->entry = strent;
131 }
132@@ -1134,13 +1133,13 @@
133 debug_section *sec = &debug_sections[line_strp
134 ? DEBUG_LINE_STR : DEBUG_STR];
135 if (old_idx >= sec->size)
136- error (1, 0, "Bad string pointer index %zd (%s)", old_idx, sec->name);
137+ err (1, "Bad string pointer index %zd (%s)", old_idx, sec->name);
138
139 const char *str = (char *)sec->data + old_idx;
140 Strent *strent = strtab_add_len (strings->str_tab,
141 str, strlen (str) + 1);
142 if (strent == NULL)
143- error (1, ENOMEM, "Could not create new string table entry");
144+ err (1, "Could not create new string table entry");
145 else
146 entry->entry = strent;
147 }
148@@ -1217,7 +1216,7 @@
149 + MIN_LINE_TABLES)));
150 if (new_table == NULL)
151 {
152- error (0, ENOMEM, "Couldn't add more debug_line tables");
153+ err (0, "Couldn't add more debug_line tables");
154 *table = NULL;
155 return false;
156 }
157@@ -1238,13 +1237,13 @@
158 unsigned char *endsec = ptr + debug_sections[DEBUG_LINE].size;
159 if (ptr == NULL)
160 {
161- error (0, 0, "%s: No .line_table section", dso->filename);
162+ err (0, "%s: No .line_table section", dso->filename);
163 return false;
164 }
165
166 if (off > debug_sections[DEBUG_LINE].size)
167 {
168- error (0, 0, "%s: Invalid .line_table offset 0x%zx",
169+ err (0, "%s: Invalid .line_table offset 0x%zx",
170 dso->filename, off);
171 return false;
172 }
173@@ -1256,13 +1255,13 @@
174 endcu += t->unit_length;
175 if (endcu == ptr + 0xffffffff)
176 {
177- error (0, 0, "%s: 64-bit DWARF not supported", dso->filename);
178+ err (0, "%s: 64-bit DWARF not supported", dso->filename);
179 return false;
180 }
181
182 if (endcu > endsec)
183 {
184- error (0, 0, "%s: .debug_line CU does not fit into section",
185+ err (0, "%s: .debug_line CU does not fit into section",
186 dso->filename);
187 return false;
188 }
189@@ -1271,7 +1270,7 @@
190 t->version = read_16 (ptr);
191 if (t->version != 2 && t->version != 3 && t->version != 4 && t->version != 5)
192 {
193- error (0, 0, "%s: DWARF version %d unhandled", dso->filename,
194+ err (0, "%s: DWARF version %d unhandled", dso->filename,
195 t->version);
196 return false;
197 }
198@@ -1282,7 +1281,7 @@
199 assert (ptr_size != 0);
200 if (ptr_size != read_8 (ptr))
201 {
202- error (0, 0, "%s: .debug_line address size differs from .debug_info",
203+ err (0, "%s: .debug_line address size differs from .debug_info",
204 dso->filename);
205 return false;
206 }
207@@ -1297,7 +1296,7 @@
208 endprol += t->header_length;
209 if (endprol > endcu)
210 {
211- error (0, 0, "%s: .debug_line CU prologue does not fit into CU",
212+ err (0, "%s: .debug_line CU prologue does not fit into CU",
213 dso->filename);
214 return false;
215 }
216@@ -1323,7 +1322,7 @@
217
218 if (ptr + t->opcode_base - 1 >= endcu)
219 {
220- error (0, 0, "%s: .debug_line opcode table does not fit into CU",
221+ err (0, "%s: .debug_line opcode table does not fit into CU",
222 dso->filename);
223 return false;
224 }
225@@ -1378,7 +1377,7 @@
226
227 dso->lines.line_buf = malloc (dso->lines.debug_lines_len);
228 if (dso->lines.line_buf == NULL)
229- error (1, ENOMEM, "No memory for new .debug_line table (0x%zx bytes)",
230+ err (1, "No memory for new .debug_line table (0x%zx bytes)",
231 dso->lines.debug_lines_len);
232
233 linedata->d_size = dso->lines.debug_lines_len;
234@@ -1651,7 +1650,7 @@
235 assert (len < UINT_MAX);
236 break;
237 default:
238- error (0, 0, "%s: Unknown DWARF DW_FORM_0x%x", dso->filename, *formp);
239+ err (0, "%s: Unknown DWARF DW_FORM_0x%x", dso->filename, *formp);
240 return FORM_ERROR;
241 }
242
243@@ -1719,7 +1718,7 @@
244
245 if (value >= dirt_cnt)
246 {
247- error (0, 0, "%s: Wrong directory table index %u",
248+ err (0, "%s: Wrong directory table index %u",
249 dso->filename, value);
250 return false;
251 }
252@@ -1743,7 +1742,7 @@
253 s = malloc (comp_dir_len + 1 + file_len + 1 + dir_len + 1);
254 if (s == NULL)
255 {
256- error (0, ENOMEM, "%s: Reading file table", dso->filename);
257+ err (0, "%s: Reading file table", dso->filename);
258 return false;
259 }
260 if (*file == '/')
261@@ -1789,7 +1788,7 @@
262 {
263 ssize_t ret = write (list_file_fd, p, size);
264 if (ret == -1)
265- error (1, errno, "Could not write to '%s'", list_file);
266+ err (1, "Could not write to '%s'", list_file);
267 size -= ret;
268 p += ret;
269 }
270@@ -1838,7 +1837,7 @@
271 *ndir = entry_count;
272 *dirs = malloc (entry_count * sizeof (char *));
273 if (*dirs == NULL)
274- error (1, errno, "%s: Could not allocate debug_line dirs",
275+ err (1, "%s: Could not allocate debug_line dirs",
276 dso->filename);
277 }
278
279@@ -1889,7 +1888,7 @@
280 }
281 break;
282 default:
283- error (0, 0, "%s: Unsupported "
284+ err (0, "%s: Unsupported "
285 ".debug_line %s %u path DW_FORM_0x%x",
286 dso->filename, entry_name, entryi, form);
287 return false;
288@@ -1914,7 +1913,7 @@
289 dirndx = do_read_32 (*ptrp);
290 break;
291 default:
292- error (0, 0, "%s: Unsupported "
293+ err (0, "%s: Unsupported "
294 ".debug_line %s %u dirndx DW_FORM_0x%x",
295 dso->filename, entry_name, entryi, form);
296 return false;
297@@ -1922,7 +1921,7 @@
298
299 if (dirndx > *ndir)
300 {
301- error (0, 0, "%s: Bad dir number %u in .debug_line %s",
302+ err (0, "%s: Bad dir number %u in .debug_line %s",
303 dso->filename, entryi, entry_name);
304 return false;
305 }
306@@ -1946,7 +1945,7 @@
307 case FORM_ERROR:
308 return false;
309 case FORM_INDIRECT:
310- error (0, 0, "%s: Unsupported "
311+ err (0, "%s: Unsupported "
312 ".debug_line %s %u DW_FORM_indirect",
313 dso->filename, entry_name, entryi);
314 return false;
315@@ -1967,7 +1966,7 @@
316 char *s = malloc (comp_dir_len + 1 + file_len + 1 + dir_len + 1);
317 if (s == NULL)
318 {
319- error (0, ENOMEM, "%s: Reading file table", dso->filename);
320+ err (0, "%s: Reading file table", dso->filename);
321 return false;
322 }
323 if (file[0] == '/')
324@@ -2013,7 +2012,7 @@
325 {
326 ssize_t ret = write (list_file_fd, p, size);
327 if (ret == -1)
328- error (1, errno, "Could not write to '%s'", list_file);
329+ err (1, "Could not write to '%s'", list_file);
330 size -= ret;
331 p += ret;
332 }
333@@ -2126,7 +2125,7 @@
334 debug_section *sec = &debug_sections[line_strp
335 ? DEBUG_LINE_STR : DEBUG_STR];
336 if (sec->data == NULL || idx >= sec->size)
337- error (1, 0, "%s: Bad string pointer index %zd for comp_dir (%s)",
338+ err (1, "%s: Bad string pointer index %zd for comp_dir (%s)",
339 dso->filename, idx, sec->name);
340 dir = (char *) sec->data + idx;
341
342@@ -2229,7 +2228,7 @@
343 producers will use DW_FORM_strp which is
344 more efficient. */
345 if (orig_len < new_len)
346- error (0, 0, "Warning, not replacing comp_dir "
347+ err (0, "Warning, not replacing comp_dir "
348 "'%s' prefix ('%s' -> '%s') encoded as "
349 "DW_FORM_string. "
350 "Replacement too large.",
351@@ -2281,7 +2280,7 @@
352 ? DEBUG_LINE_STR
353 : DEBUG_STR];
354 if (idx >= sec->size)
355- error (1, 0,
356+ err (1,
357 "%s: Bad string pointer index %zd for unit name (%s)",
358 dso->filename, idx, sec->name);
359 char *name = (char *) sec->data + idx;
360@@ -2356,7 +2355,7 @@
361 {
362 ssize_t ret = write (list_file_fd, p, size);
363 if (ret == -1)
364- error (1, errno, "Could not write to '%s'", list_file);
365+ err (1, "Could not write to '%s'", list_file);
366 size -= ret;
367 p += ret;
368 }
369@@ -2370,7 +2369,7 @@
370 else
371 ret = write (list_file_fd, "", 1);
372 if (ret == -1)
373- error (1, errno, "Could not write to '%s'", list_file);
374+ err (1, "Could not write to '%s'", list_file);
375 }
376 }
377 }
378@@ -2423,7 +2422,7 @@
379 /* header size, version, unit_type, ptr_size. */
380 if (ptr + 4 + 2 + 1 + 1 > endsec)
381 {
382- error (0, 0, "%s: %s CU header too small",
383+ err (0, "%s: %s CU header too small",
384 dso->filename, sec->name);
385 return 1;
386 }
387@@ -2432,13 +2431,13 @@
388 endcu += read_32 (ptr);
389 if (endcu == ptr + 0xffffffff)
390 {
391- error (0, 0, "%s: 64-bit DWARF not supported", dso->filename);
392+ err (0, "%s: 64-bit DWARF not supported", dso->filename);
393 return 1;
394 }
395
396 if (endcu > endsec)
397 {
398- error (0, 0, "%s: %s too small", dso->filename, sec->name);
399+ err (0, "%s: %s too small", dso->filename, sec->name);
400 return 1;
401 }
402
403@@ -2446,7 +2445,7 @@
404 if (cu_version != 2 && cu_version != 3 && cu_version != 4
405 && cu_version != 5)
406 {
407- error (0, 0, "%s: DWARF version %d unhandled", dso->filename,
408+ err (0, "%s: DWARF version %d unhandled", dso->filename,
409 cu_version);
410 return 1;
411 }
412@@ -2458,7 +2457,7 @@
413 uint8_t unit_type = read_8 (ptr);
414 if (unit_type != DW_UT_compile && unit_type != DW_UT_partial)
415 {
416- error (0, 0, "%s: Unit type %u unhandled", dso->filename,
417+ err (0, "%s: Unit type %u unhandled", dso->filename,
418 unit_type);
419 return 1;
420 }
421@@ -2469,7 +2468,7 @@
422 unsigned char *header_end = (cu_start + 23 + (cu_version < 5 ? 0 : 1));
423 if (header_end > endsec)
424 {
425- error (0, 0, "%s: %s CU header too small", dso->filename, sec->name);
426+ err (0, "%s: %s CU header too small", dso->filename, sec->name);
427 return 1;
428 }
429
430@@ -2477,9 +2476,9 @@
431 if (value >= debug_sections[DEBUG_ABBREV].size)
432 {
433 if (debug_sections[DEBUG_ABBREV].data == NULL)
434- error (0, 0, "%s: .debug_abbrev not present", dso->filename);
435+ err (0, "%s: .debug_abbrev not present", dso->filename);
436 else
437- error (0, 0, "%s: DWARF CU abbrev offset too large",
438+ err (0, "%s: DWARF CU abbrev offset too large",
439 dso->filename);
440 return 1;
441 }
442@@ -2492,14 +2491,14 @@
443 ptr_size = cu_ptr_size;
444 if (ptr_size != 4 && ptr_size != 8)
445 {
446- error (0, 0, "%s: Invalid DWARF pointer size %d",
447+ err (0, "%s: Invalid DWARF pointer size %d",
448 dso->filename, ptr_size);
449 return 1;
450 }
451 }
452 else if (cu_ptr_size != ptr_size)
453 {
454- error (0, 0, "%s: DWARF pointer size differs between CUs",
455+ err (0, "%s: DWARF pointer size differs between CUs",
456 dso->filename);
457 return 1;
458 }
459@@ -2520,7 +2519,7 @@
460 t = htab_find_with_hash (abbrev, &tag, tag.entry);
461 if (t == NULL)
462 {
463- error (0, 0, "%s: Could not find DWARF abbreviation %d",
464+ err (0, "%s: Could not find DWARF abbreviation %d",
465 dso->filename, tag.entry);
466 htab_delete (abbrev);
467 return 1;
468@@ -2592,7 +2591,7 @@
469 {
470 if (j != DEBUG_MACRO && j != DEBUG_TYPES)
471 {
472- error (0, 0, "%s: Found two copies of %s section",
473+ err (0, "%s: Found two copies of %s section",
474 dso->filename, name);
475 return 1;
476 }
477@@ -2603,7 +2602,7 @@
478 struct debug_section *sec;
479 sec = calloc (sizeof (struct debug_section), 1);
480 if (sec == NULL)
481- error (1, errno,
482+ err (1,
483 "%s: Could not allocate more %s sections",
484 dso->filename, name);
485 sec->name = name;
486@@ -2632,7 +2631,7 @@
487
488 if (debug_sections[j].name == NULL)
489 {
490- error (0, 0, "%s: Unknown debugging section %s",
491+ err (0, "%s: Unknown debugging section %s",
492 dso->filename, name);
493 }
494 }
495@@ -2664,7 +2663,7 @@
496 multi_sec = multi_sec->next;
497 }
498 if (multi_sec == NULL)
499- error (0, 1, "No %s reloc section: %s",
500+ err (0, "No %s reloc section: %s",
501 debug_sections[j].name, dso->filename);
502 }
503 else
504@@ -2690,7 +2689,7 @@
505 }
506 else
507 {
508- error (0, 0, "%s: Wrong ELF data enconding", dso->filename);
509+ err (0, "%s: Wrong ELF data enconding", dso->filename);
510 return 1;
511 }
512
513@@ -2758,7 +2757,7 @@
514 rels = dso->shdr[rndx].sh_size / dso->shdr[rndx].sh_entsize;
515 rbuf = malloc (rels * sizeof (LINE_REL));
516 if (rbuf == NULL)
517- error (1, errno, "%s: Could not allocate line relocations",
518+ err (1, "%s: Could not allocate line relocations",
519 dso->filename);
520
521 /* Sort them by offset into section. */
522@@ -2768,7 +2767,7 @@
523 {
524 GElf_Rela rela;
525 if (gelf_getrela (rdata, i, &rela) == NULL)
526- error (1, 0, "Couldn't get relocation: %s",
527+ err (1, "Couldn't get relocation: %s",
528 elf_errmsg (-1));
529 rbuf[i].r_offset = rela.r_offset;
530 rbuf[i].ndx = i;
531@@ -2777,7 +2776,7 @@
532 {
533 GElf_Rel rel;
534 if (gelf_getrel (rdata, i, &rel) == NULL)
535- error (1, 0, "Couldn't get relocation: %s",
536+ err (1, "Couldn't get relocation: %s",
537 elf_errmsg (-1));
538 rbuf[i].r_offset = rel.r_offset;
539 rbuf[i].ndx = i;
540@@ -2798,14 +2797,14 @@
541 if (rtype == SHT_RELA)
542 {
543 if (gelf_getrela (rdata, ndx, &rela) == NULL)
544- error (1, 0, "Couldn't get relocation: %s",
545+ err (1, "Couldn't get relocation: %s",
546 elf_errmsg (-1));
547 r_offset = rela.r_offset;
548 }
549 else
550 {
551 if (gelf_getrel (rdata, ndx, &rel) == NULL)
552- error (1, 0, "Couldn't get relocation: %s",
553+ err (1, "Couldn't get relocation: %s",
554 elf_errmsg (-1));
555 r_offset = rel.r_offset;
556 }
557@@ -2817,7 +2816,7 @@
558 lndx++;
559
560 if (lndx >= dso->lines.used)
561- error (1, 0,
562+ err (1,
563 ".debug_line relocation offset out of range");
564
565 /* Offset (pointing into the line program) moves
566@@ -2831,14 +2830,14 @@
567 {
568 rela.r_offset = r_offset;
569 if (gelf_update_rela (rdata, ndx, &rela) == 0)
570- error (1, 0, "Couldn't update relocation: %s",
571+ err (1, "Couldn't update relocation: %s",
572 elf_errmsg (-1));
573 }
574 else
575 {
576 rel.r_offset = r_offset;
577 if (gelf_update_rel (rdata, ndx, &rel) == 0)
578- error (1, 0, "Couldn't update relocation: %s",
579+ err (1, "Couldn't update relocation: %s",
580 elf_errmsg (-1));
581 }
582 }
583@@ -2874,17 +2873,17 @@
584 macro_version = read_16 (ptr);
585 macro_flags = read_8 (ptr);
586 if (macro_version < 4 || macro_version > 5)
587- error (1, 0, "unhandled .debug_macro version: %d",
588+ err (1, "unhandled .debug_macro version: %d",
589 macro_version);
590 if ((macro_flags & ~2) != 0)
591- error (1, 0, "unhandled .debug_macro flags: 0x%x",
592+ err (1, "unhandled .debug_macro flags: 0x%x",
593 macro_flags);
594
595 offset_len = (macro_flags & 0x01) ? 8 : 4;
596 line_offset = (macro_flags & 0x02) ? 1 : 0;
597
598 if (offset_len != 4)
599- error (0, 1,
600+ err (0,
601 "Cannot handle 8 byte macro offsets: %s",
602 dso->filename);
603
604@@ -2943,7 +2942,7 @@
605 ptr += offset_len;
606 break;
607 default:
608- error (1, 0, "Unhandled DW_MACRO op 0x%x", op);
609+ err (1, "Unhandled DW_MACRO op 0x%x", op);
610 break;
611 }
612 }
613@@ -3098,26 +3097,26 @@
614 elf = elf_begin (fd, ELF_C_RDWR, NULL);
615 if (elf == NULL)
616 {
617- error (0, 0, "cannot open ELF file: %s", elf_errmsg (-1));
618+ err (0, "cannot open ELF file: %s", elf_errmsg (-1));
619 goto error_out;
620 }
621
622 if (elf_kind (elf) != ELF_K_ELF)
623 {
624- error (0, 0, "\"%s\" is not an ELF file", name);
625+ err (0, "\"%s\" is not an ELF file", name);
626 goto error_out;
627 }
628
629 if (gelf_getehdr (elf, &ehdr) == NULL)
630 {
631- error (0, 0, "cannot get the ELF header: %s",
632+ err (0, "cannot get the ELF header: %s",
633 elf_errmsg (-1));
634 goto error_out;
635 }
636
637 if (ehdr.e_type != ET_DYN && ehdr.e_type != ET_EXEC && ehdr.e_type != ET_REL)
638 {
639- error (0, 0, "\"%s\" is not a shared library", name);
640+ err (0, "\"%s\" is not a shared library", name);
641 goto error_out;
642 }
643
644@@ -3128,13 +3127,13 @@
645 + (ehdr.e_shnum + 20) * sizeof(Elf_Scn *));
646 if (!dso)
647 {
648- error (0, ENOMEM, "Could not open DSO");
649+ err (0, "Could not open DSO");
650 goto error_out;
651 }
652
653 if (elf_getphdrnum (elf, &phnum) != 0)
654 {
655- error (0, 0, "Couldn't get number of phdrs: %s", elf_errmsg (-1));
656+ err (0, "Couldn't get number of phdrs: %s", elf_errmsg (-1));
657 goto error_out;
658 }
659
660@@ -3187,7 +3186,7 @@
661
662 if (build_id_size != 16 && build_id_size != 20)
663 {
664- error (1, 0, "Cannot handle %Zu-byte build ID", build_id_size);
665+ err (1, "Cannot handle %Zu-byte build ID", build_id_size);
666 }
667
668 int i = -1;
669@@ -3239,7 +3238,7 @@
670 if (elf64_xlatetom (&x, &x, dso->ehdr.e_ident[EI_DATA]) == NULL)
671 {
672 bad:
673- error (1, 0, "Failed to compute header checksum: %s",
674+ err (1, "Failed to compute header checksum: %s",
675 elf_errmsg (elf_errno ()));
676 }
677
678@@ -3384,7 +3383,7 @@
679
680 if (optind != argc - 1)
681 {
682- error (0, 0, "Need one FILE as input");
683+ err (0, "Need one FILE as input");
684 usage (argv[0], true);
685 }
686
687@@ -3392,18 +3391,18 @@
688 {
689 if (base_dir == NULL)
690 {
691- error (1, 0, "You must specify a base dir if you specify a dest dir");
692+ err (1, "You must specify a base dir if you specify a dest dir");
693 }
694 }
695
696 if (build_id_seed != NULL && do_build_id == 0)
697 {
698- error (1, 0, "--build-id-seed (-s) needs --build-id (-i)");
699+ err (1, "--build-id-seed (-s) needs --build-id (-i)");
700 }
701
702 if (build_id_seed != NULL && strlen (build_id_seed) < 1)
703 {
704- error (1, 0, "--build-id-seed (-s) string should be at least 1 char");
705+ err (1, "--build-id-seed (-s) string should be at least 1 char");
706 }
707
708 /* Ensure clean paths, users can muck with these. Also removes any
709@@ -3422,22 +3421,22 @@
710
711 if (elf_version(EV_CURRENT) == EV_NONE)
712 {
713- error (1, 0, "library out of date");
714+ err (1, "library out of date");
715 }
716
717 if (stat(file, &stat_buf) < 0)
718 {
719- error (1, errno, "Failed to open input file '%s'", file);
720+ err (1, "Failed to open input file '%s'", file);
721 }
722
723 /* Make sure we can read and write */
724 if (chmod (file, stat_buf.st_mode | S_IRUSR | S_IWUSR) != 0)
725- error (0, errno, "Failed to chmod input file '%s' to make sure we can read and write", file);
726+ err (0, "Failed to chmod input file '%s' to make sure we can read and write", file);
727
728 fd = open (file, O_RDWR);
729 if (fd < 0)
730 {
731- error (1, errno, "Failed to open input file '%s'", file);
732+ err (1, "Failed to open input file '%s'", file);
733 }
734
735 dso = fdopen_dso (fd, file);
736@@ -3465,7 +3464,7 @@
737 /* TODO: Handle stabs */
738 if (strcmp (name, ".stab") == 0)
739 {
740- error (0, 0, "Stabs debuginfo not supported: %s", file);
741+ err (0, "Stabs debuginfo not supported: %s", file);
742 break;
743 }
744 if (!(do_build_id && no_recompute_build_id && !base_dir && !dest_dir)
745@@ -3542,7 +3541,7 @@
746 GElf_Shdr shdr_mem;
747 GElf_Shdr *shdr = gelf_getshdr (scn, &shdr_mem);
748 if (shdr == NULL)
749- error (1, 0, "Couldn't get shdr: %s", elf_errmsg (-1));
750+ err (1, "Couldn't get shdr: %s", elf_errmsg (-1));
751
752 /* Any sections we have changed aren't allocated sections,
753 so we don't need to lookup any changed section sizes. */
754@@ -3562,7 +3561,7 @@
755 GElf_Shdr shdr_mem;
756 GElf_Shdr *shdr = gelf_getshdr (scn, &shdr_mem);
757 if (shdr == NULL)
758- error (1, 0, "Couldn't get shdr: %s", elf_errmsg (-1));
759+ err (1, "Couldn't get shdr: %s", elf_errmsg (-1));
760
761 /* A bug in elfutils before 0.169 means we have to write out
762 all section data, even when nothing changed.
763@@ -3611,7 +3610,7 @@
764 shdr->sh_size = sec_size;
765 shdr->sh_offset = sec_offset;
766 if (gelf_update_shdr (scn, shdr) == 0)
767- error (1, 0, "Couldn't update shdr: %s",
768+ err (1, "Couldn't update shdr: %s",
769 elf_errmsg (-1));
770 }
771 }
772@@ -3625,13 +3624,13 @@
773 {
774 dso->ehdr.e_shoff = new_offset;
775 if (gelf_update_ehdr (elf, &dso->ehdr) == 0)
776- error (1, 0, "Couldn't update ehdr: %s", elf_errmsg (-1));
777+ err (1, "Couldn't update ehdr: %s", elf_errmsg (-1));
778 }
779 }
780
781 if (elf_update (dso->elf, ELF_C_NULL) < 0)
782 {
783- error (1, 0, "Failed to update file: %s", elf_errmsg (elf_errno ()));
784+ err (1, "Failed to update file: %s", elf_errmsg (elf_errno ()));
785 }
786
787 if (do_build_id && build_id != NULL)
788@@ -3639,17 +3638,17 @@
789
790 if (elf_update (dso->elf, ELF_C_WRITE) < 0)
791 {
792- error (1, 0, "Failed to write file: %s", elf_errmsg (elf_errno()));
793+ err (1, "Failed to write file: %s", elf_errmsg (elf_errno()));
794 }
795 if (elf_end (dso->elf) < 0)
796 {
797- error (1, 0, "elf_end failed: %s", elf_errmsg (elf_errno()));
798+ err (1, "elf_end failed: %s", elf_errmsg (elf_errno()));
799 }
800 close (fd);
801
802 /* Restore old access rights */
803 if (chmod (file, stat_buf.st_mode) != 0)
804- error (0, errno, "Failed to chmod input file '%s' to restore old access rights", file);
805+ err (0, "Failed to chmod input file '%s' to restore old access rights", file);
806
807 free ((char *) dso->filename);
808 destroy_strings (&dso->debug_str);