Release 950706
[wine] / loader / dump.c
1 #ifndef WINELIB
2 /*
3 static char RCSId[] = "$Id: dump.c,v 1.2 1993/07/04 04:04:21 root Exp root $";
4 static char Copyright[] = "Copyright  Robert J. Amstadt, 1993";
5 */
6 #include <stdio.h>
7 #include <stdlib.h>
8 #include <sys/types.h>
9 #include <sys/stat.h>
10 #include <fcntl.h>
11 #include <unistd.h>
12 #ifdef linux
13 #include <linux/unistd.h>
14 #include <linux/head.h>
15 #include <linux/ldt.h>
16 #endif
17 #include <errno.h>
18 #include "neexe.h"
19 #include "prototypes.h"
20
21 /**********************************************************************
22  *                                      PrintFileHeader
23  */
24 void
25 PrintFileHeader(struct ne_header_s *ne_header)
26 {
27     printf("ne_header: %c%c\n",
28            ne_header->ne_magic & 0xff,
29            ne_header->ne_magic >> 8 );
30     printf("linker version: %d.%d\n", ne_header->linker_version,
31            ne_header->linker_revision);
32     printf("format flags: %04x\n", ne_header->format_flags);
33     printf("automatic data segment: %04x\n", ne_header->auto_data_seg);
34     printf("CS:IP  %04x:%04x\n", ne_header->cs, ne_header->ip);
35     printf("SS:SP  %04x:%04x\n", ne_header->ss, ne_header->sp);
36     printf("additional flags: %02x\n", ne_header->additional_flags);
37     printf("operating system: %02x\n", ne_header->operating_system);
38     printf("fast load offset: %04x\n", ne_header->fastload_offset);
39     printf("fast load length: %04x\n", ne_header->fastload_length);
40 }
41 \f
42 /**********************************************************************
43  *                                      PrintRelocationTable
44  */
45 void 
46 PrintRelocationTable(char *exe_ptr, 
47                      struct ne_segment_table_entry_s *seg_entry_p,
48                      int segment)
49 {
50     struct relocation_entry_s *rep;
51     int i;
52     int offset;
53     u_short n_entries, *sp;
54
55     printf("RELOCATION TABLE %d:\n", segment + 1);
56     
57     if (seg_entry_p->seg_data_offset == 0)
58         return;
59
60     offset = seg_entry_p->seg_data_length;
61     if (offset == 0)
62         offset = 0x10000;
63
64     sp = (u_short *) (exe_ptr + seg_entry_p->seg_data_offset * 512 + offset);
65     n_entries = *sp;
66
67     rep = (struct relocation_entry_s *) (sp + 1);
68     for (i = 0; i < n_entries; i++, rep++)
69     {
70         printf("  ADDR TYPE %d,  TYPE %d,  OFFSET %04x,",
71                rep->address_type, rep->relocation_type, rep->offset);
72         printf("TARGET %04x %04x\n", rep->target1, rep->target2);
73     }
74 }
75 #endif /* ifndef WINELIB */