home *** CD-ROM | disk | FTP | other *** search
/ Il CD di internet / CD.iso / SOURCE / D / GDB / GDB-4.13 / GDB-4 / gdb-4.13 / include / elf / internal.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-04-25  |  6.7 KB  |  175 lines

  1. /* ELF support for BFD.
  2.    Copyright (C) 1991, 1992, 1993, 1994 Free Software Foundation, Inc.
  3.  
  4.    Written by Fred Fish @ Cygnus Support, from information published
  5.    in "UNIX System V Release 4, Programmers Guide: ANSI C and
  6.    Programming Support Tools".
  7.  
  8. This file is part of BFD, the Binary File Descriptor library.
  9.  
  10. This program is free software; you can redistribute it and/or modify
  11. it under the terms of the GNU General Public License as published by
  12. the Free Software Foundation; either version 2 of the License, or
  13. (at your option) any later version.
  14.  
  15. This program is distributed in the hope that it will be useful,
  16. but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  18. GNU General Public License for more details.
  19.  
  20. You should have received a copy of the GNU General Public License
  21. along with this program; if not, write to the Free Software
  22. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
  23.  
  24.  
  25. /* This file is part of ELF support for BFD, and contains the portions
  26.    that describe how ELF is represented internally in the BFD library.
  27.    I.E. it describes the in-memory representation of ELF.  It requires
  28.    the elf-common.h file which contains the portions that are common to
  29.    both the internal and external representations. */
  30.    
  31.  
  32. /* NOTE that these structures are not kept in the same order as they appear
  33.    in the object file.  In some cases they've been reordered for more optimal
  34.    packing under various circumstances.  */
  35.  
  36. /* ELF Header */
  37.  
  38. #define EI_NIDENT    16        /* Size of e_ident[] */
  39.  
  40. typedef struct elf_internal_ehdr {
  41.   unsigned char        e_ident[EI_NIDENT];    /* ELF "magic number" */
  42.   bfd_vma        e_entry;        /* Entry point virtual address */
  43.   bfd_signed_vma    e_phoff;        /* Program header table file offset */
  44.   bfd_signed_vma    e_shoff;        /* Section header table file offset */
  45.   unsigned long        e_version;        /* Identifies object file version */
  46.   unsigned long        e_flags;        /* Processor-specific flags */
  47.   unsigned short    e_type;            /* Identifies object file type */
  48.   unsigned short    e_machine;        /* Specifies required architecture */
  49.   unsigned short    e_ehsize;        /* ELF header size in bytes */
  50.   unsigned short    e_phentsize;        /* Program header table entry size */
  51.   unsigned short    e_phnum;        /* Program header table entry count */
  52.   unsigned short    e_shentsize;        /* Section header table entry size */
  53.   unsigned short    e_shnum;        /* Section header table entry count */
  54.   unsigned short    e_shstrndx;        /* Section header string table index */
  55. } Elf_Internal_Ehdr;
  56.  
  57. #define elf32_internal_ehdr elf_internal_ehdr
  58. #define Elf32_Internal_Ehdr Elf_Internal_Ehdr
  59. #define elf64_internal_ehdr elf_internal_ehdr
  60. #define Elf64_Internal_Ehdr Elf_Internal_Ehdr
  61.  
  62. /* Program header */
  63.  
  64. struct elf_internal_phdr {
  65.   unsigned long    p_type;            /* Identifies program segment type */
  66.   unsigned long    p_flags;        /* Segment flags */
  67.   bfd_vma    p_offset;        /* Segment file offset */
  68.   bfd_vma    p_vaddr;        /* Segment virtual address */
  69.   bfd_vma    p_paddr;        /* Segment physical address */
  70.   bfd_vma    p_filesz;        /* Segment size in file */
  71.   bfd_vma    p_memsz;        /* Segment size in memory */
  72.   bfd_vma    p_align;        /* Segment alignment, file & memory */
  73. };
  74.  
  75. typedef struct elf_internal_phdr Elf_Internal_Phdr;
  76. #define elf32_internal_phdr elf_internal_phdr
  77. #define Elf32_Internal_Phdr Elf_Internal_Phdr
  78. #define elf64_internal_phdr elf_internal_phdr
  79. #define Elf64_Internal_Phdr Elf_Internal_Phdr
  80.  
  81. /* Section header */
  82.  
  83. typedef struct elf_internal_shdr {
  84.   unsigned int    sh_name;        /* Section name, index in string tbl */
  85.   unsigned int    sh_type;        /* Type of section */
  86.   bfd_vma    sh_flags;        /* Miscellaneous section attributes */
  87.   bfd_vma    sh_addr;        /* Section virtual addr at execution */
  88.   bfd_size_type    sh_size;        /* Size of section in bytes */
  89.   bfd_size_type    sh_entsize;        /* Entry size if section holds table */
  90.   unsigned long    sh_link;        /* Index of another section */
  91.   unsigned long    sh_info;        /* Additional section information */
  92.   file_ptr    sh_offset;        /* Section file offset */
  93.   unsigned int    sh_addralign;        /* Section alignment */
  94.  
  95.   /* The internal rep also has some cached info associated with it. */
  96.   PTR        rawdata;        /* null if unused... */
  97.   PTR        contents;        /* null if unused... */
  98.   bfd_vma    size;            /* size of contents (0 if unused) */
  99. } Elf_Internal_Shdr;
  100.  
  101. #define elf32_internal_shdr elf_internal_shdr
  102. #define Elf32_Internal_Shdr Elf_Internal_Shdr
  103. #define elf64_internal_shdr elf_internal_shdr
  104. #define Elf64_Internal_Shdr Elf_Internal_Shdr
  105.  
  106. /* Symbol table entry */
  107.  
  108. struct elf_internal_sym {
  109.   bfd_vma    st_value;        /* Value of the symbol */
  110.   bfd_vma    st_size;        /* Associated symbol size */
  111.   unsigned long    st_name;        /* Symbol name, index in string tbl */
  112.   unsigned char    st_info;        /* Type and binding attributes */
  113.   unsigned char    st_other;        /* No defined meaning, 0 */
  114.   unsigned short st_shndx;        /* Associated section index */
  115. };
  116.  
  117. typedef struct elf_internal_sym Elf_Internal_Sym;
  118.  
  119. #define elf32_internal_sym elf_internal_sym
  120. #define elf64_internal_sym elf_internal_sym
  121. #define Elf32_Internal_Sym Elf_Internal_Sym
  122. #define Elf64_Internal_Sym Elf_Internal_Sym
  123.  
  124. /* Note segments */
  125.  
  126. typedef struct elf_internal_note {
  127.   unsigned long    namesz;            /* Size of entry's owner string */
  128.   unsigned long    descsz;            /* Size of the note descriptor */
  129.   unsigned long    type;            /* Interpretation of the descriptor */
  130.   char        name[1];        /* Start of the name+desc data */
  131. } Elf_Internal_Note;
  132. #define Elf32_Internal_Note    Elf_Internal_Note
  133. #define elf32_internal_note    elf_internal_note
  134.  
  135. /* Relocation Entries */
  136.  
  137. typedef struct elf_internal_rel {
  138.   bfd_vma    r_offset;    /* Location at which to apply the action */
  139.   /* This needs to support 64-bit values in elf64.  */
  140.   bfd_vma    r_info;        /* index and type of relocation */
  141. } Elf_Internal_Rel;
  142.  
  143. #define elf32_internal_rel elf_internal_rel
  144. #define Elf32_Internal_Rel Elf_Internal_Rel
  145. #define elf64_internal_rel elf_internal_rel
  146. #define Elf64_Internal_Rel Elf_Internal_Rel
  147.  
  148. typedef struct elf_internal_rela {
  149.   bfd_vma    r_offset;    /* Location at which to apply the action */
  150.   bfd_vma    r_info;        /* Index and Type of relocation */
  151.   bfd_signed_vma r_addend;    /* Constant addend used to compute value */
  152. } Elf_Internal_Rela;
  153.  
  154. #define elf32_internal_rela elf_internal_rela
  155. #define elf64_internal_rela elf_internal_rela
  156. #define Elf32_Internal_Rela Elf_Internal_Rela
  157. #define Elf64_Internal_Rela Elf_Internal_Rela
  158.  
  159. /* dynamic section structure */
  160.  
  161. typedef struct elf_internal_dyn {
  162.   /* This needs to support 64-bit values in elf64.  */
  163.   bfd_vma d_tag;        /* entry tag value */
  164.   union {
  165.     /* This needs to support 64-bit values in elf64.  */
  166.     bfd_vma    d_val;
  167.     bfd_vma    d_ptr;
  168.   } d_un;
  169. } Elf_Internal_Dyn;
  170.  
  171. #define elf32_internal_dyn elf_internal_dyn
  172. #define elf64_internal_dyn elf_internal_dyn
  173. #define Elf32_Internal_Dyn Elf_Internal_Dyn
  174. #define Elf64_Internal_Dyn Elf_Internal_Dyn
  175.