home *** CD-ROM | disk | FTP | other *** search
/ Geek Gadgets 1 / ADE-1.bin / ade-dist / gdb-4.16-base.tgz / gdb-4.16-base.tar / fsf / gdb / include / elf / internal.h < prev    next >
C/C++ Source or Header  |  1995-11-30  |  8KB  |  208 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 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. #ifndef _ELF_INTERNAL_H
  37. #define _ELF_INTERNAL_H
  38.  
  39. /* ELF Header */
  40.  
  41. #define EI_NIDENT    16        /* Size of e_ident[] */
  42.  
  43. typedef struct elf_internal_ehdr {
  44.   unsigned char        e_ident[EI_NIDENT];    /* ELF "magic number" */
  45.   bfd_vma        e_entry;        /* Entry point virtual address */
  46.   bfd_signed_vma    e_phoff;        /* Program header table file offset */
  47.   bfd_signed_vma    e_shoff;        /* Section header table file offset */
  48.   unsigned long        e_version;        /* Identifies object file version */
  49.   unsigned long        e_flags;        /* Processor-specific flags */
  50.   unsigned short    e_type;            /* Identifies object file type */
  51.   unsigned short    e_machine;        /* Specifies required architecture */
  52.   unsigned short    e_ehsize;        /* ELF header size in bytes */
  53.   unsigned short    e_phentsize;        /* Program header table entry size */
  54.   unsigned short    e_phnum;        /* Program header table entry count */
  55.   unsigned short    e_shentsize;        /* Section header table entry size */
  56.   unsigned short    e_shnum;        /* Section header table entry count */
  57.   unsigned short    e_shstrndx;        /* Section header string table index */
  58. } Elf_Internal_Ehdr;
  59.  
  60. #define elf32_internal_ehdr elf_internal_ehdr
  61. #define Elf32_Internal_Ehdr Elf_Internal_Ehdr
  62. #define elf64_internal_ehdr elf_internal_ehdr
  63. #define Elf64_Internal_Ehdr Elf_Internal_Ehdr
  64.  
  65. /* Program header */
  66.  
  67. struct elf_internal_phdr {
  68.   unsigned long    p_type;            /* Identifies program segment type */
  69.   unsigned long    p_flags;        /* Segment flags */
  70.   bfd_vma    p_offset;        /* Segment file offset */
  71.   bfd_vma    p_vaddr;        /* Segment virtual address */
  72.   bfd_vma    p_paddr;        /* Segment physical address */
  73.   bfd_vma    p_filesz;        /* Segment size in file */
  74.   bfd_vma    p_memsz;        /* Segment size in memory */
  75.   bfd_vma    p_align;        /* Segment alignment, file & memory */
  76. };
  77.  
  78. typedef struct elf_internal_phdr Elf_Internal_Phdr;
  79. #define elf32_internal_phdr elf_internal_phdr
  80. #define Elf32_Internal_Phdr Elf_Internal_Phdr
  81. #define elf64_internal_phdr elf_internal_phdr
  82. #define Elf64_Internal_Phdr Elf_Internal_Phdr
  83.  
  84. /* Section header */
  85.  
  86. typedef struct elf_internal_shdr {
  87.   unsigned int    sh_name;        /* Section name, index in string tbl */
  88.   unsigned int    sh_type;        /* Type of section */
  89.   bfd_vma    sh_flags;        /* Miscellaneous section attributes */
  90.   bfd_vma    sh_addr;        /* Section virtual addr at execution */
  91.   bfd_size_type    sh_size;        /* Size of section in bytes */
  92.   bfd_size_type    sh_entsize;        /* Entry size if section holds table */
  93.   unsigned long    sh_link;        /* Index of another section */
  94.   unsigned long    sh_info;        /* Additional section information */
  95.   file_ptr    sh_offset;        /* Section file offset */
  96.   unsigned int    sh_addralign;        /* Section alignment */
  97.  
  98.   /* The internal rep also has some cached info associated with it. */
  99.   asection *    bfd_section;        /* Associated BFD section.  */
  100.   PTR        contents;        /* Section contents.  */
  101. } Elf_Internal_Shdr;
  102.  
  103. #define elf32_internal_shdr elf_internal_shdr
  104. #define Elf32_Internal_Shdr Elf_Internal_Shdr
  105. #define elf64_internal_shdr elf_internal_shdr
  106. #define Elf64_Internal_Shdr Elf_Internal_Shdr
  107.  
  108. /* Symbol table entry */
  109.  
  110. struct elf_internal_sym {
  111.   bfd_vma    st_value;        /* Value of the symbol */
  112.   bfd_vma    st_size;        /* Associated symbol size */
  113.   unsigned long    st_name;        /* Symbol name, index in string tbl */
  114.   unsigned char    st_info;        /* Type and binding attributes */
  115.   unsigned char    st_other;        /* No defined meaning, 0 */
  116.   unsigned short st_shndx;        /* Associated section index */
  117. };
  118.  
  119. typedef struct elf_internal_sym Elf_Internal_Sym;
  120.  
  121. #define elf32_internal_sym elf_internal_sym
  122. #define elf64_internal_sym elf_internal_sym
  123. #define Elf32_Internal_Sym Elf_Internal_Sym
  124. #define Elf64_Internal_Sym Elf_Internal_Sym
  125.  
  126. /* Note segments */
  127.  
  128. typedef struct elf_internal_note {
  129.   unsigned long    namesz;            /* Size of entry's owner string */
  130.   unsigned long    descsz;            /* Size of the note descriptor */
  131.   unsigned long    type;            /* Interpretation of the descriptor */
  132.   char        name[1];        /* Start of the name+desc data */
  133. } Elf_Internal_Note;
  134. #define Elf32_Internal_Note    Elf_Internal_Note
  135. #define elf32_internal_note    elf_internal_note
  136.  
  137. /* Relocation Entries */
  138.  
  139. typedef struct elf_internal_rel {
  140.   bfd_vma    r_offset;    /* Location at which to apply the action */
  141.   /* This needs to support 64-bit values in elf64.  */
  142.   bfd_vma    r_info;        /* index and type of relocation */
  143. } Elf_Internal_Rel;
  144.  
  145. #define elf32_internal_rel elf_internal_rel
  146. #define Elf32_Internal_Rel Elf_Internal_Rel
  147. #define elf64_internal_rel elf_internal_rel
  148. #define Elf64_Internal_Rel Elf_Internal_Rel
  149.  
  150. typedef struct elf_internal_rela {
  151.   bfd_vma    r_offset;    /* Location at which to apply the action */
  152.   bfd_vma    r_info;        /* Index and Type of relocation */
  153.   bfd_signed_vma r_addend;    /* Constant addend used to compute value */
  154. } Elf_Internal_Rela;
  155.  
  156. #define elf32_internal_rela elf_internal_rela
  157. #define elf64_internal_rela elf_internal_rela
  158. #define Elf32_Internal_Rela Elf_Internal_Rela
  159. #define Elf64_Internal_Rela Elf_Internal_Rela
  160.  
  161. /* dynamic section structure */
  162.  
  163. typedef struct elf_internal_dyn {
  164.   /* This needs to support 64-bit values in elf64.  */
  165.   bfd_vma d_tag;        /* entry tag value */
  166.   union {
  167.     /* This needs to support 64-bit values in elf64.  */
  168.     bfd_vma    d_val;
  169.     bfd_vma    d_ptr;
  170.   } d_un;
  171. } Elf_Internal_Dyn;
  172.  
  173. #define elf32_internal_dyn elf_internal_dyn
  174. #define elf64_internal_dyn elf_internal_dyn
  175. #define Elf32_Internal_Dyn Elf_Internal_Dyn
  176. #define Elf64_Internal_Dyn Elf_Internal_Dyn
  177.  
  178. /* This structure is used to describe how sections should be assigned
  179.    to program segments.  */
  180.  
  181. struct elf_segment_map
  182. {
  183.   /* Next program segment.  */
  184.   struct elf_segment_map *next;
  185.   /* Program segment type.  */
  186.   unsigned long p_type;
  187.   /* Program segment flags.  */
  188.   unsigned long p_flags;
  189.   /* Program segment physical address.  */
  190.   bfd_vma p_paddr;
  191.   /* Whether the p_flags field is valid; if not, the flags are based
  192.      on the section flags.  */
  193.   unsigned int p_flags_valid : 1;
  194.   /* Whether the p_paddr field is valid; if not, the physical address
  195.      is based on the section lma values.  */
  196.   unsigned int p_paddr_valid : 1;
  197.   /* Whether this segment includes the file header.  */
  198.   unsigned int includes_filehdr : 1;
  199.   /* Whether this segment includes the program headers.  */
  200.   unsigned int includes_phdrs : 1;
  201.   /* Number of sections (may be 0).  */
  202.   unsigned int count;
  203.   /* Sections.  Actual number of elements is in count field.  */
  204.   asection *sections[1];
  205. };
  206.  
  207. #endif /* _ELF_INTERNAL_H */
  208.