OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [insight/] [include/] [elf/] [internal.h] - Blame information for rev 1768

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 578 markom
/* ELF support for BFD.
2
   Copyright 1991, 1992, 1993, 1994, 1995, 1997, 1998, 2000
3
   Free Software Foundation, Inc.
4
 
5
   Written by Fred Fish @ Cygnus Support, from information published
6
   in "UNIX System V Release 4, Programmers Guide: ANSI C and
7
   Programming Support Tools".
8
 
9
This file is part of BFD, the Binary File Descriptor library.
10
 
11
This program is free software; you can redistribute it and/or modify
12
it under the terms of the GNU General Public License as published by
13
the Free Software Foundation; either version 2 of the License, or
14
(at your option) any later version.
15
 
16
This program is distributed in the hope that it will be useful,
17
but WITHOUT ANY WARRANTY; without even the implied warranty of
18
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19
GNU General Public License for more details.
20
 
21
You should have received a copy of the GNU General Public License
22
along with this program; if not, write to the Free Software
23
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
24
 
25
 
26
/* This file is part of ELF support for BFD, and contains the portions
27
   that describe how ELF is represented internally in the BFD library.
28
   I.E. it describes the in-memory representation of ELF.  It requires
29
   the elf-common.h file which contains the portions that are common to
30
   both the internal and external representations. */
31
 
32
 
33
/* NOTE that these structures are not kept in the same order as they appear
34
   in the object file.  In some cases they've been reordered for more optimal
35
   packing under various circumstances.  */
36
 
37
#ifndef _ELF_INTERNAL_H
38
#define _ELF_INTERNAL_H
39
 
40
/* ELF Header */
41
 
42
#define EI_NIDENT       16              /* Size of e_ident[] */
43
 
44
typedef struct elf_internal_ehdr {
45
  unsigned char         e_ident[EI_NIDENT];     /* ELF "magic number" */
46
  bfd_vma               e_entry;                /* Entry point virtual address */
47
  bfd_size_type         e_phoff;                /* Program header table file offset */
48
  bfd_size_type         e_shoff;                /* Section header table file offset */
49
  unsigned long         e_version;              /* Identifies object file version */
50
  unsigned long         e_flags;                /* Processor-specific flags */
51
  unsigned short        e_type;                 /* Identifies object file type */
52
  unsigned short        e_machine;              /* Specifies required architecture */
53
  unsigned short        e_ehsize;               /* ELF header size in bytes */
54
  unsigned short        e_phentsize;            /* Program header table entry size */
55
  unsigned short        e_phnum;                /* Program header table entry count */
56
  unsigned short        e_shentsize;            /* Section header table entry size */
57
  unsigned short        e_shnum;                /* Section header table entry count */
58
  unsigned short        e_shstrndx;             /* Section header string table index */
59
} Elf_Internal_Ehdr;
60
 
61
#define elf32_internal_ehdr elf_internal_ehdr
62
#define Elf32_Internal_Ehdr Elf_Internal_Ehdr
63
#define elf64_internal_ehdr elf_internal_ehdr
64
#define Elf64_Internal_Ehdr Elf_Internal_Ehdr
65
 
66
/* Program header */
67
 
68
struct elf_internal_phdr {
69
  unsigned long p_type;                 /* Identifies program segment type */
70
  unsigned long p_flags;                /* Segment flags */
71
  bfd_vma       p_offset;               /* Segment file offset */
72
  bfd_vma       p_vaddr;                /* Segment virtual address */
73
  bfd_vma       p_paddr;                /* Segment physical address */
74
  bfd_vma       p_filesz;               /* Segment size in file */
75
  bfd_vma       p_memsz;                /* Segment size in memory */
76
  bfd_vma       p_align;                /* Segment alignment, file & memory */
77
};
78
 
79
typedef struct elf_internal_phdr Elf_Internal_Phdr;
80
#define elf32_internal_phdr elf_internal_phdr
81
#define Elf32_Internal_Phdr Elf_Internal_Phdr
82
#define elf64_internal_phdr elf_internal_phdr
83
#define Elf64_Internal_Phdr Elf_Internal_Phdr
84
 
85
/* Section header */
86
 
87
typedef struct elf_internal_shdr {
88
  unsigned int  sh_name;                /* Section name, index in string tbl */
89
  unsigned int  sh_type;                /* Type of section */
90
  bfd_vma       sh_flags;               /* Miscellaneous section attributes */
91
  bfd_vma       sh_addr;                /* Section virtual addr at execution */
92
  bfd_size_type sh_size;                /* Size of section in bytes */
93
  bfd_size_type sh_entsize;             /* Entry size if section holds table */
94
  unsigned long sh_link;                /* Index of another section */
95
  unsigned long sh_info;                /* Additional section information */
96
  file_ptr      sh_offset;              /* Section file offset */
97
  unsigned int  sh_addralign;           /* Section alignment */
98
 
99
  /* The internal rep also has some cached info associated with it. */
100
  asection *    bfd_section;            /* Associated BFD section.  */
101
  PTR           contents;               /* Section contents.  */
102
} Elf_Internal_Shdr;
103
 
104
#define elf32_internal_shdr elf_internal_shdr
105
#define Elf32_Internal_Shdr Elf_Internal_Shdr
106
#define elf64_internal_shdr elf_internal_shdr
107
#define Elf64_Internal_Shdr Elf_Internal_Shdr
108
 
109
/* Symbol table entry */
110
 
111
struct elf_internal_sym {
112
  bfd_vma       st_value;               /* Value of the symbol */
113
  bfd_vma       st_size;                /* Associated symbol size */
114
  unsigned long st_name;                /* Symbol name, index in string tbl */
115
  unsigned char st_info;                /* Type and binding attributes */
116
  unsigned char st_other;               /* Visibilty, and target specific */
117
  unsigned short st_shndx;              /* Associated section index */
118
};
119
 
120
typedef struct elf_internal_sym Elf_Internal_Sym;
121
 
122
#define elf32_internal_sym elf_internal_sym
123
#define elf64_internal_sym elf_internal_sym
124
#define Elf32_Internal_Sym Elf_Internal_Sym
125
#define Elf64_Internal_Sym Elf_Internal_Sym
126
 
127
/* Note segments */
128
 
129
typedef struct elf_internal_note {
130
  unsigned long namesz;                 /* Size of entry's owner string */
131
  unsigned long descsz;                 /* Size of the note descriptor */
132
  unsigned long type;                   /* Interpretation of the descriptor */
133
  char *        namedata;               /* Start of the name+desc data */
134
  char *        descdata;               /* Start of the desc data */
135
  bfd_vma       descpos;                /* File offset of the descdata */
136
} Elf_Internal_Note;
137
#define Elf32_Internal_Note     Elf_Internal_Note
138
#define elf32_internal_note     elf_internal_note
139
 
140
/* Relocation Entries */
141
 
142
typedef struct elf_internal_rel {
143
  bfd_vma       r_offset;       /* Location at which to apply the action */
144
  /* This needs to support 64-bit values in elf64.  */
145
  bfd_vma       r_info;         /* index and type of relocation */
146
} Elf_Internal_Rel;
147
 
148
#define elf32_internal_rel elf_internal_rel
149
#define Elf32_Internal_Rel Elf_Internal_Rel
150
#define elf64_internal_rel elf_internal_rel
151
#define Elf64_Internal_Rel Elf_Internal_Rel
152
 
153
typedef struct elf_internal_rela {
154
  bfd_vma       r_offset;       /* Location at which to apply the action */
155
  bfd_vma       r_info;         /* Index and Type of relocation */
156
  bfd_signed_vma r_addend;      /* Constant addend used to compute value */
157
} Elf_Internal_Rela;
158
 
159
#define elf32_internal_rela elf_internal_rela
160
#define elf64_internal_rela elf_internal_rela
161
#define Elf32_Internal_Rela Elf_Internal_Rela
162
#define Elf64_Internal_Rela Elf_Internal_Rela
163
 
164
/* dynamic section structure */
165
 
166
typedef struct elf_internal_dyn {
167
  /* This needs to support 64-bit values in elf64.  */
168
  bfd_vma d_tag;                /* entry tag value */
169
  union {
170
    /* This needs to support 64-bit values in elf64.  */
171
    bfd_vma     d_val;
172
    bfd_vma     d_ptr;
173
  } d_un;
174
} Elf_Internal_Dyn;
175
 
176
#define elf32_internal_dyn elf_internal_dyn
177
#define elf64_internal_dyn elf_internal_dyn
178
#define Elf32_Internal_Dyn Elf_Internal_Dyn
179
#define Elf64_Internal_Dyn Elf_Internal_Dyn
180
 
181
/* This structure appears in a SHT_GNU_verdef section.  */
182
 
183
typedef struct elf_internal_verdef {
184
  unsigned short vd_version;    /* Version number of structure.  */
185
  unsigned short vd_flags;      /* Flags (VER_FLG_*).  */
186
  unsigned short vd_ndx;        /* Version index.  */
187
  unsigned short vd_cnt;        /* Number of verdaux entries.  */
188
  unsigned long  vd_hash;       /* Hash of name.  */
189
  unsigned long  vd_aux;        /* Offset to verdaux entries.  */
190
  unsigned long  vd_next;       /* Offset to next verdef.  */
191
 
192
  /* These fields are set up when BFD reads in the structure.  FIXME:
193
     It would be cleaner to store these in a different structure.  */
194
  bfd                         *vd_bfd;          /* BFD.  */
195
  const char                  *vd_nodename;     /* Version name.  */
196
  struct elf_internal_verdef  *vd_nextdef;      /* vd_next as pointer.  */
197
  struct elf_internal_verdaux *vd_auxptr;       /* vd_aux as pointer.  */
198
  unsigned int                 vd_exp_refno;    /* Used by the linker.  */
199
} Elf_Internal_Verdef;
200
 
201
/* This structure appears in a SHT_GNU_verdef section.  */
202
 
203
typedef struct elf_internal_verdaux {
204
  unsigned long vda_name;       /* String table offset of name.  */
205
  unsigned long vda_next;       /* Offset to next verdaux.  */
206
 
207
  /* These fields are set up when BFD reads in the structure.  FIXME:
208
     It would be cleaner to store these in a different structure.  */
209
  const char *vda_nodename;                     /* vda_name as pointer.  */
210
  struct elf_internal_verdaux *vda_nextptr;     /* vda_next as pointer.  */
211
} Elf_Internal_Verdaux;
212
 
213
/* This structure appears in a SHT_GNU_verneed section.  */
214
 
215
typedef struct elf_internal_verneed {
216
  unsigned short vn_version;    /* Version number of structure.  */
217
  unsigned short vn_cnt;        /* Number of vernaux entries.  */
218
  unsigned long  vn_file;       /* String table offset of library name.  */
219
  unsigned long  vn_aux;        /* Offset to vernaux entries.  */
220
  unsigned long  vn_next;       /* Offset to next verneed.  */
221
 
222
  /* These fields are set up when BFD reads in the structure.  FIXME:
223
     It would be cleaner to store these in a different structure.  */
224
  bfd                         *vn_bfd;          /* BFD.  */
225
  const char                  *vn_filename;     /* vn_file as pointer.  */
226
  struct elf_internal_vernaux *vn_auxptr;       /* vn_aux as pointer.  */
227
  struct elf_internal_verneed *vn_nextref;      /* vn_nextref as pointer.  */
228
} Elf_Internal_Verneed;
229
 
230
/* This structure appears in a SHT_GNU_verneed section.  */
231
 
232
typedef struct elf_internal_vernaux {
233
  unsigned long  vna_hash;      /* Hash of dependency name.  */
234
  unsigned short vna_flags;     /* Flags (VER_FLG_*).  */
235
  unsigned short vna_other;     /* Unused.  */
236
  unsigned long  vna_name;      /* String table offset to version name.  */
237
  unsigned long  vna_next;      /* Offset to next vernaux.  */
238
 
239
  /* These fields are set up when BFD reads in the structure.  FIXME:
240
     It would be cleaner to store these in a different structure.  */
241
  const char                  *vna_nodename;    /* vna_name as pointer.  */
242
  struct elf_internal_vernaux *vna_nextptr;     /* vna_next as pointer.  */
243
} Elf_Internal_Vernaux;
244
 
245
/* This structure appears in a SHT_GNU_versym section.  This is not a
246
   standard ELF structure; ELF just uses Elf32_Half.  */
247
 
248
typedef struct elf_internal_versym {
249
  unsigned short vs_vers;
250
} Elf_Internal_Versym;
251
 
252
/* Structure for syminfo section.  */
253
typedef struct
254
{
255
  unsigned short int    si_boundto;
256
  unsigned short int    si_flags;
257
} Elf_Internal_Syminfo;
258
 
259
 
260
#define elf32_internal_verdef elf_internal_verdef
261
#define elf64_internal_verdef elf_internal_verdef
262
#define elf32_internal_verdaux elf_internal_verdaux
263
#define elf64_internal_verdaux elf_internal_verdaux
264
#define elf32_internal_verneed elf_internal_verneed
265
#define elf64_internal_verneed elf_internal_verneed
266
#define elf32_internal_vernaux elf_internal_vernaux
267
#define elf64_internal_vernaux elf_internal_vernaux
268
#define elf32_internal_versym elf_internal_versym
269
#define elf64_internal_versym elf_internal_versym
270
 
271
#define Elf32_Internal_Verdef Elf_Internal_Verdef
272
#define Elf64_Internal_Verdef Elf_Internal_Verdef
273
#define Elf32_Internal_Verdaux Elf_Internal_Verdaux
274
#define Elf64_Internal_Verdaux Elf_Internal_Verdaux
275
#define Elf32_Internal_Verneed Elf_Internal_Verneed
276
#define Elf64_Internal_Verneed Elf_Internal_Verneed
277
#define Elf32_Internal_Vernaux Elf_Internal_Vernaux
278
#define Elf64_Internal_Vernaux Elf_Internal_Vernaux
279
#define Elf32_Internal_Versym Elf_Internal_Versym
280
#define Elf64_Internal_Versym Elf_Internal_Versym
281
#define Elf32_Internal_Syminfo Elf_Internal_Syminfo
282
#define Elf64_Internal_Syminfo Elf_Internal_Syminfo
283
 
284
/* This structure is used to describe how sections should be assigned
285
   to program segments.  */
286
 
287
struct elf_segment_map
288
{
289
  /* Next program segment.  */
290
  struct elf_segment_map *next;
291
  /* Program segment type.  */
292
  unsigned long p_type;
293
  /* Program segment flags.  */
294
  unsigned long p_flags;
295
  /* Program segment physical address.  */
296
  bfd_vma p_paddr;
297
  /* Whether the p_flags field is valid; if not, the flags are based
298
     on the section flags.  */
299
  unsigned int p_flags_valid : 1;
300
  /* Whether the p_paddr field is valid; if not, the physical address
301
     is based on the section lma values.  */
302
  unsigned int p_paddr_valid : 1;
303
  /* Whether this segment includes the file header.  */
304
  unsigned int includes_filehdr : 1;
305
  /* Whether this segment includes the program headers.  */
306
  unsigned int includes_phdrs : 1;
307
  /* Number of sections (may be 0).  */
308
  unsigned int count;
309
  /* Sections.  Actual number of elements is in count field.  */
310
  asection *sections[1];
311
};
312
 
313
#endif /* _ELF_INTERNAL_H */

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.