Subversion Repositories Kolibri OS

Rev

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

Rev 5191 Rev 6324
Line 1... Line 1...
1
/* pe.h  -  PE COFF header information 
1
/* pe.h  -  PE COFF header information
Line 2... Line -...
2
 
-
 
3
   Copyright 1999, 2000, 2001, 2003, 2004, 2005, 2006, 2007, 2009, 2010
2
 
Line 4... Line 3...
4
   Free Software Foundation, Inc.
3
   Copyright (C) 1999-2015 Free Software Foundation, Inc.
Line 5... Line 4...
5
 
4
 
6
   This file is part of BFD, the Binary File Descriptor library.
5
   This file is part of BFD, the Binary File Descriptor library.
Line 39... Line 38...
39
#define IMAGE_FILE_UP_SYSTEM_ONLY            0x4000
38
#define IMAGE_FILE_UP_SYSTEM_ONLY            0x4000
40
#define IMAGE_FILE_BYTES_REVERSED_HI         0x8000
39
#define IMAGE_FILE_BYTES_REVERSED_HI         0x8000
Line 41... Line 40...
41
 
40
 
42
/* DllCharacteristics flag bits.  The inconsistent naming may seem
41
/* DllCharacteristics flag bits.  The inconsistent naming may seem
-
 
42
   odd, but that is how they are defined in the PE specification.  */
43
   odd, but that is how they are defined in the PE specification.  */
43
#define IMAGE_DLL_CHARACTERISTICS_HIGH_ENTROPY_VA       0x0020
44
#define IMAGE_DLL_CHARACTERISTICS_DYNAMIC_BASE          0x0040
44
#define IMAGE_DLL_CHARACTERISTICS_DYNAMIC_BASE          0x0040
45
#define IMAGE_DLL_CHARACTERISTICS_FORCE_INTEGRITY       0x0080
45
#define IMAGE_DLL_CHARACTERISTICS_FORCE_INTEGRITY       0x0080
46
#define IMAGE_DLL_CHARACTERISTICS_NX_COMPAT             0x0100
46
#define IMAGE_DLL_CHARACTERISTICS_NX_COMPAT             0x0100
47
#define IMAGE_DLLCHARACTERISTICS_NO_ISOLATION           0x0200
47
#define IMAGE_DLLCHARACTERISTICS_NO_ISOLATION           0x0200
Line 100... Line 100...
100
#define IMAGE_SCN_ALIGN_1024BYTES	     IMAGE_SCN_ALIGN_POWER_CONST (10)
100
#define IMAGE_SCN_ALIGN_1024BYTES	     IMAGE_SCN_ALIGN_POWER_CONST (10)
101
#define IMAGE_SCN_ALIGN_2048BYTES	     IMAGE_SCN_ALIGN_POWER_CONST (11)
101
#define IMAGE_SCN_ALIGN_2048BYTES	     IMAGE_SCN_ALIGN_POWER_CONST (11)
102
#define IMAGE_SCN_ALIGN_4096BYTES	     IMAGE_SCN_ALIGN_POWER_CONST (12)
102
#define IMAGE_SCN_ALIGN_4096BYTES	     IMAGE_SCN_ALIGN_POWER_CONST (12)
103
#define IMAGE_SCN_ALIGN_8192BYTES	     IMAGE_SCN_ALIGN_POWER_CONST (13)
103
#define IMAGE_SCN_ALIGN_8192BYTES	     IMAGE_SCN_ALIGN_POWER_CONST (13)
Line 104... Line 104...
104
 
104
 
105
/* Encode alignment power into IMAGE_SCN_ALIGN bits of s_flags */
105
/* Encode alignment power into IMAGE_SCN_ALIGN bits of s_flags.  */
106
#define COFF_ENCODE_ALIGNMENT(SECTION, ALIGNMENT_POWER) \
106
#define COFF_ENCODE_ALIGNMENT(SECTION, ALIGNMENT_POWER) \
Line 107... Line 107...
107
  ((SECTION).s_flags |= IMAGE_SCN_ALIGN_POWER_CONST ((ALIGNMENT_POWER)))
107
  ((SECTION).s_flags |= IMAGE_SCN_ALIGN_POWER_CONST ((ALIGNMENT_POWER)))
108
 
108
 
Line 199... Line 199...
199
  char dos_message[16][4];	/* Other stuff, always follow DOS header.  */
199
  char dos_message[16][4];	/* Other stuff, always follow DOS header.  */
200
};
200
};
Line 201... Line 201...
201
 
201
 
202
struct external_PEI_IMAGE_hdr
202
struct external_PEI_IMAGE_hdr
203
{
203
{
Line 204... Line 204...
204
  char nt_signature[4];		/* required NT signature, 0x4550.  */
204
  char nt_signature[4];		/* Required NT signature, 0x4550.  */
205
 
205
 
206
  /* From standard header.  */
206
  /* From standard header.  */
207
  char f_magic[2];		/* Magic number.		*/
207
  char f_magic[2];		/* Magic number.		*/
Line 238... Line 238...
238
  char dos_message[16][4];	/* Other stuff, always follow DOS header.  */
238
  char dos_message[16][4];	/* Other stuff, always follow DOS header.  */
Line 239... Line 239...
239
 
239
 
240
  /* Note: additional bytes may be inserted before the signature.  Use
240
  /* Note: additional bytes may be inserted before the signature.  Use
Line 241... Line 241...
241
   the e_lfanew field to find the actual location of the NT signature.  */
241
   the e_lfanew field to find the actual location of the NT signature.  */
Line 242... Line 242...
242
 
242
 
243
  char nt_signature[4];		/* required NT signature, 0x4550.  */
243
  char nt_signature[4];		/* Required NT signature, 0x4550.  */
244
 
244
 
245
  /* From standard header.  */
245
  /* From standard header.  */
Line 357... Line 357...
357
/* Weak external characteristics.  */
357
/* Weak external characteristics.  */
358
#define IMAGE_WEAK_EXTERN_SEARCH_NOLIBRARY	1
358
#define IMAGE_WEAK_EXTERN_SEARCH_NOLIBRARY	1
359
#define IMAGE_WEAK_EXTERN_SEARCH_LIBRARY	2
359
#define IMAGE_WEAK_EXTERN_SEARCH_LIBRARY	2
360
#define IMAGE_WEAK_EXTERN_SEARCH_ALIAS		3
360
#define IMAGE_WEAK_EXTERN_SEARCH_ALIAS		3
Line -... Line 361...
-
 
361
 
-
 
362
/* Bigobj header.  */
-
 
363
struct external_ANON_OBJECT_HEADER_BIGOBJ
-
 
364
{
-
 
365
  /* ANON_OBJECT_HEADER_V2 header.  */
-
 
366
  char Sig1[2];
-
 
367
  char Sig2[2];
-
 
368
  char Version[2];
-
 
369
  char Machine[2];
-
 
370
  char TimeDateStamp[4];
-
 
371
  char ClassID[16];
-
 
372
  char SizeOfData[4];
-
 
373
  char Flags[4];
-
 
374
  char MetaDataSize[4];
-
 
375
  char MetaDataOffset[4];
-
 
376
 
-
 
377
  /* BIGOBJ specific.  */
-
 
378
  char NumberOfSections[4];
-
 
379
  char PointerToSymbolTable[4];
-
 
380
  char NumberOfSymbols[4];
-
 
381
};
-
 
382
 
-
 
383
#define FILHSZ_BIGOBJ (14 * 4)
-
 
384
 
-
 
385
struct external_SYMBOL_EX
-
 
386
{
-
 
387
  union
-
 
388
  {
-
 
389
    char e_name[E_SYMNMLEN];
-
 
390
 
-
 
391
    struct
-
 
392
    {
-
 
393
      char e_zeroes[4];
-
 
394
      char e_offset[4];
-
 
395
    } e;
-
 
396
  } e;
-
 
397
 
-
 
398
  char e_value[4];
-
 
399
  char e_scnum[4];
-
 
400
  char e_type[2];
-
 
401
  char e_sclass[1];
-
 
402
  char e_numaux[1];
-
 
403
} ATTRIBUTE_PACKED ;
-
 
404
 
-
 
405
#define	SYMENT_BIGOBJ	struct external_SYMBOL_EX
-
 
406
#define	SYMESZ_BIGOBJ	20
-
 
407
 
-
 
408
#define FILNMLEN_BIGOBJ	20
-
 
409
 
-
 
410
union external_AUX_SYMBOL_EX
-
 
411
{
-
 
412
  struct
-
 
413
  {
-
 
414
    char WeakDefaultSymIndex[4];
-
 
415
    char WeakSearchType[4];
-
 
416
    char rgbReserved[12];
-
 
417
  } Sym;
-
 
418
 
-
 
419
  struct
-
 
420
  {
-
 
421
    char Name[FILNMLEN_BIGOBJ];
-
 
422
  } File;
-
 
423
 
-
 
424
  struct
-
 
425
  {
-
 
426
    char Length[4];		/* Section length.  */
-
 
427
    char NumberOfRelocations[2];/* # relocation entries.  */
-
 
428
    char NumberOfLinenumbers[2];/* # line numbers.  */
-
 
429
    char Checksum[4];		/* Section COMDAT checksum.  */
-
 
430
    char Number[2];	   	/* COMDAT associated section index.  */
-
 
431
    char Selection[1];		/* COMDAT selection number.  */
-
 
432
    char bReserved[1];
-
 
433
    char HighNumber[2];         /* High bits of COMDAT associated sec.  */
-
 
434
    char rgbReserved[2];
-
 
435
  } Section;
-
 
436
} ATTRIBUTE_PACKED;
-
 
437
 
-
 
438
#define	AUXENT_BIGOBJ	union external_AUX_SYMBOL_EX
-
 
439
#define	AUXESZ_BIGOBJ	20
361
 
440
 
Line 362... Line 441...
362
/* .pdata/.xdata defines and structures for x64 PE+ for exception handling.  */
441
/* .pdata/.xdata defines and structures for x64 PE+ for exception handling.  */
Line 363... Line 442...
363
 
442
 
364
/* .pdata in exception directory.  */
443
/* .pdata in exception directory.  */
365
 
444
 
366
struct pex64_runtime_function
445
struct pex64_runtime_function
367
{
446
{
368
  bfd_vma rva_BeginAddress;
-
 
369
  bfd_vma rva_EndAddress;
447
  bfd_vma rva_BeginAddress;
Line 370... Line 448...
370
  bfd_vma rva_UnwindData;
448
  bfd_vma rva_EndAddress;
371
  unsigned int isChained : 1;
449
  bfd_vma rva_UnwindData;
372
};
450
};
Line 391... Line 469...
391
#define UWOP_ALLOC_LARGE      1
469
#define UWOP_ALLOC_LARGE      1
392
#define UWOP_ALLOC_SMALL      2
470
#define UWOP_ALLOC_SMALL      2
393
#define UWOP_SET_FPREG	      3
471
#define UWOP_SET_FPREG	      3
394
#define UWOP_SAVE_NONVOL      4
472
#define UWOP_SAVE_NONVOL      4
395
#define UWOP_SAVE_NONVOL_FAR  5
473
#define UWOP_SAVE_NONVOL_FAR  5
396
#define UWOP_SAVE_XMM	      6
474
#define UWOP_SAVE_XMM         6 /* For version 1.  */
-
 
475
#define UWOP_EPILOG           6 /* For version 2.  */
397
#define UWOP_SAVE_XMM_FAR     7
476
#define UWOP_SAVE_XMM_FAR     7 /* For version 1 (deprecated).  */
-
 
477
#define UWOP_SPARE            7 /* For version 2.  */
398
#define UWOP_SAVE_XMM128      8
478
#define UWOP_SAVE_XMM128      8
399
#define UWOP_SAVE_XMM128_FAR  9
479
#define UWOP_SAVE_XMM128_FAR  9
400
#define UWOP_PUSH_MACHFRAME   10
480
#define UWOP_PUSH_MACHFRAME   10
Line 401... Line 481...
401
 
481
 
Line 439... Line 519...
439
  /* 0 = CFA, 1..15 are index of integer registers.  */
519
  /* 0 = CFA, 1..15 are index of integer registers.  */
440
  unsigned int FrameRegister : 4;
520
  unsigned int FrameRegister : 4;
441
  bfd_vma FrameOffset;
521
  bfd_vma FrameOffset;
442
  bfd_vma sizeofUnwindCodes;
522
  bfd_vma sizeofUnwindCodes;
443
  bfd_byte *rawUnwindCodes;
523
  bfd_byte *rawUnwindCodes;
444
  /* Valid for UNW_FLAG_EHANDLER and UNW_FLAG_UHANDLER.  */
-
 
445
  bfd_vma CountOfScopes;
-
 
446
  bfd_byte *rawScopeEntries;
-
 
447
  bfd_vma rva_ExceptionHandler; /* UNW_EHANDLER.  */
524
  bfd_vma rva_ExceptionHandler; /* UNW_EHANDLER or UNW_FLAG_UHANDLER.  */
448
  bfd_vma rva_TerminationHandler; /* UNW_FLAG_UHANDLER.  */
525
  bfd_vma rva_BeginAddress;	/* UNW_FLAG_CHAININFO.  */
449
  bfd_vma rva_FrameHandler; /* UNW_FLAG_FHANDLER.  */
526
  bfd_vma rva_EndAddress;	/* UNW_FLAG_CHAININFO.  */
450
  bfd_vma FrameHandlerArgument; /* UNW_FLAG_FHANDLER.  */
-
 
451
  bfd_vma rva_FunctionEntry; /* UNW_FLAG_CHAININFO.  */
527
  bfd_vma rva_UnwindData;	/* UNW_FLAG_CHAININFO.  */
452
};
528
};
Line 453... Line 529...
453
 
529
 
454
struct external_pex64_unwind_info
530
struct external_pex64_unwind_info
455
{
531
{
Line 507... Line 583...
507
 
583
 
508
#define PEX64_SCOPE_ENTRY(COUNTOFUNWINDCODES, IDX) \
584
#define PEX64_SCOPE_ENTRY(COUNTOFUNWINDCODES, IDX) \
509
  (PEX64_OFFSET_TO_SCOPE_COUNT(COUNTOFUNWINDCODES) + \
585
  (PEX64_OFFSET_TO_SCOPE_COUNT(COUNTOFUNWINDCODES) + \
Line -... Line 586...
-
 
586
   PEX64_SCOPE_ENTRY_SIZE * (IDX))
-
 
587
 
-
 
588
/* Extra structure used in debug directory.  */
-
 
589
struct external_IMAGE_DEBUG_DIRECTORY
-
 
590
{
-
 
591
  char Characteristics[4];
-
 
592
  char TimeDateStamp[4];
-
 
593
  char MajorVersion[2];
-
 
594
  char MinorVersion[2];
-
 
595
  char Type[4];
-
 
596
  char SizeOfData[4];
-
 
597
  char AddressOfRawData[4];
-
 
598
  char PointerToRawData[4];
-
 
599
};
-
 
600
 
-
 
601
/* Extra structures used in codeview debug record.  */
-
 
602
/* This is not part of the PE specification.  */
-
 
603
 
-
 
604
#define CVINFO_PDB70_CVSIGNATURE 0x53445352 // "RSDS"
-
 
605
#define CVINFO_PDB20_CVSIGNATURE 0x3031424e // "NB10"
-
 
606
#define CVINFO_CV50_CVSIGNATURE  0x3131424e // "NB11"
-
 
607
#define CVINFO_CV41_CVSIGNATURE  0x3930424e // âNB09"
-
 
608
 
-
 
609
typedef struct _CV_INFO_PDB70
-
 
610
{
-
 
611
  char CvSignature[4];
-
 
612
  char Signature[16];
-
 
613
  char Age[4];
-
 
614
  char PdbFileName[];
-
 
615
} CV_INFO_PDB70;
-
 
616
 
-
 
617
typedef struct _CV_INFO_PDB20
-
 
618
{
-
 
619
  char CvHeader[4];
-
 
620
  char Offset[4];
-
 
621
  char Signature[4];
-
 
622
  char Age[4];
-
 
623
  char PdbFileName[];
510
   PEX64_SCOPE_ENTRY_SIZE * (IDX))
624
} CV_INFO_PDB20;