Note new "AT>" feature.
[deliverable/binutils-gdb.git] / include / coff / internal.h
index b01d3052cd2766a51660eef588c29c809b022a7b..e89b52875573c9a4c5e87709d35df3d7716eddd8 100644 (file)
@@ -1,6 +1,9 @@
 /* Internal format of COFF object file data structures, for GNU BFD.
    This file is part of BFD, the Binary File Descriptor library.  */
 
+#ifndef GNU_COFF_INTERNAL_H
+#define GNU_COFF_INTERNAL_H 1
+
 /* First, make "signed char" work, even on old compilers. */
 #ifndef signed
 #ifndef __STDC__
 
 /********************** FILE HEADER **********************/
 
-struct internal_filehdr
+/* extra stuff in a PE header. */
+
+struct internal_extra_pe_filehdr
 {
   /* DOS header data follows for PE stuff */
-  unsigned short e_magic;      /* Magic number, 0x5a4d */
-  unsigned short e_cblp;       /* Bytes on last page of file, 0x90 */
-  unsigned short e_cp;         /* Pages in file, 0x3 */
-  unsigned short e_crlc;       /* Relocations, 0x0 */
-  unsigned short e_cparhdr;    /* Size of header in paragraphs, 0x4 */
-  unsigned short e_minalloc;   /* Minimum extra paragraphs needed, 0x0 */
-  unsigned short e_maxalloc;   /* Maximum extra paragraphs needed, 0xFFFF */
-  unsigned short e_ss;         /* Initial (relative) SS value, 0x0 */
-  unsigned short e_sp;         /* Initial SP value, 0xb8 */
-  unsigned short e_csum;       /* Checksum, 0x0 */
-  unsigned short e_ip;         /* Initial IP value, 0x0 */
-  unsigned short e_cs;         /* Initial (relative) CS value, 0x0 */
-  unsigned short e_lfarlc;     /* File address of relocation table, 0x40 */
-  unsigned short e_ovno;       /* Overlay number, 0x0 */
-  unsigned short e_res[4];     /* Reserved words, all 0x0 */
-  unsigned short e_oemid;      /* OEM identifier (for e_oeminfo), 0x0 */
-  unsigned short e_oeminfo;    /* OEM information; e_oemid specific, 0x0 */
-  unsigned short e_res2[10];   /* Reserved words, all 0x0 */
-  bfd_vma  e_lfanew;           /* File address of new exe header, 0x80 */
+  unsigned short e_magic;      /* Magic number, 0x5a4d */
+  unsigned short e_cblp;       /* Bytes on last page of file, 0x90 */
+  unsigned short e_cp;         /* Pages in file, 0x3 */
+  unsigned short e_crlc;       /* Relocations, 0x0 */
+  unsigned short e_cparhdr;    /* Size of header in paragraphs, 0x4 */
+  unsigned short e_minalloc;   /* Minimum extra paragraphs needed, 0x0 */
+  unsigned short e_maxalloc;   /* Maximum extra paragraphs needed, 0xFFFF */
+  unsigned short e_ss;         /* Initial (relative) SS value, 0x0 */
+  unsigned short e_sp;         /* Initial SP value, 0xb8 */
+  unsigned short e_csum;       /* Checksum, 0x0 */
+  unsigned short e_ip;         /* Initial IP value, 0x0 */
+  unsigned short e_cs;         /* Initial (relative) CS value, 0x0 */
+  unsigned short e_lfarlc;     /* File address of relocation table, 0x40 */
+  unsigned short e_ovno;       /* Overlay number, 0x0 */
+  unsigned short e_res[4];     /* Reserved words, all 0x0 */
+  unsigned short e_oemid;      /* OEM identifier (for e_oeminfo), 0x0 */
+  unsigned short e_oeminfo;    /* OEM information; e_oemid specific, 0x0 */
+  unsigned short e_res2[10];   /* Reserved words, all 0x0 */
+  bfd_vma  e_lfanew;           /* File address of new exe header, 0x80 */
   unsigned long dos_message[16]; /* text which always follows dos header */
   bfd_vma  nt_signature;       /* required NT signature, 0x4550 */ 
+};
 
+struct internal_filehdr
+{
+  struct internal_extra_pe_filehdr pe;
 
   /* standard coff  internal info */
   unsigned short f_magic;      /* magic number                 */
@@ -44,6 +53,7 @@ struct internal_filehdr
   long f_nsyms;                        /* number of symtab entries     */
   unsigned short f_opthdr;     /* sizeof(optional hdr)         */
   unsigned short f_flags;      /* flags                        */
+  unsigned short f_target_id;  /* (TIc80 specific)             */
 };
 
 
@@ -57,6 +67,7 @@ struct internal_filehdr
  *     F_AR32W         file is 32-bit big-endian
  *     F_DYNLOAD       rs/6000 aix: dynamically loadable w/imports & exports
  *     F_SHROBJ        rs/6000 aix: file is a shared object
+ *      F_DLL           PE format DLL
  */
 
 #define        F_RELFLG        (0x0001)
@@ -68,6 +79,7 @@ struct internal_filehdr
 #define        F_AR32W         (0x0200)
 #define        F_DYNLOAD       (0x1000)
 #define        F_SHROBJ        (0x2000)
+#define F_DLL           (0x2000)
 
 /* extra structure which is used in the optional header */
 typedef struct _IMAGE_DATA_DIRECTORY 
@@ -77,9 +89,56 @@ typedef struct _IMAGE_DATA_DIRECTORY
 }  IMAGE_DATA_DIRECTORY;
 #define IMAGE_NUMBEROF_DIRECTORY_ENTRIES  16
 
-/* default image base for NT */
-#define NT_IMAGE_BASE 0x400000
+/* Default image base for NT.  */
+#define NT_EXE_IMAGE_BASE 0x400000
+#define NT_DLL_IMAGE_BASE 0x10000000
 
+/* Default image base for BeOS. */
+#define BEOS_EXE_IMAGE_BASE 0x80000000
+#define BEOS_DLL_IMAGE_BASE 0x10000000
+
+/* Extra stuff in a PE aouthdr */
+
+#define PE_DEF_SECTION_ALIGNMENT 0x1000
+#define PE_DEF_FILE_ALIGNMENT 0x200
+
+struct internal_extra_pe_aouthdr 
+{
+  /* PE stuff  */
+  bfd_vma ImageBase;           /* address of specific location in memory that
+                                  file is located, NT default 0x10000 */
+
+  bfd_vma SectionAlignment;    /* section alignment default 0x1000 */
+  bfd_vma FileAlignment;       /* file alignment default 0x200 */
+  short   MajorOperatingSystemVersion; /* minimum version of the operating */
+  short   MinorOperatingSystemVersion; /* system req'd for exe, default to 1*/
+  short   MajorImageVersion;   /* user defineable field to store version of */
+  short   MinorImageVersion;   /* exe or dll being created, default to 0 */ 
+  short   MajorSubsystemVersion; /* minimum subsystem version required to */
+  short   MinorSubsystemVersion; /* run exe; default to 3.1 */
+  long    Reserved1;           /* seems to be 0 */
+  long    SizeOfImage;         /* size of memory to allocate for prog */
+  long    SizeOfHeaders;       /* size of PE header and section table */
+  long    CheckSum;            /* set to 0 */
+  short   Subsystem;   
+
+  /* type of subsystem exe uses for user interface,
+     possible values:
+     1 - NATIVE   Doesn't require a subsystem
+     2 - WINDOWS_GUI runs in Windows GUI subsystem
+     3 - WINDOWS_CUI runs in Windows char sub. (console app)
+     5 - OS2_CUI runs in OS/2 character subsystem
+     7 - POSIX_CUI runs in Posix character subsystem */
+  short   DllCharacteristics;  /* flags for DLL init, use 0 */
+  bfd_vma SizeOfStackReserve;  /* amount of memory to reserve  */
+  bfd_vma SizeOfStackCommit;   /* amount of memory initially committed for 
+                                  initial thread's stack, default is 0x1000 */
+  bfd_vma SizeOfHeapReserve;   /* amount of virtual memory to reserve and */
+  bfd_vma SizeOfHeapCommit;    /* commit, don't know what to defaut it to */
+  long    LoaderFlags;         /* can probably set to 0 */
+  long    NumberOfRvaAndSizes; /* number of entries in next entry, 16 */
+  IMAGE_DATA_DIRECTORY DataDirectory[IMAGE_NUMBEROF_DIRECTORY_ENTRIES];
+};
 
 /********************** AOUT "OPTIONAL HEADER" **********************/
 struct internal_aouthdr
@@ -107,7 +166,9 @@ struct internal_aouthdr
   short o_algntext;            /* max alignment for text       */
   short o_algndata;            /* max alignment for data       */
   short o_modtype;             /* Module type field, 1R,RE,RO  */
+  short o_cputype;             /* Encoded CPU type             */
   unsigned long o_maxstack;    /* max stack size allowed.      */
+  unsigned long o_maxdata;     /* max data size allowed.       */
 
   /* ECOFF stuff */
   bfd_vma bss_start;           /* Base of bss section.         */
@@ -122,42 +183,10 @@ struct internal_aouthdr
   long vid[2];                 /* Version id */
 
 
-  /* PE stuff  */
-  bfd_vma ImageBase;          /* address of specific location in memory that
-                                 file is located, NT default 0x10000 */
-  bfd_vma SectionAlignment;   /* section alignment default 0x1000 */
-  bfd_vma FileAlignment;      /* file alignment default 0x200 */
-  short   MajorOperatingSystemVersion;  /* minimum version of the operating */
-  short   MinorOperatingSystemVersion;  /* system req'd for exe, default to 1*/
-  short   MajorImageVersion;  /* user defineable field to store version of */
-  short   MinorImageVersion;  /* exe or dll being created, default to 0 */ 
-  short   MajorSubsystemVersion; /* minimum subsystem version required to */
-  short   MinorSubsystemVersion; /* run exe; default to 3.1 */
-  long    Reserved1;  /* seems to be 0 */
-  long    SizeOfImage; /* size of region from image base to end last section */
-  long    SizeOfHeaders; /* size of PE header and section table */
-  long    CheckSum;  /* set to 0 */
-  short   Subsystem; /* type of subsystem exe uses for user interface,
-                        possible values:
-                        1 - NATIVE   Doesn't require a subsystem
-                        2 - WINDOWS_GUI runs in Windows GUI subsystem
-                        3 - WINDOWS_CUI runs in Windows char sub. (console app)
-                        5 - OS2_CUI runs in OS/2 character subsystem
-                        7 - POSIX_CUI runs in Posix character subsystem */
-  short   DllCharacteristics; /* flags for DLL init, use 0 */
-  bfd_vma SizeOfStackReserve; /* amount of memory to reserve, def. 0x100000 */
-  bfd_vma SizeOfStackCommit; /* amount of memory initially committed for 
-                                initial thread's stack, default is 0x1000 */
-  bfd_vma SizeOfHeapReserve; /* amount of virtual memory to reserve and */
-  bfd_vma SizeOfHeapCommit;  /* commit, don't know what to defaut it to */
-  long    LoaderFlags; /* can probably set to 0 */
-  long    NumberOfRvaAndSizes; /* number of entries in next entry, 16 */
-  IMAGE_DATA_DIRECTORY DataDirectory[IMAGE_NUMBEROF_DIRECTORY_ENTRIES];
-
+  struct internal_extra_pe_aouthdr pe;
 
 };
 
-
 /********************** STORAGE CLASSES **********************/
 
 /* This used to be defined as -1, but now n_sclass is unsigned.  */
@@ -191,8 +220,17 @@ struct internal_aouthdr
 #define C_ALIAS                105     /* duplicate tag                */
 #define C_HIDDEN       106     /* ext symbol in dmert public lib */
 
+#define C_WEAKEXT      127     /* weak symbol -- GNU extension */
+
+/* New storage classes for TIc80 */
+#define C_UEXT         19      /* Tentative external definition */
+#define C_STATLAB      20      /* Static load time label */
+#define C_EXTLAB       21      /* External load time label */
+#define C_SYSTEM       23      /* System Wide variable */
+
 /* New storage classes for WINDOWS_NT   */
 #define C_SECTION       104     /* section name */
+#define C_NT_WEAK      105     /* weak external */
 
  /* New storage classes for 80960 */
 
@@ -233,11 +271,27 @@ struct internal_aouthdr
 #define C_BSTAT         (0x8f)
 #define C_ESTAT         (0x90)
 
+/* Storage classes for Thumb symbols */
+#define C_THUMBEXT      (128 + C_EXT)          /* 130 */
+#define C_THUMBSTAT     (128 + C_STAT)         /* 131 */
+#define C_THUMBLABEL    (128 + C_LABEL)                /* 134 */
+#define C_THUMBEXTFUNC  (C_THUMBEXT  + 20)     /* 150 */
+#define C_THUMBSTATFUNC (C_THUMBSTAT + 20)     /* 151 */
+
 /********************** SECTION HEADER **********************/
+
+#define SCNNMLEN (8)
+
 struct internal_scnhdr
 {
-  char s_name[8];              /* section name                 */
-  bfd_vma s_paddr;             /* physical address, aliased s_nlib */
+  char s_name[SCNNMLEN];       /* section name                 */
+
+  /* Physical address, aliased s_nlib.
+     In the pei format, this field is the virtual section size
+     (the size of the section after being loaded int memory),
+     NOT the physical address.  */
+  bfd_vma s_paddr;
+
   bfd_vma s_vaddr;             /* virtual address              */
   bfd_vma s_size;              /* section size                 */
   bfd_vma s_scnptr;            /* file ptr to raw data for section */
@@ -319,8 +373,8 @@ struct internal_syment
   short n_scnum;               /* section number               */
   unsigned short n_flags;      /* copy of flags from filhdr    */
   unsigned short n_type;       /* type and derived type        */
-  unsigned char n_sclass;              /* storage class                */
-  char n_numaux;               /* number of aux. entries       */
+  unsigned char n_sclass;      /* storage class                */
+  unsigned char n_numaux;      /* number of aux. entries       */
 };
 
 #define n_name         _n._n_name
@@ -367,13 +421,18 @@ struct internal_syment
 #define DT_ARY         (3)     /* array */
 
 #define BTYPE(x)       ((x) & N_BTMASK)
-
-#define ISPTR(x)       (((x) & N_TMASK) == (DT_PTR << N_BTSHFT))
-#define ISFCN(x)       (((x) & N_TMASK) == (DT_FCN << N_BTSHFT))
-#define ISARY(x)       (((x) & N_TMASK) == (DT_ARY << N_BTSHFT))
-#define ISTAG(x)       ((x)==C_STRTAG||(x)==C_UNTAG||(x)==C_ENTAG)
-#define DECREF(x) ((((x)>>N_TSHIFT)&~N_BTMASK)|((x)&N_BTMASK))
-
+#define DTYPE(x)       (((x) & N_TMASK) >> N_BTSHFT)
+
+#define ISPTR(x) \
+  (((unsigned long) (x) & N_TMASK) == ((unsigned long) DT_PTR << N_BTSHFT))
+#define ISFCN(x) \
+  (((unsigned long) (x) & N_TMASK) == ((unsigned long) DT_FCN << N_BTSHFT))
+#define ISARY(x) \
+  (((unsigned long) (x) & N_TMASK) == ((unsigned long) DT_ARY << N_BTSHFT))
+#define ISTAG(x) \
+  ((x) == C_STRTAG || (x) == C_UNTAG || (x) == C_ENTAG)
+#define DECREF(x) \
+  ((((x) >> N_TSHIFT) & ~ N_BTMASK) | ((x) & N_BTMASK))
 
 union internal_auxent
 {
@@ -432,6 +491,9 @@ union internal_auxent
     long x_scnlen;             /* section length */
     unsigned short x_nreloc;   /* # relocation entries */
     unsigned short x_nlinno;   /* # line numbers */
+    unsigned long x_checksum;  /* section COMDAT checksum for PE */
+    unsigned short x_associated; /* COMDAT associated section index for PE */
+    unsigned char x_comdat;    /* COMDAT selection number for PE */
   }      x_scn;
 
   struct
@@ -482,7 +544,7 @@ union internal_auxent
 #define        XMC_UA  4               /* Read-write unclassified */
 #define        XMC_RW  5               /* Read-write data */
 #define        XMC_GL  6               /* Read-only global linkage */
-#define        XMC_XO  7               /* Read-only extended operation (simulated insn) */
+#define        XMC_XO  7               /* Read-only extended operation */
 #define        XMC_SV  8               /* Read-only supervisor call */
 #define        XMC_BS  9               /* Read-write BSS */
 #define        XMC_DS  10              /* Read-write descriptor csect */
@@ -490,8 +552,8 @@ union internal_auxent
 #define        XMC_TI  12              /* Read-only traceback index csect */
 #define        XMC_TB  13              /* Read-only traceback table csect */
 /*             14      ??? */
-#define        XMC_TC0 15              /* Read-write TOC anchor for TOC addressability */
-
+#define        XMC_TC0 15              /* Read-write TOC anchor */
+#define XMC_TD 16              /* Read-write data in TOC */
 
   /******************************************
    *  I960-specific *2nd* aux. entry formats
@@ -528,49 +590,97 @@ struct internal_reloc
   unsigned long r_offset;      /* Used by Alpha ECOFF, SPARC, others */
 };
 
-#define R_RELBYTE      017
-#define R_RELWORD      020
-#define R_PCRBYTE      022
-#define R_PCRWORD      023
-#define R_PCRLONG      024
-
-#define        R_DIR16         01
-#define R_DIR32                06
-#define        R_PCLONG        020
-#define R_RELBYTE      017
-#define R_RELWORD      020
-
-
-
-#define R_PCR16L 128
-#define R_PCR26L 129
-#define R_VRT16  130
-#define R_HVRT16 131
-#define R_LVRT16 132
-#define R_VRT32  133
-#define R_RELLONG      (0x11)  /* Direct 32-bit relocation */
-#define R_IPRSHORT     (0x18)
-#define R_IPRMED       (0x19)  /* 24-bit ip-relative relocation */
-#define R_IPRLONG      (0x1a)
-#define R_OPTCALL      (0x1b)  /* 32-bit optimizable call (leafproc/sysproc) */
-#define R_OPTCALLX     (0x1c)  /* 64-bit optimizable call (leafproc/sysproc) */
-#define R_GETSEG       (0x1d)
-#define R_GETPA                (0x1e)
-#define R_TAGWORD      (0x1f)
-#define R_JUMPTARG     0x20    /* strange 29k 00xx00xx reloc */
-
-
-#define R_MOVB1        0x41    /* Special h8 16bit or 8 bit reloc for mov.b    */
-#define R_MOVB2        0x42    /* Special h8 opcode for 8bit which could be 16 */
-#define R_JMP1         0x43    /* Special h8 16bit jmp which could be pcrel    */
-#define R_JMP2                 0x44    /* a branch which used to be a jmp              */
+#define R_DIR16         1
+#define R_DIR32         6
+#define R_IMAGEBASE     7
+#define R_RELBYTE      15
+#define R_RELWORD      16
+#define R_RELLONG      17
+#define R_PCRBYTE      18
+#define R_PCRWORD      19
+#define R_PCRLONG      20
+#define R_IPRSHORT     24
+#define R_IPRLONG      26
+#define R_GETSEG       29
+#define R_GETPA        30
+#define R_TAGWORD      31
+#define R_JUMPTARG     32      /* strange 29k 00xx00xx reloc */
+
+#define R_PCR16L       128
+#define R_PCR26L       129
+#define R_VRT16        130
+#define R_HVRT16       131
+#define R_LVRT16       132
+#define R_VRT32        133
+
+
+/* This reloc identifies mov.b instructions with a 16bit absolute
+   address.  The linker tries to turn insns with this reloc into
+   an absolute 8-bit address.  */
+#define R_MOV16B1      0x41
+
+/* This reloc identifies mov.b instructions which had a 16bit
+   absolute address which have been shortened into a 8-bit
+   absolute address.  */
+#define R_MOV16B2      0x42
+
+/* This reloc identifies jmp insns with a 16bit target address;
+   the linker tries to turn these insns into bra insns with
+   an 8bit pc-relative target.  */
+#define R_JMP1         0x43
+
+/* This reloc identifies a bra with an 8-bit pc-relative
+   target that was formerlly a jmp insn with a 16bit target.  */
+#define R_JMP2                 0x44
+
+/* ??? */
 #define R_RELLONG_NEG          0x45
 
-#define R_JMPL1        0x46    /* Special h8 24bit jmp which could be pcrel    */
-#define R_JMPL_B8      0x47    /* a 8 bit pcrel which used to be a jmp  */
+/* This reloc identifies jmp insns with a 24bit target address;
+   the linker tries to turn these insns into bra insns with
+   an 8bit pc-relative target.  */
+#define R_JMPL1        0x46
+
+/* This reloc identifies a bra with an 8-bit pc-relative
+   target that was formerlly a jmp insn with a 24bit target.  */
+#define R_JMPL2                0x47
+
+/* This reloc identifies mov.b instructions with a 24bit absolute
+   address.  The linker tries to turn insns with this reloc into
+   an absolute 8-bit address.  */
 
-#define R_MOVLB1       0x48    /* Special h8 24bit or 8 bit reloc for mov.b    */
-#define R_MOVLB2       0x49    /* Special h8 opcode for 8bit which could be 24 */
+#define R_MOV24B1      0x48
+
+/* This reloc identifies mov.b instructions which had a 24bit
+   absolute address which have been shortened into a 8-bit
+   absolute address.  */
+#define R_MOV24B2      0x49
+
+/* An h8300 memory indirect jump/call.  Forces the address of the jump/call
+   target into the function vector (in page zero), and the address of the
+   vector entry to be placed in the jump/call instruction.  */
+#define R_MEM_INDIRECT 0x4a
+
+/* This reloc identifies a 16bit pc-relative branch target which was
+   shortened into an 8bit pc-relative branch target.  */
+#define R_PCRWORD_B    0x4b
+
+/* This reloc identifies mov.[wl] instructions with a 32/24 bit
+   absolute address; the linker may turn this into a mov.[wl]
+   insn with a 16bit absolute address.  */
+#define R_MOVL1        0x4c
+
+/* This reloc identifies mov.[wl] insns which formerlly had
+   a 32/24bit absolute address and now have a 16bit absolute address.  */
+#define R_MOVL2        0x4d
+
+/* This reloc identifies a bCC:8 which will have it's condition
+   inverted and its target redirected to the target of the branch
+   in the following insn.  */
+#define R_BCC_INV      0x4e
+
+/* This reloc identifies a jmp instruction that has been deleted.  */
+#define R_JMP_DEL      0x4f
 
 /* Z8k modes */
 #define R_IMM16   0x01         /* 16 bit abs */
@@ -598,30 +708,6 @@ struct internal_reloc
 #define R_H8500_IMM32   8               /* 32 bit immediate */
 #define R_H8500_HIGH16  9              /* high 16 bits of 32 bit immediate */
 
-/* SH modes */
-
-#define R_SH_PCREL8    3               /*  8 bit pcrel         */
-#define R_SH_PCREL16   4               /* 16 bit pcrel         */
-#define R_SH_HIGH8     5               /* high 8 bits of 24 bit address */
-#define R_SH_LOW16     7               /* low 16 bits of 24 bit immediate */
-#define R_SH_IMM24     6               /* 24 bit immediate */
-#define R_SH_PCDISP8BY4        9               /* PC rel 8 bits *4 +ve */
-#define R_SH_PCDISP8BY2        10              /* PC rel 8 bits *2 +ve */
-#define R_SH_PCDISP8    11             /* 8 bit branch */
-#define R_SH_PCDISP     12             /* 12 bit branch */
-#define R_SH_IMM32      14             /* 32 bit immediate */
-#define R_SH_IMM8      16
-#define R_SH_IMM8BY2    17
-#define R_SH_IMM8BY4    18
-#define R_SH_IMM4      19
-#define R_SH_IMM4BY2    20
-#define R_SH_IMM4BY4    21
-#define R_SH_PCRELIMM8BY2   22
-#define R_SH_PCRELIMM8BY4   23
-#define R_SH_IMM16      24             /* 16 bit immediate */
-
-
-
 /* W65 modes */
 
 #define R_W65_ABS8     1  /* addr & 0xff               */
@@ -639,3 +725,4 @@ struct internal_reloc
 
 #define R_W65_DP       10  /* direct page 8 bits only   */
 
+#endif /* GNU_COFF_INTERNAL_H */
This page took 0.029993 seconds and 4 git commands to generate.