Deleted Added
full compact
sods.c (31442) sods.c (35575)
1/*
2 * Copyright (C) 1996-1997 John D. Polstra. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.

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

17 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23 * SUCH DAMAGE.
24 *
1/*
2 * Copyright (C) 1996-1997 John D. Polstra. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.

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

17 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23 * SUCH DAMAGE.
24 *
25 * $Id: sods.c,v 1.5 1997/09/02 21:54:39 jdp Exp $
25 * $Id: sods.c,v 1.6 1997/11/28 19:34:27 jdp Exp $
26 */
27
28#include <assert.h>
29#include <ctype.h>
30#include <fcntl.h>
31#include <stdarg.h>
32#include <stdio.h>
33#include <stdlib.h>
34#include <string.h>
35#include <unistd.h>
36
37#include <sys/types.h>
38#include <sys/mman.h>
39#include <sys/stat.h>
40
41#include <a.out.h>
26 */
27
28#include <assert.h>
29#include <ctype.h>
30#include <fcntl.h>
31#include <stdarg.h>
32#include <stdio.h>
33#include <stdlib.h>
34#include <string.h>
35#include <unistd.h>
36
37#include <sys/types.h>
38#include <sys/mman.h>
39#include <sys/stat.h>
40
41#include <a.out.h>
42#include <elf.h>
42#include <link.h>
43#include <stab.h>
44
45#define PAGE_SIZE 4096 /* i386 specific */
46
47#ifndef N_SETA
48#define N_SETA 0x14 /* Absolute set element symbol */
49#endif /* This is input to LD, in a .o file. */

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

168 close(fd);
169 return;
170 }
171
172 close(fd);
173
174 file_base = (const char *) objbase; /* Makes address arithmetic easier */
175
43#include <link.h>
44#include <stab.h>
45
46#define PAGE_SIZE 4096 /* i386 specific */
47
48#ifndef N_SETA
49#define N_SETA 0x14 /* Absolute set element symbol */
50#endif /* This is input to LD, in a .o file. */

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

169 close(fd);
170 return;
171 }
172
173 close(fd);
174
175 file_base = (const char *) objbase; /* Makes address arithmetic easier */
176
177 if (IS_ELF(*(Elf32_Ehdr*) file_base)) {
178 error("%s: this is an ELF program; use objdump to examine.", fname);
179 munmap(objbase, sb.st_size);
180 close(fd);
181 return;
182 }
183
176 ex = (const struct exec *) file_base;
177
178 printf("%s: a_midmag = 0x%lx\n", fname, ex->a_midmag);
179 printf(" magic = 0x%lx = 0%lo, netmagic = 0x%lx = 0%lo\n",
180 N_GETMAGIC(*ex), N_GETMAGIC(*ex),
181 N_GETMAGIC_NET(*ex), N_GETMAGIC_NET(*ex));
182
183 if (N_BADMAG(*ex)) {

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

206 assert(sym_count * sizeof sym_base[0] == ex->a_syms);
207
208 if (sym_count != 0) {
209 sym_used = (unsigned char *) calloc(sym_count, sizeof(unsigned char));
210 assert(sym_used != NULL);
211 }
212
213 printf(" Entry = 0x%lx\n", ex->a_entry);
184 ex = (const struct exec *) file_base;
185
186 printf("%s: a_midmag = 0x%lx\n", fname, ex->a_midmag);
187 printf(" magic = 0x%lx = 0%lo, netmagic = 0x%lx = 0%lo\n",
188 N_GETMAGIC(*ex), N_GETMAGIC(*ex),
189 N_GETMAGIC_NET(*ex), N_GETMAGIC_NET(*ex));
190
191 if (N_BADMAG(*ex)) {

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

214 assert(sym_count * sizeof sym_base[0] == ex->a_syms);
215
216 if (sym_count != 0) {
217 sym_used = (unsigned char *) calloc(sym_count, sizeof(unsigned char));
218 assert(sym_used != NULL);
219 }
220
221 printf(" Entry = 0x%lx\n", ex->a_entry);
214 printf(" Text offset = %x, address = %x\n", N_TXTOFF(*ex),
222 printf(" Text offset = %x, address = %lx\n", N_TXTOFF(*ex),
215 N_TXTADDR(*ex));
216 printf(" Data offset = %lx, address = %lx\n", N_DATOFF(*ex),
217 N_DATADDR(*ex));
218
219 /*
220 * In an executable program file, everything is relocated relative to
221 * the assumed run-time load address, i.e., N_TXTADDR(*ex), i.e., 0x1000.
222 *

--- 324 unchanged lines hidden ---
223 N_TXTADDR(*ex));
224 printf(" Data offset = %lx, address = %lx\n", N_DATOFF(*ex),
225 N_DATADDR(*ex));
226
227 /*
228 * In an executable program file, everything is relocated relative to
229 * the assumed run-time load address, i.e., N_TXTADDR(*ex), i.e., 0x1000.
230 *

--- 324 unchanged lines hidden ---