]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blobdiff - include/coff/pe.h
Update year range in copyright notice of binutils files
[thirdparty/binutils-gdb.git] / include / coff / pe.h
index 3166531097f76b8278497e408833e3bcde501e9b..a157812ef7f1be882b68417eda2c0ae6da49a98e 100644 (file)
@@ -1,6 +1,6 @@
-/* pe.h  -  PE COFF header information 
+/* pe.h  -  PE COFF header information
 
-   Copyright (C) 1999-2014 Free Software Foundation, Inc.
+   Copyright (C) 1999-2021 Free Software Foundation, Inc.
 
    This file is part of BFD, the Binary File Descriptor library.
 
@@ -20,6 +20,8 @@
 #ifndef _PE_H
 #define _PE_H
 
+#include "msdos.h"
+
 /* NT specific file attributes.  */
 #define IMAGE_FILE_RELOCS_STRIPPED           0x0001
 #define IMAGE_FILE_EXECUTABLE_IMAGE          0x0002
@@ -40,6 +42,7 @@
 
 /* DllCharacteristics flag bits.  The inconsistent naming may seem
    odd, but that is how they are defined in the PE specification.  */
+#define IMAGE_DLL_CHARACTERISTICS_HIGH_ENTROPY_VA       0x0020
 #define IMAGE_DLL_CHARACTERISTICS_DYNAMIC_BASE          0x0040
 #define IMAGE_DLL_CHARACTERISTICS_FORCE_INTEGRITY       0x0080
 #define IMAGE_DLL_CHARACTERISTICS_NX_COMPAT             0x0100
 
 /* Section characteristics added for ppc-nt.  */
 
-#define IMAGE_SCN_TYPE_NO_PAD                0x00000008  /* Reserved. */
+#define IMAGE_SCN_TYPE_NO_PAD                0x00000008  /* Reserved.  */
 
-#define IMAGE_SCN_CNT_CODE                   0x00000020  /* Section contains code. */
-#define IMAGE_SCN_CNT_INITIALIZED_DATA       0x00000040  /* Section contains initialized data. */
-#define IMAGE_SCN_CNT_UNINITIALIZED_DATA     0x00000080  /* Section contains uninitialized data. */
+#define IMAGE_SCN_CNT_CODE                   0x00000020  /* Section contains code.  */
+#define IMAGE_SCN_CNT_INITIALIZED_DATA       0x00000040  /* Section contains initialized data.  */
+#define IMAGE_SCN_CNT_UNINITIALIZED_DATA     0x00000080  /* Section contains uninitialized data.  */
 
-#define IMAGE_SCN_LNK_OTHER                  0x00000100  /* Reserved. */
-#define IMAGE_SCN_LNK_INFO                   0x00000200  /* Section contains comments or some other type of information. */
-#define IMAGE_SCN_LNK_REMOVE                 0x00000800  /* Section contents will not become part of image. */
-#define IMAGE_SCN_LNK_COMDAT                 0x00001000  /* Section contents comdat. */
+#define IMAGE_SCN_LNK_OTHER                  0x00000100  /* Reserved.  */
+#define IMAGE_SCN_LNK_INFO                   0x00000200  /* Section contains comments or some other type of information.  */
+#define IMAGE_SCN_LNK_REMOVE                 0x00000800  /* Section contents will not become part of image.  */
+#define IMAGE_SCN_LNK_COMDAT                 0x00001000  /* Section contents comdat.  */
 
 #define IMAGE_SCN_MEM_FARDATA                0x00008000
 
@@ -77,7 +80,7 @@
 #define IMAGE_SCN_MEM_LOCKED                 0x00040000
 #define IMAGE_SCN_MEM_PRELOAD                0x00080000
 
-/* Bit position in the s_flags field where the alignment values start. */
+/* Bit position in the s_flags field where the alignment values start.  */
 #define IMAGE_SCN_ALIGN_POWER_BIT_POS       20
 #define IMAGE_SCN_ALIGN_POWER_BIT_MASK      0x00f00000
 #define IMAGE_SCN_ALIGN_POWER_NUM(val)      \
@@ -89,7 +92,7 @@
 #define IMAGE_SCN_ALIGN_2BYTES              IMAGE_SCN_ALIGN_POWER_CONST (1)
 #define IMAGE_SCN_ALIGN_4BYTES              IMAGE_SCN_ALIGN_POWER_CONST (2)
 #define IMAGE_SCN_ALIGN_8BYTES              IMAGE_SCN_ALIGN_POWER_CONST (3)
-/* Default alignment if no others are specified. */
+/* Default alignment if no others are specified.  */
 #define IMAGE_SCN_ALIGN_16BYTES                     IMAGE_SCN_ALIGN_POWER_CONST (4)
 #define IMAGE_SCN_ALIGN_32BYTES                     IMAGE_SCN_ALIGN_POWER_CONST (5)
 #define IMAGE_SCN_ALIGN_64BYTES                     IMAGE_SCN_ALIGN_POWER_CONST (6)
 #define IMAGE_SCN_ALIGN_4096BYTES           IMAGE_SCN_ALIGN_POWER_CONST (12)
 #define IMAGE_SCN_ALIGN_8192BYTES           IMAGE_SCN_ALIGN_POWER_CONST (13)
 
-/* Encode alignment power into IMAGE_SCN_ALIGN bits of s_flags */
+/* Encode alignment power into IMAGE_SCN_ALIGN bits of s_flags */
 #define COFF_ENCODE_ALIGNMENT(SECTION, ALIGNMENT_POWER) \
-  ((SECTION).s_flags |= IMAGE_SCN_ALIGN_POWER_CONST ((ALIGNMENT_POWER)))
+  ((SECTION).s_flags |= IMAGE_SCN_ALIGN_POWER_CONST ((ALIGNMENT_POWER) <= 13 \
+                                                    ? (ALIGNMENT_POWER) : 13))
+#define COFF_DECODE_ALIGNMENT(X)             \
+  IMAGE_SCN_ALIGN_POWER_NUM ((X) & IMAGE_SCN_ALIGN_POWER_BIT_MASK)
 
 #define IMAGE_SCN_LNK_NRELOC_OVFL            0x01000000  /* Section contains extended relocations. */
 #define IMAGE_SCN_MEM_NOT_CACHED             0x04000000  /* Section is not cachable.               */
 #define IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER     12
 #define IMAGE_SUBSYSTEM_SAL_RUNTIME_DRIVER     13
 #define IMAGE_SUBSYSTEM_XBOX                   14
-  
-/* Magic values that are true for all dos/nt implementations.  */
-#define DOSMAGIC       0x5a4d  
-#define NT_SIGNATURE   0x00004550
 
 /* NT allows long filenames, we want to accommodate this.
    This may break some of the bfd functions.  */
 #undef  FILNMLEN
 #define FILNMLEN       18      /* # characters in a file name.  */
 
-struct external_PEI_DOS_hdr
-{
-  /* DOS header fields - always at offset zero in the EXE file.  */
-  char e_magic[2];             /* Magic number, 0x5a4d.  */
-  char e_cblp[2];              /* Bytes on last page of file, 0x90.  */
-  char e_cp[2];                        /* Pages in file, 0x3.  */
-  char e_crlc[2];              /* Relocations, 0x0.  */
-  char e_cparhdr[2];           /* Size of header in paragraphs, 0x4.  */
-  char e_minalloc[2];          /* Minimum extra paragraphs needed, 0x0.  */
-  char e_maxalloc[2];          /* Maximum extra paragraphs needed, 0xFFFF.  */
-  char e_ss[2];                        /* Initial (relative) SS value, 0x0.  */
-  char e_sp[2];                        /* Initial SP value, 0xb8.  */
-  char e_csum[2];              /* Checksum, 0x0.  */
-  char e_ip[2];                        /* Initial IP value, 0x0.  */
-  char e_cs[2];                        /* Initial (relative) CS value, 0x0.  */
-  char e_lfarlc[2];            /* File address of relocation table, 0x40.  */
-  char e_ovno[2];              /* Overlay number, 0x0.  */
-  char e_res[4][2];            /* Reserved words, all 0x0.  */
-  char e_oemid[2];             /* OEM identifier (for e_oeminfo), 0x0.  */
-  char e_oeminfo[2];           /* OEM information; e_oemid specific, 0x0.  */
-  char e_res2[10][2];          /* Reserved words, all 0x0.  */
-  char e_lfanew[4];            /* File address of new exe header, usually 0x80.  */
-  char dos_message[16][4];     /* Other stuff, always follow DOS header.  */
-};
-
 struct external_PEI_IMAGE_hdr
 {
-  char nt_signature[4];                /* required NT signature, 0x4550.  */
+  char nt_signature[4];                /* Required NT signature, 0x4550.  */
 
   /* From standard header.  */
   char f_magic[2];             /* Magic number.                */
@@ -239,7 +216,7 @@ struct external_PEI_filehdr
   /* Note: additional bytes may be inserted before the signature.  Use
    the e_lfanew field to find the actual location of the NT signature.  */
 
-  char nt_signature[4];                /* required NT signature, 0x4550.  */
+  char nt_signature[4];                /* Required NT signature, 0x4550.  */
 
   /* From standard header.  */
   char f_magic[2];             /* Magic number.                */
@@ -262,9 +239,9 @@ struct external_PEI_filehdr
 
 #endif /* COFF_IMAGE_WITH_PE */
 
-/* 32-bit PE a.out header: */
+/* 32-bit PE a.out header:  */
 
-typedef struct 
+typedef struct
 {
   AOUTHDR standard;
 
@@ -300,7 +277,7 @@ typedef struct
 /* Like PEAOUTHDR, except that the "standard" member has no BaseOfData
    (aka data_start) member and that some of the members are 8 instead
    of just 4 bytes long.  */
-typedef struct 
+typedef struct
 {
 #ifdef AOUTHDRSZ64
   AOUTHDR64 standard;
@@ -338,7 +315,7 @@ typedef struct
 #else
 #define PEPAOUTSZ      240
 #endif
-  
+
 #undef  E_FILNMLEN
 #define E_FILNMLEN     18      /* # characters in a file name.  */
 
@@ -422,14 +399,14 @@ union external_AUX_SYMBOL_EX
 
   struct
   {
-    char Length[4];    /* section length */
-    char NumberOfRelocations[2];       /* # relocation entries */
-    char NumberOfLinenumbers[2];       /* # line numbers */
-    char Checksum[4];             /* section COMDAT checksum         */
-    char Number[2];       /* COMDAT associated section index */
-    char Selection[1];            /* COMDAT selection number         */
+    char Length[4];            /* Section length.  */
+    char NumberOfRelocations[2];/* # relocation entries.  */
+    char NumberOfLinenumbers[2];/* # line numbers.  */
+    char Checksum[4];          /* Section COMDAT checksum.  */
+    char Number[2];            /* COMDAT associated section index.  */
+    char Selection[1];         /* COMDAT selection number.  */
     char bReserved[1];
-    char HighNumber[2];           /* High bits of COMDAT associated sec.  */
+    char HighNumber[2];         /* High bits of COMDAT associated sec.  */
     char rgbReserved[2];
   } Section;
 } ATTRIBUTE_PACKED;
@@ -520,6 +497,7 @@ struct pex64_unwind_info
   bfd_vma FrameOffset;
   bfd_vma sizeofUnwindCodes;
   bfd_byte *rawUnwindCodes;
+  bfd_byte *rawUnwindCodesEnd;
   bfd_vma rva_ExceptionHandler; /* UNW_EHANDLER or UNW_FLAG_UHANDLER.  */
   bfd_vma rva_BeginAddress;    /* UNW_FLAG_CHAININFO.  */
   bfd_vma rva_EndAddress;      /* UNW_FLAG_CHAININFO.  */
@@ -584,4 +562,42 @@ struct external_pex64_scope_entry
   (PEX64_OFFSET_TO_SCOPE_COUNT(COUNTOFUNWINDCODES) + \
    PEX64_SCOPE_ENTRY_SIZE * (IDX))
 
+/* Extra structure used in debug directory.  */
+struct external_IMAGE_DEBUG_DIRECTORY
+{
+  char Characteristics[4];
+  char TimeDateStamp[4];
+  char MajorVersion[2];
+  char MinorVersion[2];
+  char Type[4];
+  char SizeOfData[4];
+  char AddressOfRawData[4];
+  char PointerToRawData[4];
+};
+
+/* Extra structures used in codeview debug record.  */
+/* This is not part of the PE specification.  */
+
+#define CVINFO_PDB70_CVSIGNATURE 0x53445352 /* "RSDS" */
+#define CVINFO_PDB20_CVSIGNATURE 0x3031424e /* "NB10" */
+#define CVINFO_CV50_CVSIGNATURE  0x3131424e /* "NB11" */
+#define CVINFO_CV41_CVSIGNATURE  0x3930424e /* "NB09" */
+
+typedef struct _CV_INFO_PDB70
+{
+  char CvSignature[4];
+  char Signature[16];
+  char Age[4];
+  char PdbFileName[];
+} CV_INFO_PDB70;
+
+typedef struct _CV_INFO_PDB20
+{
+  char CvHeader[4];
+  char Offset[4];
+  char Signature[4];
+  char Age[4];
+  char PdbFileName[];
+} CV_INFO_PDB20;
+
 #endif /* _PE_H */