1 --- rpm-4.3/file/src/readelf.c.orig 2003-04-15 17:19:30.000000000 +0200
2 +++ rpm-4.3/file/src/readelf.c 2004-02-24 22:15:06.302161792 +0100
5 + * Copyright (c) Christos Zoulas 2003.
6 + * All Rights Reserved.
8 + * Redistribution and use in source and binary forms, with or without
9 + * modification, are permitted provided that the following conditions
11 + * 1. Redistributions of source code must retain the above copyright
12 + * notice immediately at the beginning of the file, without modification,
13 + * this list of conditions, and the following disclaimer.
14 + * 2. Redistributions in binary form must reproduce the above copyright
15 + * notice, this list of conditions and the following disclaimer in the
16 + * documentation and/or other materials provided with the distribution.
17 + * 3. The name of the author may not be used to endorse or promote products
18 + * derived from this software without specific prior written permission.
20 + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
21 + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
24 + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36 FILE_RCSID("@(#)Id: readelf.c,v 1.22 2002/07/03 18:26:38 christos Exp ")
39 +static size_t donote(const fmagic fm, unsigned char *, size_t, size_t, int);
41 +#define ELF_ALIGN(a) ((((a) + align - 1) / align) * align)
45 @@ -100,230 +131,27 @@
46 #define ph_offset (fm->cls == ELFCLASS32 \
47 ? getu32(fm, ph32.p_offset) \
48 : getu64(fm, ph64.p_offset))
49 -#define ph_align (fm->cls == ELFCLASS32 \
50 - ? (ph32.p_align ? getu32(fm, ph32.p_align) : 4) \
51 - : (ph64.p_align ? getu64(fm, ph64.p_align) : 4))
52 +#define ph_align (int)((fm->cls == ELFCLASS32 \
53 + ? (off_t) (ph32.p_align ? \
54 + getu32(fm, ph32.p_align) : 4) \
55 + : (off_t) (ph64.p_align ? \
56 + getu64(fm, ph64.p_align) : 4)))
57 #define nh_size (fm->cls == ELFCLASS32 \
62 #define nh_type (fm->cls == ELFCLASS32 \
63 - ? getu32(fm, nh32->n_type) \
64 - : getu32(fm, nh64->n_type))
65 + ? getu32(fm, nh32.n_type) \
66 + : getu32(fm, nh64.n_type))
67 #define nh_namesz (fm->cls == ELFCLASS32 \
68 - ? getu32(fm, nh32->n_namesz) \
69 - : getu32(fm, nh64->n_namesz))
70 + ? getu32(fm, nh32.n_namesz) \
71 + : getu32(fm, nh64.n_namesz))
72 #define nh_descsz (fm->cls == ELFCLASS32 \
73 - ? getu32(fm, nh32->n_descsz) \
74 - : getu32(fm, nh64->n_descsz))
75 + ? getu32(fm, nh32.n_descsz) \
76 + : getu32(fm, nh64.n_descsz))
77 #define prpsoffsets(i) (fm->cls == ELFCLASS32 \
83 -doshn(fmagic fm, off_t off, int num, size_t size)
84 - /*@globals fileSystem @*/
85 - /*@modifies fm, fileSystem @*/
90 - if (size != sh_size) {
91 - error(EXIT_FAILURE, 0, "corrupted program header size.\n");
95 - if (lseek(fm->fd, off, SEEK_SET) == -1) {
96 - error(EXIT_FAILURE, 0, "lseek failed (%s).\n", strerror(errno));
100 - for ( ; num; num--) {
101 - if (read(fm->fd, sh_addr, size) == -1) {
102 - error(EXIT_FAILURE, 0, "read failed (%s).\n", strerror(errno));
105 - if (shs_type == SHT_SYMTAB /* || shs_type == SHT_DYNSYM */) {
106 - file_printf(fm, ", not stripped");
110 - file_printf(fm, ", stripped");
115 - * Look through the program headers of an executable image, searching
116 - * for a PT_INTERP section; if one is found, it's dynamically linked,
117 - * otherwise it's statically linked.
121 -dophn_exec(fmagic fm, off_t off, int num, size_t size)
122 - /*@globals fileSystem @*/
123 - /*@modifies fm, fileSystem @*/
126 - Elf32_Nhdr *nh32 = NULL;
128 - Elf64_Nhdr *nh64 = NULL;
129 - char *linking_style = "statically";
130 - char *shared_libraries = "";
133 - size_t offset, nameoffset;
135 - if (size != ph_size) {
136 - error(EXIT_FAILURE, 0, "corrupted program header size.\n");
140 - if (lseek(fm->fd, off, SEEK_SET) == -1) {
141 - error(EXIT_FAILURE, 0, "lseek failed (%s).\n", strerror(errno));
145 - for ( ; num; num--) {
146 - if (read(fm->fd, ph_addr, size) == -1) {
147 - error(EXIT_FAILURE, 0, "read failed (%s).\n", strerror(errno));
153 - linking_style = "dynamically";
154 - /*@switchbreak@*/ break;
156 - shared_libraries = " (uses shared libs)";
157 - /*@switchbreak@*/ break;
160 - * This is a PT_NOTE section; loop through all the notes
163 - if (lseek(fm->fd, (off_t) ph_offset, SEEK_SET) == -1) {
164 - error(EXIT_FAILURE, 0, "lseek failed (%s).\n", strerror(errno));
167 - bufsize = read(fm->fd, nbuf, sizeof(nbuf));
168 - if (bufsize == -1) {
169 - error(EXIT_FAILURE, 0, ": " "read failed (%s).\n",
175 - if (offset >= bufsize)
176 - /*@innerbreak@*/ break;
177 - if (fm->cls == ELFCLASS32)
178 - nh32 = (Elf32_Nhdr *)&nbuf[offset];
180 - nh64 = (Elf64_Nhdr *)&nbuf[offset];
183 - if (offset + nh_namesz >= bufsize) {
185 - * We're past the end of the buffer.
187 - /*@innerbreak@*/ break;
190 - nameoffset = offset;
191 - offset += nh_namesz;
192 - offset = ((offset+ph_align-1)/ph_align)*ph_align;
194 - if ((nh_namesz == 0) && (nh_descsz == 0)) {
196 - * We're out of note headers.
198 - /*@innerbreak@*/ break;
201 - if (offset + nh_descsz >= bufsize)
202 - /*@innerbreak@*/ break;
204 - if (nh_namesz == 4 &&
205 - strcmp(&nbuf[nameoffset], "GNU") == 0 &&
206 - nh_type == NT_GNU_VERSION &&
209 - (uint32_t *)&nbuf[offset];
211 - file_printf(fm, ", for GNU/");
212 - switch (getu32(fm, desc[0])) {
214 - file_printf(fm, "Linux");
215 - /*@switchbreak@*/ break;
217 - file_printf(fm, "Hurd");
218 - /*@switchbreak@*/ break;
219 - case GNU_OS_SOLARIS:
220 - file_printf(fm, "Solaris");
221 - /*@switchbreak@*/ break;
223 - file_printf(fm, "<unknown>");
224 - /*@switchbreak@*/ break;
226 - file_printf(fm, " %d.%d.%d",
227 - getu32(fm, desc[1]),
228 - getu32(fm, desc[2]),
229 - getu32(fm, desc[3]));
232 - if (nh_namesz == 7 &&
233 - strcmp(&nbuf[nameoffset], "NetBSD") == 0 &&
234 - nh_type == NT_NETBSD_VERSION &&
236 - file_printf(fm, ", for NetBSD");
238 - * Version number is stuck at 199905,
239 - * and hence is basically content-free.
243 - if (nh_namesz == 8 &&
244 - strcmp(&nbuf[nameoffset], "FreeBSD") == 0 &&
245 - nh_type == NT_FREEBSD_VERSION &&
247 - uint32_t desc = getu32(fm,
248 - *(uint32_t *)&nbuf[offset]);
249 - file_printf(fm, ", for FreeBSD");
251 - * Contents is __FreeBSD_version,
252 - * whose relation to OS versions is
253 - * defined by a huge table in the
254 - * Porters' Handbook. Happily, the
255 - * first three digits are the version
256 - * number, at least in versions of
257 - * FreeBSD that use this note.
260 - file_printf(fm, " %d.%d", desc / 100000,
261 - desc / 10000 % 10);
262 - if (desc / 1000 % 10 > 0)
263 - file_printf(fm, ".%d",
267 - if (nh_namesz == 8 &&
268 - strcmp(&nbuf[nameoffset], "OpenBSD") == 0 &&
269 - nh_type == NT_OPENBSD_VERSION &&
271 - file_printf(fm, ", for OpenBSD");
272 - /* Content of note is always 0 */
275 - if ((lseek(fm->fd, ph_offset + offset, SEEK_SET)) == -1) {
276 - error(EXIT_FAILURE, 0, "lseek failed (%s).\n", strerror(errno));
279 - /*@switchbreak@*/ break;
282 - file_printf(fm, ", %s linked%s", linking_style, shared_libraries);
287 /*@unchecked@*/ /*@observer@*/
288 static size_t prpsoffsets32[] = {
289 @@ -382,15 +210,10 @@
290 /*@modifies fm, fileSystem @*/
293 - Elf32_Nhdr *nh32 = NULL;
295 - Elf64_Nhdr *nh64 = NULL;
296 - size_t offset, nameoffset, noffset, reloffset;
303 + unsigned char nbuf[BUFSIZ];
306 if (size != ph_size) {
307 error(EXIT_FAILURE, 0, "corrupted program header size.\n");
308 @@ -401,11 +224,11 @@
309 * Loop through all the program headers.
311 for ( ; num; num--) {
312 - if (lseek(fm->fd, off, SEEK_SET) == -1) {
313 + if (lseek(fm->fd, off, SEEK_SET) == (off_t)-1) {
314 error(EXIT_FAILURE, 0, "lseek failed (%s).\n", strerror(errno));
317 - if (read(fm->fd, ph_addr, size) == -1) {
318 + if (read(fm->fd, ph_addr, ph_size) == -1) {
319 error(EXIT_FAILURE, 0, "read failed (%s).\n", strerror(errno));
323 * This is a PT_NOTE section; loop through all the notes
326 - if (lseek(fm->fd, (off_t) ph_offset, SEEK_SET) == -1) {
327 + if (lseek(fm->fd, (off_t) ph_offset, SEEK_SET) == (off_t)-1) {
328 error(EXIT_FAILURE, 0, "lseek failed (%s).\n", strerror(errno));
331 @@ -428,164 +251,379 @@
335 - if (offset >= bufsize)
336 + if (offset >= (size_t)bufsize)
337 /*@innerbreak@*/ break;
338 - if (fm->cls == ELFCLASS32)
339 - nh32 = (Elf32_Nhdr *)&nbuf[offset];
341 - nh64 = (Elf64_Nhdr *)&nbuf[offset];
343 + offset = donote(fm, nbuf, offset, (size_t)bufsize,
347 - * Check whether this note has the name "CORE" or
348 - * "FreeBSD", or "NetBSD-CORE".
350 - if (offset + nh_namesz >= bufsize) {
352 - * We're past the end of the buffer.
354 - /*@innerbreak@*/ break;
364 +donote(const fmagic fm, unsigned char *nbuf, size_t offset, size_t size,
374 - nameoffset = offset;
375 - offset += nh_namesz;
376 - offset = ((offset + 3)/4)*4;
377 + if (fm->cls == ELFCLASS32)
378 + memcpy(&nh32, &nbuf[offset], sizeof(nh32));
380 + memcpy(&nh64, &nbuf[offset], sizeof(nh64));
384 - * Sigh. The 2.0.36 kernel in Debian 2.1, at
385 - * least, doesn't correctly implement name
386 - * sections, in core dumps, as specified by
387 - * the "Program Linking" section of "UNIX(R) System
388 - * V Release 4 Programmer's Guide: ANSI C and
389 - * Programming Support Tools", because my copy
390 - * clearly says "The first 'namesz' bytes in 'name'
391 - * contain a *null-terminated* [emphasis mine]
392 - * character representation of the entry's owner
393 - * or originator", but the 2.0.36 kernel code
394 - * doesn't include the terminating null in the
397 - if (os_style == -1) {
398 - if ((nh_namesz == 4 &&
399 - strncmp(&nbuf[nameoffset],
400 - "CORE", 4) == 0) ||
402 - strcmp(&nbuf[nameoffset],
404 - os_style = OS_STYLE_SVR4;
406 - if ((nh_namesz == 8 &&
407 - strcmp(&nbuf[nameoffset],
408 - "FreeBSD") == 0)) {
409 - os_style = OS_STYLE_FREEBSD;
411 - if ((nh_namesz >= 11 &&
412 - strncmp(&nbuf[nameoffset],
413 - "NetBSD-CORE", 11) == 0)) {
414 - os_style = OS_STYLE_NETBSD;
416 - /*@innercontinue@*/ continue;
417 - file_printf(fm, ", %s-style", os_style_names[os_style]);
418 + if ((nh_namesz == 0) && (nh_descsz == 0)) {
420 + * We're out of note headers.
426 + doff = ELF_ALIGN(offset + nh_namesz);
428 + if (offset + nh_namesz >= size) {
430 + * We're past the end of the buffer.
435 + offset = ELF_ALIGN(doff + nh_descsz);
436 + if (offset + nh_descsz >= size)
439 + if (nh_namesz == 4 && strcmp((char *)&nbuf[noff], "GNU") == 0 &&
440 + nh_type == NT_GNU_VERSION && nh_descsz == 16) {
442 + (void)memcpy(desc, &nbuf[doff], sizeof(desc));
444 + file_printf(fm, ", for GNU/");
445 + switch (getu32(fm, desc[0])) {
447 + file_printf(fm, "Linux");
450 + file_printf(fm, "Hurd");
452 + case GNU_OS_SOLARIS:
453 + file_printf(fm, "Solaris");
456 + file_printf(fm, "<unknown>");
458 + file_printf(fm, " %d.%d.%d", getu32(fm, desc[1]),
459 + getu32(fm, desc[2]), getu32(fm, desc[3]));
463 + if (nh_namesz == 7 && strcmp((char *)&nbuf[noff], "NetBSD") == 0 &&
464 + nh_type == NT_NETBSD_VERSION && nh_descsz == 4) {
466 + (void)memcpy(&desc, &nbuf[doff], sizeof(desc));
467 + desc = getu32(fm, desc);
469 + file_printf(fm, ", for NetBSD");
471 + * The version number used to be stuck as 199905, and was thus
472 + * basically content-free. Newer versions of NetBSD have fixed
473 + * this and now use the encoding of __NetBSD_Version__:
477 + * M = major version
478 + * m = minor version
479 + * r = release ["",A-Z,Z[A-Z] but numeric]
482 + if (desc > 100000000U) {
483 + u_int ver_patch = (desc / 100) % 100;
484 + u_int ver_rel = (desc / 10000) % 100;
485 + u_int ver_min = (desc / 1000000) % 100;
486 + u_int ver_maj = desc / 100000000;
488 + file_printf(fm, " %u.%u", ver_maj, ver_min);
489 + if (ver_rel == 0 && ver_patch != 0) {
490 + file_printf(fm, ".%u", ver_patch);
491 + } else if (ver_rel != 0) {
492 + while (ver_rel > 26) {
493 + file_printf(fm, "Z");
496 + file_printf(fm, "%c", 'A' + ver_rel - 1);
502 - if (os_style == OS_STYLE_NETBSD &&
503 - nh_type == NT_NETBSD_CORE_PROCINFO) {
505 + if (nh_namesz == 8 && strcmp((char *)&nbuf[noff], "FreeBSD") == 0 &&
506 + nh_type == NT_FREEBSD_VERSION && nh_descsz == 4) {
508 + (void)memcpy(&desc, &nbuf[doff], sizeof(desc));
509 + desc = getu32(fm, desc);
510 + file_printf(fm, ", for FreeBSD");
512 + * Contents is __FreeBSD_version, whose relation to OS versions
513 + * is defined by a huge table in the Porters' Handbook. Happily,
514 + * the first three digits are the version number, at least in
515 + * versions of FreeBSD that use this note.
517 + file_printf(fm, " %d.%d", desc / 100000, desc / 10000 % 10);
518 + if (desc / 1000 % 10 > 0)
519 + file_printf(fm, ".%d", desc / 1000 % 10);
523 + if (nh_namesz == 8 && strcmp((char *)&nbuf[noff], "OpenBSD") == 0 &&
524 + nh_type == NT_OPENBSD_VERSION && nh_descsz == 4) {
525 + file_printf(fm, ", for OpenBSD");
526 + /* Content of note is always 0 */
531 + * Sigh. The 2.0.36 kernel in Debian 2.1, at
532 + * least, doesn't correctly implement name
533 + * sections, in core dumps, as specified by
534 + * the "Program Linking" section of "UNIX(R) System
535 + * V Release 4 Programmer's Guide: ANSI C and
536 + * Programming Support Tools", because my copy
537 + * clearly says "The first 'namesz' bytes in 'name'
538 + * contain a *null-terminated* [emphasis mine]
539 + * character representation of the entry's owner
540 + * or originator", but the 2.0.36 kernel code
541 + * doesn't include the terminating null in the
544 + if ((nh_namesz == 4 && strncmp((char *)&nbuf[noff], "CORE", 4) == 0) ||
545 + (nh_namesz == 5 && strcmp((char *)&nbuf[noff], "CORE") == 0)) {
546 + os_style = OS_STYLE_SVR4;
549 + if ((nh_namesz == 8 && strcmp((char *)&nbuf[noff], "FreeBSD") == 0)) {
550 + os_style = OS_STYLE_FREEBSD;
553 + if ((nh_namesz >= 11 && strncmp((char *)&nbuf[noff], "NetBSD-CORE", 11)
555 + os_style = OS_STYLE_NETBSD;
559 + if (os_style != -1)
560 + file_printf(fm, ", %s-style", os_style_names[os_style]);
562 + if (os_style == OS_STYLE_NETBSD && nh_type == NT_NETBSD_CORE_PROCINFO) {
565 + * Extract the program name. It is at
566 + * offset 0x7c, and is up to 32-bytes,
567 + * including the terminating NUL.
569 + file_printf(fm, ", from '%.31s'", &nbuf[doff + 0x7c]);
572 + * Extract the signal number. It is at
575 + memcpy(&signo, &nbuf[doff + 0x08],
577 + file_printf(fm, " (signal %u)", getu32(fm, signo));
579 + } else if (os_style != OS_STYLE_NETBSD && nh_type == NT_PRPSINFO) {
583 + * Extract the program name. We assume
584 + * it to be 16 characters (that's what it
585 + * is in SunOS 5.x and Linux).
587 + * Unfortunately, it's at a different offset
588 + * in varous OSes, so try multiple offsets.
589 + * If the characters aren't all printable,
592 + for (i = 0; i < NOFFSETS; i++) {
593 + size_t reloffset = prpsoffsets(i);
594 + size_t noffset = doff + reloffset;
595 + for (j = 0; j < 16; j++, noffset++, reloffset++) {
597 - * Extract the program name. It is at
598 - * offset 0x7c, and is up to 32-bytes,
599 - * including the terminating NUL.
601 - file_printf(fm, ", from '%.31s'", &nbuf[offset + 0x7c]);
604 - * Extract the signal number. It is at
606 + * Make sure we're not past
607 + * the end of the buffer; if
608 + * we are, just give up.
610 - memcpy(&signo, &nbuf[offset + 0x08],
612 - file_printf(fm, " (signal %u)", getu32(fm, signo));
614 - if (os_style != OS_STYLE_NETBSD &&
615 - nh_type == NT_PRPSINFO) {
616 + if (noffset >= size)
620 - * Extract the program name. We assume
621 - * it to be 16 characters (that's what it
622 - * is in SunOS 5.x and Linux).
624 - * Unfortunately, it's at a different offset
625 - * in varous OSes, so try multiple offsets.
626 - * If the characters aren't all printable,
628 + * Make sure we're not past
629 + * the end of the contents;
630 + * if we are, this obviously
631 + * isn't the right offset.
633 - for (i = 0; i < NOFFSETS; i++) {
634 - reloffset = prpsoffsets(i);
635 - noffset = offset + reloffset;
636 - for (j = 0; j < 16;
637 - j++, noffset++, reloffset++) {
639 - * Make sure we're not past
640 - * the end of the buffer; if
641 - * we are, just give up.
643 - if (noffset >= bufsize)
647 - * Make sure we're not past
648 - * the end of the contents;
649 - * if we are, this obviously
650 - * isn't the right offset.
652 - if (reloffset >= nh_descsz)
662 - * means we're done.
667 - /*@innerbreak@*/ break;
671 - * character is also
674 -#define isquote(c) (strchr("'\"`", (c)) != NULL)
680 + if (reloffset >= nh_descsz)
686 - * Well, that worked.
691 + * means we're done.
693 - file_printf(fm, ", from '%.16s'",
694 - &nbuf[offset + prpsoffsets(i)]);
695 - /*@innerbreak@*/ break;
706 + * character is also
709 +#define isquote(c) (strchr("'\"`", (c)) != NULL)
710 + if (!isprint(c) || isquote(c))
713 - /*@innerbreak@*/ break;
715 - offset += nh_descsz;
716 - offset = ((offset + 3)/4)*4;
719 + * Well, that worked.
721 + file_printf(fm, ", from '%.16s'",
722 + &nbuf[doff + prpsoffsets(i)]);
735 +doshn(fmagic fm, off_t off, int num, size_t size)
736 + /*@globals fileSystem @*/
737 + /*@modifies fm, fileSystem @*/
742 + if (size != sh_size) {
743 + error(EXIT_FAILURE, 0, "corrupted program header size.\n");
747 + if (lseek(fm->fd, off, SEEK_SET) == (off_t)-1) {
748 + error(EXIT_FAILURE, 0, "lseek failed (%s).\n", strerror(errno));
752 + for ( ; num; num--) {
753 + if (read(fm->fd, sh_addr, sh_size) == -1) {
754 + error(EXIT_FAILURE, 0, "read failed (%s).\n", strerror(errno));
757 + if (shs_type == SHT_SYMTAB /* || shs_type == SHT_DYNSYM */) {
758 + file_printf(fm, ", not stripped");
762 + file_printf(fm, ", stripped");
767 + * Look through the program headers of an executable image, searching
768 + * for a PT_INTERP section; if one is found, it's dynamically linked,
769 + * otherwise it's statically linked.
773 +dophn_exec(fmagic fm, off_t off, int num, size_t size)
774 + /*@globals fileSystem @*/
775 + /*@modifies fm, fileSystem @*/
779 + const char *linking_style = "statically";
780 + const char *shared_libraries = "";
781 + unsigned char nbuf[BUFSIZ];
786 + if (size != ph_size) {
787 + error(EXIT_FAILURE, 0, "corrupted program header size.\n");
791 + if (lseek(fm->fd, off, SEEK_SET) == (off_t)-1) {
792 + error(EXIT_FAILURE, 0, "lseek failed (%s).\n", strerror(errno));
796 + for ( ; num; num--) {
797 + if (read(fm->fd, ph_addr, ph_size) == -1) {
798 + error(EXIT_FAILURE, 0, "read failed (%s).\n", strerror(errno));
801 + if ((savedoffset = lseek(fm->fd, (off_t)0, SEEK_CUR)) == (off_t)-1) {
802 + error(EXIT_FAILURE, 0, "lseek failed (%s).\n", strerror(errno));
808 + linking_style = "dynamically";
809 + /*@switchbreak@*/ break;
811 + shared_libraries = " (uses shared libs)";
812 + /*@switchbreak@*/ break;
815 + * This is a PT_NOTE section; loop through all the notes
818 + if (lseek(fm->fd, (off_t) ph_offset, SEEK_SET) == -1) {
819 + error(EXIT_FAILURE, 0, "lseek failed (%s).\n", strerror(errno));
822 + bufsize = read(fm->fd, nbuf, sizeof(nbuf));
823 + if (bufsize == -1) {
824 + error(EXIT_FAILURE, 0, ": " "read failed (%s).\n",
830 + if (offset >= (size_t)bufsize)
831 + /*@innerbreak@*/ break;
832 + offset = donote(fm, nbuf, offset,
833 + (size_t)bufsize, ph_align);
835 + if ((lseek(fm->fd, savedoffset + offset, SEEK_SET)) == (off_t)-1) {
836 + error(EXIT_FAILURE, 0, "lseek failed (%s).\n", strerror(errno));
839 + /*@switchbreak@*/ break;
842 + file_printf(fm, ", %s linked%s", linking_style, shared_libraries);