Deleted Added
full compact
ldd.c (181136) ldd.c (181161)
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

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

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
31#include <sys/cdefs.h>
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

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

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
31#include <sys/cdefs.h>
32__FBSDID("$FreeBSD: head/usr.bin/ldd/ldd.c 181136 2008-08-01 21:52:41Z jhb $");
32__FBSDID("$FreeBSD: head/usr.bin/ldd/ldd.c 181161 2008-08-02 12:04:59Z jhb $");
33
34#include <sys/wait.h>
35
36#include <machine/elf.h>
37
38#include <arpa/inet.h>
39
40#include <a.out.h>

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

78
79static int
80execldd32(char *file, char *fmt1, char *fmt2, int aflag, int vflag)
81{
82 char *argv[8];
83 int i, rval, status;
84
85 unsetenv(LD_ "TRACE_LOADED_OBJECTS");
33
34#include <sys/wait.h>
35
36#include <machine/elf.h>
37
38#include <arpa/inet.h>
39
40#include <a.out.h>

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

78
79static int
80execldd32(char *file, char *fmt1, char *fmt2, int aflag, int vflag)
81{
82 char *argv[8];
83 int i, rval, status;
84
85 unsetenv(LD_ "TRACE_LOADED_OBJECTS");
86
87 rval = 0;
88 i = 0;
89 argv[i++] = strdup(_PATH_LDD32);
90 if (aflag)
91 argv[i++] = strdup("-a");
92 if (vflag)
93 argv[i++] = strdup("-v");
86 rval = 0;
87 i = 0;
88 argv[i++] = strdup(_PATH_LDD32);
89 if (aflag)
90 argv[i++] = strdup("-a");
91 if (vflag)
92 argv[i++] = strdup("-v");
94 if (fmt1) {
93 if (fmt1 != NULL) {
95 argv[i++] = strdup("-f");
96 argv[i++] = strdup(fmt1);
97 }
94 argv[i++] = strdup("-f");
95 argv[i++] = strdup(fmt1);
96 }
98 if (fmt2) {
97 if (fmt2 != NULL) {
99 argv[i++] = strdup("-f");
100 argv[i++] = strdup(fmt2);
101 }
98 argv[i++] = strdup("-f");
99 argv[i++] = strdup(fmt2);
100 }
102
103 argv[i++] = strdup(file);
104 argv[i++] = NULL;
105
106 switch (fork()) {
107 case -1:
108 err(1, "fork");
109 break;
110 case 0:
111 execv(_PATH_LDD32, argv);
112 warn("%s", _PATH_LDD32);
101 argv[i++] = strdup(file);
102 argv[i++] = NULL;
103
104 switch (fork()) {
105 case -1:
106 err(1, "fork");
107 break;
108 case 0:
109 execv(_PATH_LDD32, argv);
110 warn("%s", _PATH_LDD32);
113 _exit(1);
111 _exit(127);
114 break;
115 default:
112 break;
113 default:
116 if (wait(&status) <= 0) {
114 if (wait(&status) < 0)
117 rval = 1;
115 rval = 1;
118 } else if (WIFSIGNALED(status)) {
116 else if (WIFSIGNALED(status))
119 rval = 1;
117 rval = 1;
120 } else if (WIFEXITED(status) && WEXITSTATUS(status)) {
118 else if (WIFEXITED(status) && WEXITSTATUS(status) != 0)
121 rval = 1;
119 rval = 1;
122 }
123 break;
124 }
125 while (i--)
126 free(argv[i]);
127 setenv(LD_ "TRACE_LOADED_OBJECTS", "yes", 1);
128 return (rval);
129}
130#endif

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

227 printf("%s:\n", *argv);
228 fflush(stdout);
229
230 switch (fork()) {
231 case -1:
232 err(1, "fork");
233 break;
234 default:
120 break;
121 }
122 while (i--)
123 free(argv[i]);
124 setenv(LD_ "TRACE_LOADED_OBJECTS", "yes", 1);
125 return (rval);
126}
127#endif

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

224 printf("%s:\n", *argv);
225 fflush(stdout);
226
227 switch (fork()) {
228 case -1:
229 err(1, "fork");
230 break;
231 default:
235 if (wait(&status) <= 0) {
232 if (wait(&status) < 0) {
236 warn("wait");
237 rval |= 1;
238 } else if (WIFSIGNALED(status)) {
239 fprintf(stderr, "%s: signal %d\n", *argv,
240 WTERMSIG(status));
241 rval |= 1;
233 warn("wait");
234 rval |= 1;
235 } else if (WIFSIGNALED(status)) {
236 fprintf(stderr, "%s: signal %d\n", *argv,
237 WTERMSIG(status));
238 rval |= 1;
242 } else if (WIFEXITED(status) && WEXITSTATUS(status)) {
239 } else if (WIFEXITED(status) &&
240 WEXITSTATUS(status) != 0) {
243 fprintf(stderr, "%s: exit status %d\n", *argv,
244 WEXITSTATUS(status));
245 rval |= 1;
246 }
247 break;
248 case 0:
249 if (is_shlib == 0) {
250 execl(*argv, *argv, (char *)NULL);

--- 141 unchanged lines hidden ---
241 fprintf(stderr, "%s: exit status %d\n", *argv,
242 WEXITSTATUS(status));
243 rval |= 1;
244 }
245 break;
246 case 0:
247 if (is_shlib == 0) {
248 execl(*argv, *argv, (char *)NULL);

--- 141 unchanged lines hidden ---