ldd.c (38648) | ldd.c (39354) |
---|---|
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 --- 13 unchanged lines hidden (view full) --- 22 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 23 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 24 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 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 * | 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 --- 13 unchanged lines hidden (view full) --- 22 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 23 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 24 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 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 * $Id: ldd.c,v 1.15 1998/05/01 08:40:11 dfr Exp $ | 30 * $Id: ldd.c,v 1.16 1998/08/30 18:30:59 jdp Exp $ |
31 */ 32 33#include <sys/types.h> 34#include <sys/stat.h> 35#include <sys/file.h> 36#include <sys/time.h> 37#include <sys/resource.h> 38#include <sys/wait.h> --- 50 unchanged lines hidden (view full) --- 89 if (vflag && fmt1) 90 errx(1, "-v may not be used with -f"); 91 92 if (argc <= 0) { 93 usage(); 94 /*NOTREACHED*/ 95 } 96 | 31 */ 32 33#include <sys/types.h> 34#include <sys/stat.h> 35#include <sys/file.h> 36#include <sys/time.h> 37#include <sys/resource.h> 38#include <sys/wait.h> --- 50 unchanged lines hidden (view full) --- 89 if (vflag && fmt1) 90 errx(1, "-v may not be used with -f"); 91 92 if (argc <= 0) { 93 usage(); 94 /*NOTREACHED*/ 95 } 96 |
97#ifdef __i386__ |
|
97 if (vflag) { 98 for (c = 0; c < argc; c++) 99 dump_file(argv[c]); 100 exit(error_count == 0 ? EXIT_SUCCESS : EXIT_FAILURE); 101 } | 98 if (vflag) { 99 for (c = 0; c < argc; c++) 100 dump_file(argv[c]); 101 exit(error_count == 0 ? EXIT_SUCCESS : EXIT_FAILURE); 102 } |
103#endif |
|
102 103 /* ld.so magic */ 104 setenv("LD_TRACE_LOADED_OBJECTS", "1", 1); 105 if (fmt1) 106 setenv("LD_TRACE_LOADED_OBJECTS_FMT1", fmt1, 1); 107 if (fmt2) 108 setenv("LD_TRACE_LOADED_OBJECTS_FMT2", fmt2, 1); 109 110 rval = 0; 111 for ( ; argc > 0; argc--, argv++) { 112 int fd; 113 union { 114 struct exec aout; | 104 105 /* ld.so magic */ 106 setenv("LD_TRACE_LOADED_OBJECTS", "1", 1); 107 if (fmt1) 108 setenv("LD_TRACE_LOADED_OBJECTS_FMT1", fmt1, 1); 109 if (fmt2) 110 setenv("LD_TRACE_LOADED_OBJECTS_FMT2", fmt2, 1); 111 112 rval = 0; 113 for ( ; argc > 0; argc--, argv++) { 114 int fd; 115 union { 116 struct exec aout; |
115 Elf32_Ehdr elf; | 117 Elf_Ehdr elf; |
116 } hdr; 117 int n; 118 int status; 119 int file_ok; 120 121 if ((fd = open(*argv, O_RDONLY, 0)) < 0) { 122 warn("%s", *argv); 123 rval |= 1; --- 13 unchanged lines hidden (view full) --- 137#if 1 /* Compatibility */ 138 || hdr.aout.a_entry < __LDPGSZ 139#endif 140 ) { 141 warnx("%s: not a dynamic executable", *argv); 142 file_ok = 0; 143 } 144 } else if (n >= sizeof hdr.elf && IS_ELF(hdr.elf)) { | 118 } hdr; 119 int n; 120 int status; 121 int file_ok; 122 123 if ((fd = open(*argv, O_RDONLY, 0)) < 0) { 124 warn("%s", *argv); 125 rval |= 1; --- 13 unchanged lines hidden (view full) --- 139#if 1 /* Compatibility */ 140 || hdr.aout.a_entry < __LDPGSZ 141#endif 142 ) { 143 warnx("%s: not a dynamic executable", *argv); 144 file_ok = 0; 145 } 146 } else if (n >= sizeof hdr.elf && IS_ELF(hdr.elf)) { |
145 Elf32_Ehdr ehdr; 146 Elf32_Phdr phdr; | 147 Elf_Ehdr ehdr; 148 Elf_Phdr phdr; |
147 int dynamic = 0, i; 148 149 lseek(fd, 0, SEEK_SET); 150 if (read(fd, &ehdr, sizeof ehdr) != sizeof ehdr) { 151 warnx("%s: can't read program header", *argv); 152 file_ok = 0; 153 } 154 lseek(fd, 0, ehdr.e_phoff); --- 58 unchanged lines hidden --- | 149 int dynamic = 0, i; 150 151 lseek(fd, 0, SEEK_SET); 152 if (read(fd, &ehdr, sizeof ehdr) != sizeof ehdr) { 153 warnx("%s: can't read program header", *argv); 154 file_ok = 0; 155 } 156 lseek(fd, 0, ehdr.e_phoff); --- 58 unchanged lines hidden --- |