]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/C/GenFw/elf64.h
BaseTools/GenFw: Disable support for R_X86_64_32S
[mirror_edk2.git] / BaseTools / Source / C / GenFw / elf64.h
index 9960888940425e28773151e56a802cdbcdaf608b..f4d4e1a28c06d327653b711b375a70b12e710d1d 100644 (file)
-/*-
- * Copyright (c) 1996-1998 John D. Polstra.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $FreeBSD: src/sys/sys/elf64.h,v 1.10.14.2 2007/12/03 21:30:36 marius Exp $
- */
-
-#ifndef _SYS_ELF64_H_
-#define _SYS_ELF64_H_ 1
-
-
-/*
- * ELF definitions common to all 64-bit architectures.
- */
-
-typedef UINT64 Elf64_Addr;
-typedef UINT16 Elf64_Half;
-typedef UINT64 Elf64_Off;
-typedef INT32          Elf64_Sword;
-typedef INT64          Elf64_Sxword;
-typedef UINT32 Elf64_Word;
-typedef UINT64 Elf64_Lword;
-typedef UINT64 Elf64_Xword;
-
-/*
- * Types of dynamic symbol hash table bucket and chain elements.
- *
- * This is inconsistent among 64 bit architectures, so a machine dependent
- * typedef is required.
- */
-
-typedef Elf64_Word     Elf64_Hashelt;
-
-/* Non-standard class-dependent datatype used for abstraction. */
-typedef Elf64_Xword      Elf64_Size;
-typedef Elf64_Sxword   Elf64_Ssize;
-
-/*
- * ELF header.
- */
-
-typedef struct {
-       unsigned char   e_ident[EI_NIDENT];     /* File identification. */
-       Elf64_Half      e_type;         /* File type. */
-       Elf64_Half      e_machine;      /* Machine architecture. */
-       Elf64_Word      e_version;      /* ELF format version. */
-       Elf64_Addr      e_entry;        /* Entry point. */
-       Elf64_Off       e_phoff;        /* Program header file offset. */
-       Elf64_Off       e_shoff;        /* Section header file offset. */
-       Elf64_Word      e_flags;        /* Architecture-specific flags. */
-       Elf64_Half      e_ehsize;       /* Size of ELF header in bytes. */
-       Elf64_Half      e_phentsize;    /* Size of program header entry. */
-       Elf64_Half      e_phnum;        /* Number of program header entries. */
-       Elf64_Half      e_shentsize;    /* Size of section header entry. */
-       Elf64_Half      e_shnum;        /* Number of section header entries. */
-       Elf64_Half      e_shstrndx;     /* Section name strings section. */
-} Elf64_Ehdr;
-
-/*
- * Section header.
- */
-
-typedef struct {
-       Elf64_Word      sh_name;        /* Section name (index into the
-                                          section header string table). */
-       Elf64_Word      sh_type;        /* Section type. */
-       Elf64_Xword     sh_flags;       /* Section flags. */
-       Elf64_Addr      sh_addr;        /* Address in memory image. */
-       Elf64_Off       sh_offset;      /* Offset in file. */
-       Elf64_Xword     sh_size;        /* Size in bytes. */
-       Elf64_Word      sh_link;        /* Index of a related section. */
-       Elf64_Word      sh_info;        /* Depends on section type. */
-       Elf64_Xword     sh_addralign;   /* Alignment in bytes. */
-       Elf64_Xword     sh_entsize;     /* Size of each entry in section. */
-} Elf64_Shdr;
-
-/*
- * Program header.
- */
-
-typedef struct {
-       Elf64_Word      p_type;         /* Entry type. */
-       Elf64_Word      p_flags;        /* Access permission flags. */
-       Elf64_Off       p_offset;       /* File offset of contents. */
-       Elf64_Addr      p_vaddr;        /* Virtual address in memory image. */
-       Elf64_Addr      p_paddr;        /* Physical address (not used). */
-       Elf64_Xword     p_filesz;       /* Size of contents in file. */
-       Elf64_Xword     p_memsz;        /* Size of contents in memory. */
-       Elf64_Xword     p_align;        /* Alignment in memory and file. */
-} Elf64_Phdr;
-
-/*
- * Dynamic structure.  The ".dynamic" section contains an array of them.
- */
-
-typedef struct {
-       Elf64_Sxword    d_tag;          /* Entry type. */
-       union {
-               Elf64_Xword     d_val;  /* Integer value. */
-               Elf64_Addr      d_ptr;  /* Address value. */
-       } d_un;
-} Elf64_Dyn;
-
-/*
- * Relocation entries.
- */
-
-/* Relocations that don't need an addend field. */
-typedef struct {
-       Elf64_Addr      r_offset;       /* Location to be relocated. */
-       Elf64_Xword     r_info;         /* Relocation type and symbol index. */
-} Elf64_Rel;
-
-/* Relocations that need an addend field. */
-typedef struct {
-       Elf64_Addr      r_offset;       /* Location to be relocated. */
-       Elf64_Xword     r_info;         /* Relocation type and symbol index. */
-       Elf64_Sxword    r_addend;       /* Addend. */
-} Elf64_Rela;
-
-/* Macros for accessing the fields of r_info. */
-#define ELF64_R_SYM(info)      ((info) >> 32)
-#define ELF64_R_TYPE(info)     ((info) & 0xffffffffL)
-
-/* Macro for constructing r_info from field values. */
-#define ELF64_R_INFO(sym, type)        (((sym) << 32) + ((type) & 0xffffffffL))
-
-#define        ELF64_R_TYPE_DATA(info) (((Elf64_Xword)(info)<<32)>>40)
-#define        ELF64_R_TYPE_ID(info)   (((Elf64_Xword)(info)<<56)>>56)
-#define        ELF64_R_TYPE_INFO(data, type)   \
-               (((Elf64_Xword)(data)<<8)+(Elf64_Xword)(type))
-
-/*
- *     Note entry header
- */
-typedef Elf_Note Elf64_Nhdr;
-
-/*
- *     Move entry
- */
-typedef struct {
-       Elf64_Lword     m_value;        /* symbol value */
-       Elf64_Xword     m_info;         /* size + index */
-       Elf64_Xword     m_poffset;      /* symbol offset */
-       Elf64_Half      m_repeat;       /* repeat count */
-       Elf64_Half      m_stride;       /* stride info */
-} Elf64_Move;
-
-#define        ELF64_M_SYM(info)       ((info)>>8)
-#define        ELF64_M_SIZE(info)      ((unsigned char)(info))
-#define        ELF64_M_INFO(sym, size) (((sym)<<8)+(unsigned char)(size))
-
-/*
- *     Hardware/Software capabilities entry
- */
-typedef struct {
-       Elf64_Xword     c_tag;          /* how to interpret value */
-       union {
-               Elf64_Xword     c_val;
-               Elf64_Addr      c_ptr;
-       } c_un;
-} Elf64_Cap;
-
-/*
- * Symbol table entries.
- */
-
-typedef struct {
-       Elf64_Word      st_name;        /* String table index of name. */
-       unsigned char   st_info;        /* Type and binding information. */
-       unsigned char   st_other;       /* Reserved (not used). */
-       Elf64_Half      st_shndx;       /* Section index of symbol. */
-       Elf64_Addr      st_value;       /* Symbol value. */
-       Elf64_Xword     st_size;        /* Size of associated object. */
-} Elf64_Sym;
-
-/* Macros for accessing the fields of st_info. */
-#define ELF64_ST_BIND(info)            ((info) >> 4)
-#define ELF64_ST_TYPE(info)            ((info) & 0xf)
-
-/* Macro for constructing st_info from field values. */
-#define ELF64_ST_INFO(bind, type)      (((bind) << 4) + ((type) & 0xf))
-
-/* Macro for accessing the fields of st_other. */
-#define ELF64_ST_VISIBILITY(oth)       ((oth) & 0x3)
-
-/* Structures used by Sun & GNU-style symbol versioning. */
-typedef struct {
-       Elf64_Half      vd_version;
-       Elf64_Half      vd_flags;
-       Elf64_Half      vd_ndx;
-       Elf64_Half      vd_cnt;
-       Elf64_Word      vd_hash;
-       Elf64_Word      vd_aux;
-       Elf64_Word      vd_next;
-} Elf64_Verdef;
-
-typedef struct {
-       Elf64_Word      vda_name;
-       Elf64_Word      vda_next;
-} Elf64_Verdaux;
-
-typedef struct {
-       Elf64_Half      vn_version;
-       Elf64_Half      vn_cnt;
-       Elf64_Word      vn_file;
-       Elf64_Word      vn_aux;
-       Elf64_Word      vn_next;
-} Elf64_Verneed;
-
-typedef struct {
-       Elf64_Word      vna_hash;
-       Elf64_Half      vna_flags;
-       Elf64_Half      vna_other;
-       Elf64_Word      vna_name;
-       Elf64_Word      vna_next;
-} Elf64_Vernaux;
-
-typedef Elf64_Half Elf64_Versym;
-
-typedef struct {
-       Elf64_Half      si_boundto;     /* direct bindings - symbol bound to */
-       Elf64_Half      si_flags;       /* per symbol flags */
-} Elf64_Syminfo;
-
-#endif /* !_SYS_ELF64_H_ */
+/** @file\r
+Ported ELF include files from FreeBSD\r
+\r
+Copyright (c) 2009 - 2010, Apple Inc. All rights reserved.<BR>\r
+This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+/*-\r
+ * Copyright (c) 1996-1998 John D. Polstra.\r
+ * All rights reserved.\r
+ *\r
+ * Redistribution and use in source and binary forms, with or without\r
+ * modification, are permitted provided that the following conditions\r
+ * are met:\r
+ * 1. Redistributions of source code must retain the above copyright\r
+ *    notice, this list of conditions and the following disclaimer.\r
+ * 2. Redistributions in binary form must reproduce the above copyright\r
+ *    notice, this list of conditions and the following disclaimer in the\r
+ *    documentation and/or other materials provided with the distribution.\r
+ *\r
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND\r
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\r
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\r
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\r
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\r
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\r
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\r
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\r
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\r
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\r
+ * SUCH DAMAGE.\r
+ *\r
+ * $FreeBSD: src/sys/sys/elf64.h,v 1.10.14.2 2007/12/03 21:30:36 marius Exp $\r
+ */\r
+\r
+#ifndef _SYS_ELF64_H_\r
+#define _SYS_ELF64_H_ 1\r
+\r
+\r
+/*\r
+ * ELF definitions common to all 64-bit architectures.\r
+ */\r
+\r
+typedef UINT64  Elf64_Addr;\r
+typedef UINT16  Elf64_Half;\r
+typedef UINT64  Elf64_Off;\r
+typedef INT32    Elf64_Sword;\r
+typedef INT64    Elf64_Sxword;\r
+typedef UINT32  Elf64_Word;\r
+typedef UINT64  Elf64_Lword;\r
+typedef UINT64  Elf64_Xword;\r
+\r
+/*\r
+ * Types of dynamic symbol hash table bucket and chain elements.\r
+ *\r
+ * This is inconsistent among 64 bit architectures, so a machine dependent\r
+ * typedef is required.\r
+ */\r
+\r
+typedef Elf64_Word  Elf64_Hashelt;\r
+\r
+/* Non-standard class-dependent datatype used for abstraction. */\r
+typedef Elf64_Xword    Elf64_Size;\r
+typedef Elf64_Sxword  Elf64_Ssize;\r
+\r
+/*\r
+ * ELF header.\r
+ */\r
+\r
+typedef struct {\r
+  unsigned char  e_ident[EI_NIDENT];  /* File identification. */\r
+  Elf64_Half  e_type;    /* File type. */\r
+  Elf64_Half  e_machine;  /* Machine architecture. */\r
+  Elf64_Word  e_version;  /* ELF format version. */\r
+  Elf64_Addr  e_entry;  /* Entry point. */\r
+  Elf64_Off  e_phoff;  /* Program header file offset. */\r
+  Elf64_Off  e_shoff;  /* Section header file offset. */\r
+  Elf64_Word  e_flags;  /* Architecture-specific flags. */\r
+  Elf64_Half  e_ehsize;  /* Size of ELF header in bytes. */\r
+  Elf64_Half  e_phentsize;  /* Size of program header entry. */\r
+  Elf64_Half  e_phnum;  /* Number of program header entries. */\r
+  Elf64_Half  e_shentsize;  /* Size of section header entry. */\r
+  Elf64_Half  e_shnum;  /* Number of section header entries. */\r
+  Elf64_Half  e_shstrndx;  /* Section name strings section. */\r
+} Elf64_Ehdr;\r
+\r
+/*\r
+ * Section header.\r
+ */\r
+\r
+typedef struct {\r
+  Elf64_Word  sh_name;  /* Section name (index into the\r
+             section header string table). */\r
+  Elf64_Word  sh_type;  /* Section type. */\r
+  Elf64_Xword  sh_flags;  /* Section flags. */\r
+  Elf64_Addr  sh_addr;  /* Address in memory image. */\r
+  Elf64_Off  sh_offset;  /* Offset in file. */\r
+  Elf64_Xword  sh_size;  /* Size in bytes. */\r
+  Elf64_Word  sh_link;  /* Index of a related section. */\r
+  Elf64_Word  sh_info;  /* Depends on section type. */\r
+  Elf64_Xword  sh_addralign;  /* Alignment in bytes. */\r
+  Elf64_Xword  sh_entsize;  /* Size of each entry in section. */\r
+} Elf64_Shdr;\r
+\r
+/*\r
+ * Program header.\r
+ */\r
+\r
+typedef struct {\r
+  Elf64_Word  p_type;    /* Entry type. */\r
+  Elf64_Word  p_flags;  /* Access permission flags. */\r
+  Elf64_Off  p_offset;  /* File offset of contents. */\r
+  Elf64_Addr  p_vaddr;  /* Virtual address in memory image. */\r
+  Elf64_Addr  p_paddr;  /* Physical address (not used). */\r
+  Elf64_Xword  p_filesz;  /* Size of contents in file. */\r
+  Elf64_Xword  p_memsz;  /* Size of contents in memory. */\r
+  Elf64_Xword  p_align;  /* Alignment in memory and file. */\r
+} Elf64_Phdr;\r
+\r
+/*\r
+ * Dynamic structure.  The ".dynamic" section contains an array of them.\r
+ */\r
+\r
+typedef struct {\r
+  Elf64_Sxword  d_tag;    /* Entry type. */\r
+  union {\r
+    Elf64_Xword  d_val;  /* Integer value. */\r
+    Elf64_Addr  d_ptr;  /* Address value. */\r
+  } d_un;\r
+} Elf64_Dyn;\r
+\r
+/*\r
+ * Relocation entries.\r
+ */\r
+\r
+/* Relocations that don't need an addend field. */\r
+typedef struct {\r
+  Elf64_Addr  r_offset;  /* Location to be relocated. */\r
+  Elf64_Xword  r_info;    /* Relocation type and symbol index. */\r
+} Elf64_Rel;\r
+\r
+/* Relocations that need an addend field. */\r
+typedef struct {\r
+  Elf64_Addr  r_offset;  /* Location to be relocated. */\r
+  Elf64_Xword  r_info;    /* Relocation type and symbol index. */\r
+  Elf64_Sxword  r_addend;  /* Addend. */\r
+} Elf64_Rela;\r
+\r
+/* Macros for accessing the fields of r_info. */\r
+#define ELF64_R_SYM(info)  ((info) >> 32)\r
+#define ELF64_R_TYPE(info)  ((info) & 0xffffffffL)\r
+\r
+/* Macro for constructing r_info from field values. */\r
+#define ELF64_R_INFO(sym, type)  (((sym) << 32) + ((type) & 0xffffffffL))\r
+\r
+#define  ELF64_R_TYPE_DATA(info)  (((Elf64_Xword)(info)<<32)>>40)\r
+#define  ELF64_R_TYPE_ID(info)  (((Elf64_Xword)(info)<<56)>>56)\r
+#define  ELF64_R_TYPE_INFO(data, type)  \\r
+    (((Elf64_Xword)(data)<<8)+(Elf64_Xword)(type))\r
+\r
+/*\r
+ *  Note entry header\r
+ */\r
+typedef Elf_Note Elf64_Nhdr;\r
+\r
+/*\r
+ *  Move entry\r
+ */\r
+typedef struct {\r
+  Elf64_Lword  m_value;  /* symbol value */\r
+  Elf64_Xword   m_info;    /* size + index */\r
+  Elf64_Xword  m_poffset;  /* symbol offset */\r
+  Elf64_Half  m_repeat;  /* repeat count */\r
+  Elf64_Half  m_stride;  /* stride info */\r
+} Elf64_Move;\r
+\r
+#define  ELF64_M_SYM(info)  ((info)>>8)\r
+#define  ELF64_M_SIZE(info)  ((unsigned char)(info))\r
+#define  ELF64_M_INFO(sym, size)  (((sym)<<8)+(unsigned char)(size))\r
+\r
+/*\r
+ *  Hardware/Software capabilities entry\r
+ */\r
+typedef struct {\r
+  Elf64_Xword  c_tag;    /* how to interpret value */\r
+  union {\r
+    Elf64_Xword  c_val;\r
+    Elf64_Addr  c_ptr;\r
+  } c_un;\r
+} Elf64_Cap;\r
+\r
+/*\r
+ * Symbol table entries.\r
+ */\r
+\r
+typedef struct {\r
+  Elf64_Word  st_name;  /* String table index of name. */\r
+  unsigned char  st_info;  /* Type and binding information. */\r
+  unsigned char  st_other;  /* Reserved (not used). */\r
+  Elf64_Half  st_shndx;  /* Section index of symbol. */\r
+  Elf64_Addr  st_value;  /* Symbol value. */\r
+  Elf64_Xword  st_size;  /* Size of associated object. */\r
+} Elf64_Sym;\r
+\r
+/* Macros for accessing the fields of st_info. */\r
+#define ELF64_ST_BIND(info)    ((info) >> 4)\r
+#define ELF64_ST_TYPE(info)    ((info) & 0xf)\r
+\r
+/* Macro for constructing st_info from field values. */\r
+#define ELF64_ST_INFO(bind, type)  (((bind) << 4) + ((type) & 0xf))\r
+\r
+/* Macro for accessing the fields of st_other. */\r
+#define ELF64_ST_VISIBILITY(oth)  ((oth) & 0x3)\r
+\r
+/* Structures used by Sun & GNU-style symbol versioning. */\r
+typedef struct {\r
+  Elf64_Half  vd_version;\r
+  Elf64_Half  vd_flags;\r
+  Elf64_Half  vd_ndx;\r
+  Elf64_Half  vd_cnt;\r
+  Elf64_Word  vd_hash;\r
+  Elf64_Word  vd_aux;\r
+  Elf64_Word  vd_next;\r
+} Elf64_Verdef;\r
+\r
+typedef struct {\r
+  Elf64_Word  vda_name;\r
+  Elf64_Word  vda_next;\r
+} Elf64_Verdaux;\r
+\r
+typedef struct {\r
+  Elf64_Half  vn_version;\r
+  Elf64_Half  vn_cnt;\r
+  Elf64_Word  vn_file;\r
+  Elf64_Word  vn_aux;\r
+  Elf64_Word  vn_next;\r
+} Elf64_Verneed;\r
+\r
+typedef struct {\r
+  Elf64_Word  vna_hash;\r
+  Elf64_Half  vna_flags;\r
+  Elf64_Half  vna_other;\r
+  Elf64_Word  vna_name;\r
+  Elf64_Word  vna_next;\r
+} Elf64_Vernaux;\r
+\r
+typedef Elf64_Half Elf64_Versym;\r
+\r
+typedef struct {\r
+  Elf64_Half  si_boundto;  /* direct bindings - symbol bound to */\r
+  Elf64_Half  si_flags;  /* per symbol flags */\r
+} Elf64_Syminfo;\r
+\r
+#endif /* !_SYS_ELF64_H_ */\r