Subversion Repositories Kolibri OS

Rev

Rev 5191 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 5191 Rev 6324
Line 1... Line 1...
1
/* Internal format of COFF object file data structures, for GNU BFD.
1
/* Internal format of COFF object file data structures, for GNU BFD.
2
   This file is part of BFD, the Binary File Descriptor library.
2
   This file is part of BFD, the Binary File Descriptor library.
3
   
3
 
4
   Copyright 1999, 2000, 2001, 2002, 2003, 2004. 2005, 2006, 2007, 2009,
-
 
5
   2010  Free Software Foundation, Inc.
4
   Copyright (C) 1999-2015 Free Software Foundation, Inc.
Line 6... Line 5...
6
 
5
 
7
   This program is free software; you can redistribute it and/or modify
6
   This program is free software; you can redistribute it and/or modify
8
   it under the terms of the GNU General Public License as published by
7
   it under the terms of the GNU General Public License as published by
9
   the Free Software Foundation; either version 3 of the License, or
8
   the Free Software Foundation; either version 3 of the License, or
10
   (at your option) any later version.
9
   (at your option) any later version.
11
   
10
 
12
   This program is distributed in the hope that it will be useful,
11
   This program is distributed in the hope that it will be useful,
13
   but WITHOUT ANY WARRANTY; without even the implied warranty of
12
   but WITHOUT ANY WARRANTY; without even the implied warranty of
14
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
   GNU General Public License for more details.
14
   GNU General Public License for more details.
16
   
15
 
17
   You should have received a copy of the GNU General Public License
16
   You should have received a copy of the GNU General Public License
18
   along with this program; if not, write to the Free Software
17
   along with this program; if not, write to the Free Software
19
   Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
18
   Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
Line 54... Line 53...
54
  unsigned short e_oemid;	/* OEM identifier (for e_oeminfo), 0x0 */
53
  unsigned short e_oemid;	/* OEM identifier (for e_oeminfo), 0x0 */
55
  unsigned short e_oeminfo;	/* OEM information; e_oemid specific, 0x0 */
54
  unsigned short e_oeminfo;	/* OEM information; e_oemid specific, 0x0 */
56
  unsigned short e_res2[10];	/* Reserved words, all 0x0 */
55
  unsigned short e_res2[10];	/* Reserved words, all 0x0 */
57
  bfd_vma  e_lfanew;		/* File address of new exe header, 0x80 */
56
  bfd_vma  e_lfanew;		/* File address of new exe header, 0x80 */
58
  unsigned long dos_message[16]; /* text which always follows dos header */
57
  unsigned long dos_message[16]; /* text which always follows dos header */
59
  bfd_vma  nt_signature;   	/* required NT signature, 0x4550 */ 
58
  bfd_vma  nt_signature;   	/* required NT signature, 0x4550 */
60
};
59
};
Line 61... Line 60...
61
 
60
 
Line 62... Line 61...
62
#define GO32_STUBSIZE 2048
61
#define GO32_STUBSIZE 2048
63
 
62
 
64
struct internal_filehdr
63
struct internal_filehdr
Line 65... Line 64...
65
{
64
{
66
  struct internal_extra_pe_filehdr pe;
65
  struct internal_extra_pe_filehdr pe;
67
 
66
 
68
  /* coff-stgo32 EXE stub header before BFD tdata has been allocated.
67
  /* coff-stgo32 EXE stub header before BFD tdata has been allocated.
69
     Its data is kept in INTERNAL_FILEHDR.GO32STUB afterwards.
68
     Its data is kept in INTERNAL_FILEHDR.GO32STUB afterwards.
70
     
69
 
Line 71... Line 70...
71
     F_GO32STUB is set iff go32stub contains a valid data.  Artifical headers
70
     F_GO32STUB is set iff go32stub contains a valid data.  Artifical headers
72
     created in BFD have no pre-set go32stub.  */
71
     created in BFD have no pre-set go32stub.  */
73
  char go32stub[GO32_STUBSIZE];
72
  char go32stub[GO32_STUBSIZE];
74
 
73
 
75
  /* Standard coff internal info.  */
74
  /* Standard coff internal info.  */
76
  unsigned short f_magic;	/* magic number			*/
75
  unsigned short f_magic;	/* magic number			*/
77
  unsigned short f_nscns;	/* number of sections		*/
76
  unsigned int   f_nscns;	/* number of sections		*/
78
  long f_timdat;		/* time & date stamp		*/
77
  long f_timdat;		/* time & date stamp		*/
Line 108... Line 107...
108
#define	F_SHROBJ	(0x2000)
107
#define	F_SHROBJ	(0x2000)
109
#define F_DLL           (0x2000)
108
#define F_DLL           (0x2000)
110
#define F_GO32STUB      (0x4000)
109
#define F_GO32STUB      (0x4000)
Line 111... Line 110...
111
 
110
 
112
/* Extra structure which is used in the optional header.  */
111
/* Extra structure which is used in the optional header.  */
113
typedef struct _IMAGE_DATA_DIRECTORY 
112
typedef struct _IMAGE_DATA_DIRECTORY
114
{
113
{
115
  bfd_vma VirtualAddress;
114
  bfd_vma VirtualAddress;
116
  long    Size;
115
  long    Size;
117
}  IMAGE_DATA_DIRECTORY;
116
}  IMAGE_DATA_DIRECTORY;
Line 131... Line 130...
131
#define PE_DELAY_IMPORT_DESCRIPTOR	13
130
#define PE_DELAY_IMPORT_DESCRIPTOR	13
132
#define PE_CLR_RUNTIME_HEADER		14
131
#define PE_CLR_RUNTIME_HEADER		14
133
/* DataDirectory[15] is currently reserved, so no define. */
132
/* DataDirectory[15] is currently reserved, so no define. */
134
#define IMAGE_NUMBEROF_DIRECTORY_ENTRIES  16
133
#define IMAGE_NUMBEROF_DIRECTORY_ENTRIES  16
Line -... Line 134...
-
 
134
 
-
 
135
/* Extra structure used in debug directory.  */
-
 
136
struct internal_IMAGE_DEBUG_DIRECTORY
-
 
137
{
-
 
138
  unsigned long  Characteristics;
-
 
139
  unsigned long  TimeDateStamp;
-
 
140
  unsigned short MajorVersion;
-
 
141
  unsigned short MinorVersion;
-
 
142
  unsigned long  Type;
-
 
143
  unsigned long  SizeOfData;
-
 
144
  unsigned long  AddressOfRawData;
-
 
145
  unsigned long  PointerToRawData;
-
 
146
};
-
 
147
 
-
 
148
#define PE_IMAGE_DEBUG_TYPE_UNKNOWN          0
-
 
149
#define PE_IMAGE_DEBUG_TYPE_COFF             1
-
 
150
#define PE_IMAGE_DEBUG_TYPE_CODEVIEW         2
-
 
151
#define PE_IMAGE_DEBUG_TYPE_FPO              3
-
 
152
#define PE_IMAGE_DEBUG_TYPE_MISC             4
-
 
153
#define PE_IMAGE_DEBUG_TYPE_EXCEPTION        5
-
 
154
#define PE_IMAGE_DEBUG_TYPE_FIXUP            6
-
 
155
#define PE_IMAGE_DEBUG_TYPE_OMAP_TO_SRC      7
-
 
156
#define PE_IMAGE_DEBUG_TYPE_OMAP_FROM_SRC    8
-
 
157
#define PE_IMAGE_DEBUG_TYPE_BORLAND          9
-
 
158
#define PE_IMAGE_DEBUG_TYPE_RESERVED10       10
-
 
159
#define PE_IMAGE_DEBUG_TYPE_CLSID            11
-
 
160
 
-
 
161
/* Extra structure for a codeview debug record */
-
 
162
#define CV_INFO_SIGNATURE_LENGTH 16
-
 
163
 
-
 
164
typedef struct _CODEVIEW_INFO
-
 
165
{
-
 
166
  unsigned long CVSignature;
-
 
167
  char          Signature[CV_INFO_SIGNATURE_LENGTH];
-
 
168
  unsigned int  SignatureLength;
-
 
169
  unsigned long Age;
-
 
170
  // char PdbFileName[];
-
 
171
} CODEVIEW_INFO;
135
 
172
 
136
/* Default image base for NT.  */
173
/* Default image base for NT.  */
137
#define NT_EXE_IMAGE_BASE 0x400000
174
#define NT_EXE_IMAGE_BASE 0x400000
Line 138... Line 175...
138
#define NT_DLL_IMAGE_BASE 0x10000000
175
#define NT_DLL_IMAGE_BASE 0x10000000
Line 146... Line 183...
146
#define PE_DEF_SECTION_ALIGNMENT 0x1000
183
#define PE_DEF_SECTION_ALIGNMENT 0x1000
147
#ifndef PE_DEF_FILE_ALIGNMENT
184
#ifndef PE_DEF_FILE_ALIGNMENT
148
# define PE_DEF_FILE_ALIGNMENT 0x200
185
# define PE_DEF_FILE_ALIGNMENT 0x200
149
#endif
186
#endif
Line 150... Line 187...
150
 
187
 
151
struct internal_extra_pe_aouthdr 
188
struct internal_extra_pe_aouthdr
152
{
189
{
153
  /* FIXME: The following entries are in AOUTHDR.  But they aren't
190
  /* FIXME: The following entries are in AOUTHDR.  But they aren't
154
     available internally in bfd.  We add them here so that objdump
191
     available internally in bfd.  We add them here so that objdump
155
     can dump them.  */
192
     can dump them.  */
156
  /* The state of the image file  */
193
  /* The state of the image file.  */
157
  short Magic;
194
  short Magic;
158
  /* Linker major version number */
195
  /* Linker major version number.  */
159
  char MajorLinkerVersion;
196
  char MajorLinkerVersion;
160
  /* Linker minor version number  */
197
  /* Linker minor version number.  */
161
  char MinorLinkerVersion;	
198
  char MinorLinkerVersion;	
162
  /* Total size of all code sections  */
199
  /* Total size of all code sections.  */
163
  long SizeOfCode;
200
  long SizeOfCode;
164
  /* Total size of all initialized data sections  */
201
  /* Total size of all initialized data sections.  */
165
  long SizeOfInitializedData;
202
  long SizeOfInitializedData;
166
  /* Total size of all uninitialized data sections  */
203
  /* Total size of all uninitialized data sections.  */
167
  long SizeOfUninitializedData;
204
  long SizeOfUninitializedData;
168
  /* Address of entry point relative to image base.  */
205
  /* Address of entry point relative to image base.  */
169
  bfd_vma AddressOfEntryPoint;
206
  bfd_vma AddressOfEntryPoint;
170
  /* Address of the first code section relative to image base.  */
207
  /* Address of the first code section relative to image base.  */
171
  bfd_vma BaseOfCode;
208
  bfd_vma BaseOfCode;
172
  /* Address of the first data section relative to image base.  */
209
  /* Address of the first data section relative to image base.  */
173
  bfd_vma BaseOfData;
210
  bfd_vma BaseOfData;
174
 
211
 
175
  /* PE stuff  */
212
  /* PE stuff  */
176
  bfd_vma ImageBase;		/* address of specific location in memory that
213
  bfd_vma ImageBase;		/* Address of specific location in memory that
Line 177... Line 214...
177
				   file is located, NT default 0x10000 */
214
				    file is located, NT default 0x10000.  */
178
 
215
 
179
  bfd_vma SectionAlignment;	/* section alignment default 0x1000 */
216
  bfd_vma SectionAlignment;	/* Section alignment default 0x1000.  */
180
  bfd_vma FileAlignment;	/* file alignment default 0x200 */
217
  bfd_vma FileAlignment;	/* File alignment default 0x200.  */
181
  short   MajorOperatingSystemVersion; /* minimum version of the operating */
218
  short   MajorOperatingSystemVersion; /* Minimum version of the operating.  */
182
  short   MinorOperatingSystemVersion; /* system req'd for exe, default to 1*/
219
  short   MinorOperatingSystemVersion; /* System req'd for exe, default to 1.  */
183
  short   MajorImageVersion;	/* user defineable field to store version of */
220
  short   MajorImageVersion;	/* User defineable field to store version of */
184
  short   MinorImageVersion;	/* exe or dll being created, default to 0 */ 
221
  short   MinorImageVersion;	/*  exe or dll being created, default to 0.  */ 
185
  short   MajorSubsystemVersion; /* minimum subsystem version required to */
222
  short   MajorSubsystemVersion; /* Minimum subsystem version required to */
186
  short   MinorSubsystemVersion; /* run exe; default to 3.1 */
223
  short   MinorSubsystemVersion; /*  run exe; default to 3.1.  */
187
  long    Reserved1;		/* seems to be 0 */
224
  long    Reserved1;		/* Seems to be 0.  */
188
  long    SizeOfImage;		/* size of memory to allocate for prog */
225
  long    SizeOfImage;		/* Size of memory to allocate for prog.  */
189
  long    SizeOfHeaders;	/* size of PE header and section table */
226
  long    SizeOfHeaders;	/* Size of PE header and section table.  */
Line 190... Line 227...
190
  long    CheckSum;		/* set to 0 */
227
  long    CheckSum;		/* Set to 0.  */
191
  short   Subsystem;	
228
  short   Subsystem;	
192
 
229
 
193
  /* type of subsystem exe uses for user interface,
230
  /* Type of subsystem exe uses for user interface,
194
     possible values:
231
     possible values:
195
     1 - NATIVE   Doesn't require a subsystem
232
     1 - NATIVE   Doesn't require a subsystem
196
     2 - WINDOWS_GUI runs in Windows GUI subsystem
233
     2 - WINDOWS_GUI runs in Windows GUI subsystem
197
     3 - WINDOWS_CUI runs in Windows char sub. (console app)
234
     3 - WINDOWS_CUI runs in Windows char sub. (console app)
198
     5 - OS2_CUI runs in OS/2 character subsystem
235
     5 - OS2_CUI runs in OS/2 character subsystem
199
     7 - POSIX_CUI runs in Posix character subsystem */
236
     7 - POSIX_CUI runs in Posix character subsystem.  */
200
  unsigned short DllCharacteristics; /* flags for DLL init  */
237
  unsigned short DllCharacteristics; /* flags for DLL init.  */
201
  bfd_vma SizeOfStackReserve;	/* amount of memory to reserve  */
238
  bfd_vma SizeOfStackReserve;	/* Amount of memory to reserve.  */
202
  bfd_vma SizeOfStackCommit;	/* amount of memory initially committed for 
239
  bfd_vma SizeOfStackCommit;	/* Amount of memory initially committed for
203
				   initial thread's stack, default is 0x1000 */
240
				    initial thread's stack, default is 0x1000.  */
204
  bfd_vma SizeOfHeapReserve;	/* amount of virtual memory to reserve and */
241
  bfd_vma SizeOfHeapReserve;	/* Amount of virtual memory to reserve and */
205
  bfd_vma SizeOfHeapCommit;	/* commit, don't know what to defaut it to */
242
  bfd_vma SizeOfHeapCommit;	/*  commit, don't know what to defaut it to.  */
206
  long    LoaderFlags;		/* can probably set to 0 */
243
  long    LoaderFlags;		/* Can probably set to 0.  */
Line 207... Line 244...
207
  long    NumberOfRvaAndSizes;	/* number of entries in next entry, 16 */
244
  long    NumberOfRvaAndSizes;	/* Number of entries in next entry, 16.  */
208
  IMAGE_DATA_DIRECTORY DataDirectory[IMAGE_NUMBEROF_DIRECTORY_ENTRIES];
245
  IMAGE_DATA_DIRECTORY DataDirectory[IMAGE_NUMBEROF_DIRECTORY_ENTRIES];
Line 549... Line 586...
549
    unsigned short x_tvndx;	/* tv index */
586
    unsigned short x_tvndx;	/* tv index */
550
  }      x_sym;
587
  }      x_sym;
Line 551... Line 588...
551
 
588
 
552
  union
589
  union
-
 
590
  {
-
 
591
    /* PR 17754: We use to FILNMLEN for the size of the x_fname
-
 
592
       array, but that cause problems as PE targets use a larger
-
 
593
       value.  We cannot use their definition of EFILNMLEN as this
553
  {
594
       header can be used without including any PE headers.  */
554
    char x_fname[FILNMLEN];
595
    char x_fname[20];
555
    struct
596
    struct
556
    {
597
    {
557
      long x_zeroes;
598
      long x_zeroes;
558
      long x_offset;
599
      long x_offset;