Deleted Added
full compact
ldd.c (69827) ldd.c (70049)
1/*
2 * Copyright (c) 1993 Paul Kranenburg
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 16 unchanged lines hidden (view full) ---

25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
28 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
31#ifndef lint
32static const char rcsid[] =
1/*
2 * Copyright (c) 1993 Paul Kranenburg
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 16 unchanged lines hidden (view full) ---

25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
28 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
31#ifndef lint
32static const char rcsid[] =
33 "$FreeBSD: head/usr.bin/ldd/ldd.c 69827 2000-12-10 20:54:13Z charnier $";
33 "$FreeBSD: head/usr.bin/ldd/ldd.c 70049 2000-12-15 13:20:43Z ache $";
34#endif /* not lint */
35
36#include <sys/wait.h>
37#include <a.out.h>
38#include <elf.h>
39#include <err.h>
40#include <fcntl.h>
41#include <stdio.h>

--- 98 unchanged lines hidden (view full) ---

140 warnx("%s: not a dynamic executable", *argv);
141 file_ok = 0;
142 }
143 } else if (n >= sizeof hdr.elf && IS_ELF(hdr.elf)) {
144 Elf_Ehdr ehdr;
145 Elf_Phdr phdr;
146 int dynamic = 0, i;
147
34#endif /* not lint */
35
36#include <sys/wait.h>
37#include <a.out.h>
38#include <elf.h>
39#include <err.h>
40#include <fcntl.h>
41#include <stdio.h>

--- 98 unchanged lines hidden (view full) ---

140 warnx("%s: not a dynamic executable", *argv);
141 file_ok = 0;
142 }
143 } else if (n >= sizeof hdr.elf && IS_ELF(hdr.elf)) {
144 Elf_Ehdr ehdr;
145 Elf_Phdr phdr;
146 int dynamic = 0, i;
147
148 lseek(fd, 0, SEEK_SET);
149 if (read(fd, &ehdr, sizeof ehdr) != sizeof ehdr) {
148 if (lseek(fd, 0, SEEK_SET) == -1 ||
149 read(fd, &ehdr, sizeof ehdr) != sizeof ehdr ||
150 lseek(fd, ehdr.e_phoff, SEEK_SET) == -1
151 ) {
150 warnx("%s: can't read program header", *argv);
151 file_ok = 0;
152 warnx("%s: can't read program header", *argv);
153 file_ok = 0;
152 }
153 lseek(fd, 0, ehdr.e_phoff);
154 for (i = 0; i < ehdr.e_phnum; i++) {
155 if (read(fd, &phdr, ehdr.e_phentsize)
156 != sizeof phdr) {
157 warnx("%s: can't read program header",
158 *argv);
159 file_ok = 0;
154 } else {
155 for (i = 0; i < ehdr.e_phnum; i++) {
156 if (read(fd, &phdr, ehdr.e_phentsize)
157 != sizeof phdr) {
158 warnx("%s: can't read program header",
159 *argv);
160 file_ok = 0;
161 break;
162 }
163 if (phdr.p_type == PT_DYNAMIC)
164 dynamic = 1;
160 }
165 }
161 if (phdr.p_type == PT_DYNAMIC)
162 dynamic = 1;
163 }
164 if (!dynamic) {
165 warnx("%s: not a dynamic executable", *argv);
166 file_ok = 0;
167 }
168 } else {
169 warnx("%s: not a dynamic executable", *argv);
170 file_ok = 0;

--- 41 unchanged lines hidden ---
166 }
167 if (!dynamic) {
168 warnx("%s: not a dynamic executable", *argv);
169 file_ok = 0;
170 }
171 } else {
172 warnx("%s: not a dynamic executable", *argv);
173 file_ok = 0;

--- 41 unchanged lines hidden ---