Release 940804
[wine/gsoc-2012-control.git] / loader / dump.c
blob08e1962d5a27254bb42b4ce984b93cb67c15b654
1 #ifndef WINELIB
2 static char RCSId[] = "$Id: dump.c,v 1.2 1993/07/04 04:04:21 root Exp root $";
3 static char Copyright[] = "Copyright Robert J. Amstadt, 1993";
5 #include <stdio.h>
6 #include <stdlib.h>
7 #include <sys/types.h>
8 #include <sys/stat.h>
9 #include <fcntl.h>
10 #include <unistd.h>
11 #ifdef linux
12 #include <linux/unistd.h>
13 #include <linux/head.h>
14 #include <linux/ldt.h>
15 #endif
16 #include <errno.h>
17 #include "neexe.h"
18 #include "segmem.h"
19 #include "prototypes.h"
21 /**********************************************************************
22 * PrintFileHeader
24 void
25 PrintFileHeader(struct ne_header_s *ne_header)
27 printf("ne_header: %c%c\n",
28 ne_header->header_type[0],
29 ne_header->header_type[1]);
30 printf("linker version: %d.%d\n", ne_header->linker_version,
31 ne_header->linker_revision);
32 printf("format flags: %04.4x\n", ne_header->format_flags);
33 printf("automatic data segment: %04.4x\n", ne_header->auto_data_seg);
34 printf("CS:IP %04.4x:%04.4x\n", ne_header->cs, ne_header->ip);
35 printf("SS:SP %04.4x:%04.4x\n", ne_header->ss, ne_header->sp);
36 printf("additional flags: %02.2x\n", ne_header->additional_flags);
37 printf("operating system: %02.2x\n", ne_header->operating_system);
38 printf("fast load offset: %04.4x\n", ne_header->fastload_offset);
39 printf("fast load length: %04.4x\n", ne_header->fastload_length);
42 /**********************************************************************
43 * PrintSegmentTable
45 void
46 PrintSegmentTable(struct ne_segment_table_entry_s *seg_table, int nentries)
48 int i;
50 for (i = 0; i < nentries; i++)
52 printf(" %2d: OFFSET %04.4x, LENGTH %04.4x, ",
53 i + 1, seg_table[i].seg_data_offset,
54 seg_table[i].seg_data_length);
55 printf("FLAGS %04.4x, MIN ALLOC %04.4x\n",
56 seg_table[i].seg_flags, seg_table[i].min_alloc);
60 /**********************************************************************
61 * PrintRelocationTable
63 void
64 PrintRelocationTable(char *exe_ptr,
65 struct ne_segment_table_entry_s *seg_entry_p,
66 int segment)
68 struct relocation_entry_s *rep;
69 int i;
70 int offset;
71 u_short n_entries, *sp;
73 printf("RELOCATION TABLE %d:\n", segment + 1);
75 if (seg_entry_p->seg_data_offset == 0)
76 return;
78 offset = seg_entry_p->seg_data_length;
79 if (offset == 0)
80 offset = 0x10000;
82 sp = (u_short *) (exe_ptr + seg_entry_p->seg_data_offset * 512 + offset);
83 n_entries = *sp;
85 rep = (struct relocation_entry_s *) (sp + 1);
86 for (i = 0; i < n_entries; i++, rep++)
88 printf(" ADDR TYPE %d, TYPE %d, OFFSET %04.4x,",
89 rep->address_type, rep->relocation_type, rep->offset);
90 printf("TARGET %04.4x %04.4x\n", rep->target1, rep->target2);
93 #endif /* ifndef WINELIB */