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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [insight/] [include/] [coff/] [xcoff.h] - Blame information for rev 1767

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

Line No. Rev Author Line
1 578 markom
/* Internal format of XCOFF object file data structures for BFD.
2
 
3
   Copyright 1995, 1996, 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
4
   Written by Ian Lance Taylor <ian@cygnus.com>, Cygnus Support.
5
 
6
   This file is part of BFD, the Binary File Descriptor library.
7
 
8
   This program is free software; you can redistribute it and/or modify
9
   it under the terms of the GNU General Public License as published by
10
   the Free Software Foundation; either version 2 of the License, or
11
   (at your option) any later version.
12
 
13
   This program is distributed in the hope that it will be useful,
14
   but WITHOUT ANY WARRANTY; without even the implied warranty of
15
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
   GNU General Public License for more details.
17
 
18
   You should have received a copy of the GNU General Public License
19
   along with this program; if not, write to the Free Software
20
   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
21
 
22
#ifndef _INTERNAL_XCOFF_H
23
#define _INTERNAL_XCOFF_H
24
 
25
/*
26
 * LINKER
27
 */
28
 
29
/*
30
 * names of "special" sections
31
 */
32
#define _TEXT   ".text"
33
#define _DATA   ".data"
34
#define _BSS    ".bss"
35
#define _PAD    ".pad"
36
#define _LOADER ".loader"
37
 
38
/* XCOFF uses a special .loader section with type STYP_LOADER.  */
39
#define STYP_LOADER 0x1000
40
 
41
/* XCOFF uses a special .debug section with type STYP_DEBUG.  */
42
#define STYP_DEBUG 0x2000
43
 
44
/* XCOFF handles line number or relocation overflow by creating
45
   another section header with STYP_OVRFLO set.  */
46
#define STYP_OVRFLO 0x8000
47
 
48
#define RS6K_AOUTHDR_OMAGIC 0x0107 /* old: text & data writeable */
49
#define RS6K_AOUTHDR_NMAGIC 0x0108 /* new: text r/o, data r/w */
50
#define RS6K_AOUTHDR_ZMAGIC 0x010B /* paged: text r/o, both page-aligned */
51
 
52
 
53
/* XCOFF relocation types.
54
   The relocations are described in the function
55
   xcoff[64]_ppc_relocate_section in coff64-rs6000.c and coff-rs6000.c  */
56
 
57
#define R_POS   (0x00)
58
#define R_NEG   (0x01)
59
#define R_REL   (0x02)
60
#define R_TOC   (0x03)
61
#define R_RTB   (0x04)
62
#define R_GL    (0x05)
63
#define R_TCL   (0x06)
64
#define R_BA    (0x08)
65
#define R_BR    (0x0a)
66
#define R_RL    (0x0c)
67
#define R_RLA   (0x0d)
68
#define R_REF   (0x0f)
69
#define R_TRL   (0x12)
70
#define R_TRLA  (0x13)
71
#define R_RRTBI (0x14)
72
#define R_RRTBA (0x15)
73
#define R_CAI   (0x16)
74
#define R_CREL  (0x17)
75
#define R_RBA   (0x18)
76
#define R_RBAC  (0x19)
77
#define R_RBR   (0x1a)
78
#define R_RBRC  (0x1b)
79
 
80
 
81
/*
82
 * Storage class #defines, from /usr/include/storclass.h
83
 * That are not already defined in internal.h
84
 */
85
#define C_INFO          110     /* Comment string in .info section */
86
 
87
 
88
/*
89
 * AUXILLARY SYMBOL ENTRIES
90
 *
91
 * auxemt
92
 */
93
 
94
/* x_smtyp values:  */
95
 
96
#define SMTYP_ALIGN(x)  ((x) >> 3)      /* log2 of alignment */
97
#define SMTYP_SMTYP(x)  ((x) & 0x7)     /* symbol type */
98
/* Symbol type values:  */
99
#define XTY_ER  0                /* External reference */
100
#define XTY_SD  1               /* Csect definition */
101
#define XTY_LD  2               /* Label definition */
102
#define XTY_CM  3               /* .BSS */
103
#define XTY_EM  4               /* Error message */
104
#define XTY_US  5               /* "Reserved for internal use" */
105
 
106
/* x_smclas values:  */
107
 
108
#define XMC_PR  0                /* Read-only program code */
109
#define XMC_RO  1               /* Read-only constant */
110
#define XMC_DB  2               /* Read-only debug dictionary table */
111
#define XMC_TC  3               /* Read-write general TOC entry */
112
#define XMC_UA  4               /* Read-write unclassified */
113
#define XMC_RW  5               /* Read-write data */
114
#define XMC_GL  6               /* Read-only global linkage */
115
#define XMC_XO  7               /* Read-only extended operation */
116
#define XMC_SV  8               /* Read-only supervisor call */
117
#define XMC_BS  9               /* Read-write BSS */
118
#define XMC_DS  10              /* Read-write descriptor csect */
119
#define XMC_UC  11              /* Read-write unnamed Fortran common */
120
#define XMC_TI  12              /* Read-only traceback index csect */
121
#define XMC_TB  13              /* Read-only traceback table csect */
122
/*              14      ??? */
123
#define XMC_TC0 15              /* Read-write TOC anchor */
124
#define XMC_TD  16              /* Read-write data in TOC */
125
 
126
/* The ldhdr structure.  This appears at the start of the .loader
127
   section.  */
128
 
129
struct internal_ldhdr
130
{
131
  /*
132
   * The version number:
133
   * 1 : 32 bit
134
   * 2 : 64 bit
135
   */
136
  unsigned long l_version;
137
  /* The number of symbol table entries.  */
138
  bfd_size_type l_nsyms;
139
  /* The number of relocation table entries.  */
140
  bfd_size_type l_nreloc;
141
  /* The length of the import file string table.  */
142
  bfd_size_type l_istlen;
143
  /* The number of import files.  */
144
  bfd_size_type l_nimpid;
145
  /* The offset from the start of the .loader section to the first
146
     entry in the import file table.  */
147
  bfd_size_type l_impoff;
148
  /* The length of the string table.  */
149
  bfd_size_type l_stlen;
150
  /* The offset from the start of the .loader section to the first
151
     entry in the string table.  */
152
  bfd_size_type l_stoff;
153
  /* The offset to start of the symbol table, only in XCOFF64 */
154
  bfd_vma l_symoff;
155
  /* The offset to the start of the relocation table, only in XCOFF64 */
156
  bfd_vma l_rldoff;
157
};
158
 
159
/* The ldsym structure.  This is used to represent a symbol in the
160
   .loader section.  */
161
 
162
struct internal_ldsym
163
{
164
  union
165
    {
166
      /* The symbol name if <= SYMNMLEN characters.  */
167
      char _l_name[SYMNMLEN];
168
      struct
169
        {
170
          /* Zero if the symbol name is more than SYMNMLEN characters.  */
171
          long _l_zeroes;
172
          /* The offset in the string table if the symbol name is more
173
             than SYMNMLEN characters.  */
174
          long _l_offset;
175
        } _l_l;
176
    } _l;
177
  /* The symbol value.  */
178
  bfd_vma l_value;
179
  /* The symbol section number.  */
180
  short l_scnum;
181
  /* The symbol type and flags.  */
182
  char l_smtype;
183
  /* The symbol storage class.  */
184
  char l_smclas;
185
  /* The import file ID.  */
186
  bfd_size_type l_ifile;
187
  /* Offset to the parameter type check string.  */
188
  bfd_size_type l_parm;
189
};
190
 
191
/* These flags are for the l_smtype field (the lower three bits are an
192
   XTY_* value).  */
193
 
194
/* Imported symbol.  */
195
#define L_IMPORT (0x40)
196
/* Entry point.  */
197
#define L_ENTRY (0x20)
198
/* Exported symbol.  */
199
#define L_EXPORT (0x10)
200
 
201
/* The ldrel structure.  This is used to represent a reloc in the
202
   .loader section.  */
203
 
204
struct internal_ldrel
205
{
206
  /* The reloc address.  */
207
  bfd_vma l_vaddr;
208
  /* The symbol table index in the .loader section symbol table.  */
209
  bfd_size_type l_symndx;
210
  /* The relocation type and size.  */
211
  short l_rtype;
212
  /* The section number this relocation applies to.  */
213
  short l_rsecnm;
214
};
215
 
216
/* An entry in the XCOFF linker hash table.  */
217
struct xcoff_link_hash_entry
218
{
219
  struct bfd_link_hash_entry root;
220
 
221
  /* Symbol index in output file.  Set to -1 initially.  Set to -2 if
222
     there is a reloc against this symbol.  */
223
  long indx;
224
 
225
  /* If we have created a TOC entry for this symbol, this is the .tc
226
     section which holds it.  */
227
  asection *toc_section;
228
 
229
  union
230
    {
231
      /* If we have created a TOC entry (the XCOFF_SET_TOC flag is
232
         set), this is the offset in toc_section.  */
233
      bfd_vma toc_offset;
234
      /* If the TOC entry comes from an input file, this is set to the
235
         symbol index of the C_HIDEXT XMC_TC or XMC_TD symbol.  */
236
      long toc_indx;
237
    } u;
238
 
239
  /* If this symbol is a function entry point which is called, this
240
     field holds a pointer to the function descriptor.  If this symbol
241
     is a function descriptor, this field holds a pointer to the
242
     function entry point.  */
243
  struct xcoff_link_hash_entry *descriptor;
244
 
245
  /* The .loader symbol table entry, if there is one.  */
246
  struct internal_ldsym *ldsym;
247
 
248
  /* If XCOFF_BUILT_LDSYM is set, this is the .loader symbol table
249
     index.  If XCOFF_BUILD_LDSYM is clear, and XCOFF_IMPORT is set,
250
     this is the l_ifile value.  */
251
  long ldindx;
252
 
253
  /* Some linker flags.  */
254
  unsigned long flags;
255
 
256
  /* The storage mapping class.  */
257
  unsigned char smclas;
258
};
259
 
260
/*
261
 * #define for xcoff_link_hash_entry.flags
262
 *
263
 * XCOFF_REF_REGULAR
264
 * Symbol is referenced by a regular object.
265
 *
266
 * XCOFF_DEF_REGULAR
267
 * Symbol is defined by a regular object.
268
 *
269
 * XCOFF_DEF_DYNAMIC
270
 * Symbol is defined by a dynamic object.
271
 *
272
 * XCOFF_LDREL
273
 * Symbol is used in a reloc being copied into the .loader section.
274
 *
275
 * XCOFF_ENTRY
276
 * Symbol is the entry point.
277
 *
278
 * XCOFF_CALLED
279
 * Symbol is called; this is, it appears in a R_BR reloc.
280
 *
281
 * XCOFF_SET_TOC
282
 * Symbol needs the TOC entry filled in.
283
 *
284
 * XCOFF_IMPORT
285
 * Symbol is explicitly imported.
286
 *
287
 * XCOFF_EXPORT
288
 * Symbol is explicitly exported.
289
 *
290
 * XCOFF_BUILT_LDSYM
291
 * Symbol has been processed by xcoff_build_ldsyms.
292
 *
293
 * XCOFF_MARK
294
 * Symbol is mentioned by a section which was not garbage collected.
295
 *
296
 * XCOFF_HAS_SIZE
297
 * Symbol size is recorded in size_list list from hash table.
298
 *
299
 * XCOFF_DESCRIPTOR
300
 * Symbol is a function descriptor.
301
 *
302
 * XCOFF_MULTIPLY_DEFINED
303
 * Multiple definitions have been for the symbol.
304
 *
305
 * XCOFF_RTINIT
306
 * Symbol is the __rtinit symbol
307
 *
308
 */
309
 
310
#define XCOFF_REF_REGULAR      0x00000001
311
#define XCOFF_DEF_REGULAR      0x00000002
312
#define XCOFF_DEF_DYNAMIC      0x00000004
313
#define XCOFF_LDREL            0x00000008
314
#define XCOFF_ENTRY            0x00000010
315
#define XCOFF_CALLED           0x00000020
316
#define XCOFF_SET_TOC          0x00000040
317
#define XCOFF_IMPORT           0x00000080
318
#define XCOFF_EXPORT           0x00000100
319
#define XCOFF_BUILT_LDSYM      0x00000200
320
#define XCOFF_MARK             0x00000400
321
#define XCOFF_HAS_SIZE         0x00000800
322
#define XCOFF_DESCRIPTOR       0x00001000
323
#define XCOFF_MULTIPLY_DEFINED 0x00002000
324
#define XCOFF_RTINIT           0x00004000
325
 
326
 
327
/* The XCOFF linker hash table.  */
328
 
329
#define XCOFF_NUMBER_OF_SPECIAL_SECTIONS 6
330
#define XCOFF_SPECIAL_SECTION_TEXT       0
331
#define XCOFF_SPECIAL_SECTION_ETEXT      1 
332
#define XCOFF_SPECIAL_SECTION_DATA       2
333
#define XCOFF_SPECIAL_SECTION_EDATA      3
334
#define XCOFF_SPECIAL_SECTION_END        4
335
#define XCOFF_SPECIAL_SECTION_END2       5
336
 
337
struct xcoff_link_hash_table
338
{
339
  struct bfd_link_hash_table root;
340
 
341
  /* The .debug string hash table.  We need to compute this while
342
     reading the input files, so that we know how large the .debug
343
     section will be before we assign section positions.  */
344
  struct bfd_strtab_hash *debug_strtab;
345
 
346
  /* The .debug section we will use for the final output.  */
347
  asection *debug_section;
348
 
349
  /* The .loader section we will use for the final output.  */
350
  asection *loader_section;
351
 
352
  /* A count of non TOC relative relocs which will need to be
353
     allocated in the .loader section.  */
354
  size_t ldrel_count;
355
 
356
  /* The .loader section header.  */
357
  struct internal_ldhdr ldhdr;
358
 
359
  /* The .gl section we use to hold global linkage code.  */
360
  asection *linkage_section;
361
 
362
  /* The .tc section we use to hold toc entries we build for global
363
     linkage code.  */
364
  asection *toc_section;
365
 
366
  /* The .ds section we use to hold function descriptors which we
367
     create for exported symbols.  */
368
  asection *descriptor_section;
369
 
370
  /* The list of import files.  */
371
  struct xcoff_import_file *imports;
372
 
373
  /* Required alignment of sections within the output file.  */
374
  unsigned long file_align;
375
 
376
  /* Whether the .text section must be read-only.  */
377
  boolean textro;
378
 
379
  /* Whether garbage collection was done.  */
380
  boolean gc;
381
 
382
  /* A linked list of symbols for which we have size information.  */
383
  struct xcoff_link_size_list
384
    {
385
      struct xcoff_link_size_list *next;
386
      struct xcoff_link_hash_entry *h;
387
      bfd_size_type size;
388
    } *size_list;
389
 
390
  /* Magic sections: _text, _etext, _data, _edata, _end, end. */
391
  asection *special_sections[XCOFF_NUMBER_OF_SPECIAL_SECTIONS];
392
};
393
 
394
 
395
/* This structure is used to pass information through
396
   xcoff_link_hash_traverse.  */
397
 
398
struct xcoff_loader_info
399
{
400
  /* Set if a problem occurred.  */
401
  boolean failed;
402
  /* Output BFD.  */
403
  bfd *output_bfd;
404
  /* Link information structure.  */
405
  struct bfd_link_info *info;
406
  /* Whether all defined symbols should be exported.  */
407
  boolean export_defineds;
408
  /* Number of ldsym structures.  */
409
  size_t ldsym_count;
410
  /* Size of string table.  */
411
  size_t string_size;
412
  /* String table.  */
413
  bfd_byte *strings;
414
  /* Allocated size of string table.  */
415
  size_t string_alc;
416
};
417
 
418
/* In case we're on a 32-bit machine, construct a 64-bit "-1" value
419
   from smaller values.  Start with zero, widen, *then* decrement.  */
420
#define MINUS_ONE       (((bfd_vma)0) - 1)
421
 
422
 
423
/*
424
 * __rtinit
425
 * from /usr/include/rtinit.h
426
 */
427
struct __rtinit {
428
  int           (*rtl)();               /* Pointer to runtime linker */
429
  int           init_offset;            /* Offset to array of init functions
430
                                           (0 if none). */
431
  int           fini_offset;            /* Offset to array of fini functions
432
                                           (0 if none). */
433
  int           __rtinit_descriptor_size; /* Size of __RTINIT_DESCRIPTOR.
434
                                             This value should be used instead
435
                                             of sizeof(__RTINIT_DESCRIPTOR). */
436
};
437
 
438
#define RTINIT_DESCRIPTOR_SIZE (12)
439
 
440
struct __rtinit_descriptor {
441
  int   f;              /* Init/fini function. */
442
  int                   name_offset;    /* Offset (within __rtinit symbol)
443
                                           to name of function. */
444
  unsigned char flags;          /* Flags */
445
};
446
 
447
 
448
 
449
/*
450
 * ARCHIVE
451
 */
452
 
453
#define XCOFFARMAG    "<aiaff>\012"
454
#define XCOFFARMAGBIG "<bigaf>\012"
455
#define SXCOFFARMAG   8
456
 
457
/* This terminates an XCOFF archive member name.  */
458
 
459
#define XCOFFARFMAG "`\012"
460
#define SXCOFFARFMAG 2
461
 
462
/* XCOFF archives start with this (printable) structure.  */
463
 
464
struct xcoff_ar_file_hdr
465
{
466
  /* Magic string.  */
467
  char magic[SXCOFFARMAG];
468
 
469
  /* Offset of the member table (decimal ASCII string).  */
470
  char memoff[12];
471
 
472
  /* Offset of the global symbol table (decimal ASCII string).  */
473
  char symoff[12];
474
 
475
  /* Offset of the first member in the archive (decimal ASCII string).  */
476
  char firstmemoff[12];
477
 
478
  /* Offset of the last member in the archive (decimal ASCII string).  */
479
  char lastmemoff[12];
480
 
481
  /* Offset of the first member on the free list (decimal ASCII
482
     string).  */
483
  char freeoff[12];
484
};
485
 
486
#define SIZEOF_AR_FILE_HDR (5 * 12 + SXCOFFARMAG)
487
 
488
/* This is the equivalent data structure for the big archive format.  */
489
 
490
struct xcoff_ar_file_hdr_big
491
{
492
  /* Magic string.  */
493
  char magic[SXCOFFARMAG];
494
 
495
  /* Offset of the member table (decimal ASCII string).  */
496
  char memoff[20];
497
 
498
  /* Offset of the global symbol table for 32-bit objects (decimal ASCII
499
     string).  */
500
  char symoff[20];
501
 
502
  /* Offset of the global symbol table for 64-bit objects (decimal ASCII
503
     string).  */
504
  char symoff64[20];
505
 
506
  /* Offset of the first member in the archive (decimal ASCII string).  */
507
  char firstmemoff[20];
508
 
509
  /* Offset of the last member in the archive (decimal ASCII string).  */
510
  char lastmemoff[20];
511
 
512
  /* Offset of the first member on the free list (decimal ASCII
513
     string).  */
514
  char freeoff[20];
515
};
516
 
517
#define SIZEOF_AR_FILE_HDR_BIG (6 * 20 + SXCOFFARMAG)
518
 
519
 
520
/* Each XCOFF archive member starts with this (printable) structure.  */
521
 
522
struct xcoff_ar_hdr
523
{
524
  /* File size not including the header (decimal ASCII string).  */
525
  char size[12];
526
 
527
  /* File offset of next archive member (decimal ASCII string).  */
528
  char nextoff[12];
529
 
530
  /* File offset of previous archive member (decimal ASCII string).  */
531
  char prevoff[12];
532
 
533
  /* File mtime (decimal ASCII string).  */
534
  char date[12];
535
 
536
  /* File UID (decimal ASCII string).  */
537
  char uid[12];
538
 
539
  /* File GID (decimal ASCII string).  */
540
  char gid[12];
541
 
542
  /* File mode (octal ASCII string).  */
543
  char mode[12];
544
 
545
  /* Length of file name (decimal ASCII string).  */
546
  char namlen[4];
547
 
548
  /* This structure is followed by the file name.  The length of the
549
     name is given in the namlen field.  If the length of the name is
550
     odd, the name is followed by a null byte.  The name and optional
551
     null byte are followed by XCOFFARFMAG, which is not included in
552
     namlen.  The contents of the archive member follow; the number of
553
     bytes is given in the size field.  */
554
};
555
 
556
#define SIZEOF_AR_HDR (7 * 12 + 4)
557
 
558
/* The equivalent for the big archive format.  */
559
 
560
struct xcoff_ar_hdr_big
561
{
562
  /* File size not including the header (decimal ASCII string).  */
563
  char size[20];
564
 
565
  /* File offset of next archive member (decimal ASCII string).  */
566
  char nextoff[20];
567
 
568
  /* File offset of previous archive member (decimal ASCII string).  */
569
  char prevoff[20];
570
 
571
  /* File mtime (decimal ASCII string).  */
572
  char date[12];
573
 
574
  /* File UID (decimal ASCII string).  */
575
  char uid[12];
576
 
577
  /* File GID (decimal ASCII string).  */
578
  char gid[12];
579
 
580
  /* File mode (octal ASCII string).  */
581
  char mode[12];
582
 
583
  /* Length of file name (decimal ASCII string).  */
584
  char namlen[4];
585
 
586
  /* This structure is followed by the file name.  The length of the
587
     name is given in the namlen field.  If the length of the name is
588
     odd, the name is followed by a null byte.  The name and optional
589
     null byte are followed by XCOFFARFMAG, which is not included in
590
     namlen.  The contents of the archive member follow; the number of
591
     bytes is given in the size field.  */
592
};
593
 
594
#define SIZEOF_AR_HDR_BIG (3 * 20 + 4 * 12 + 4)
595
 
596
/* We often have to distinguish between the old and big file format.
597
   Make it a bit cleaner.  We can use `xcoff_ardata' here because the
598
   `hdr' member has the same size and position in both formats.  */
599
#define xcoff_big_format_p(abfd) \
600
  (xcoff_ardata (abfd)->magic[1] == 'b')
601
 
602
/* We store a copy of the xcoff_ar_file_hdr in the tdata field of the
603
   artdata structure.  Similar for the big archive.  */
604
#define xcoff_ardata(abfd) \
605
  ((struct xcoff_ar_file_hdr *) bfd_ardata (abfd)->tdata)
606
#define xcoff_ardata_big(abfd) \
607
  ((struct xcoff_ar_file_hdr_big *) bfd_ardata (abfd)->tdata)
608
 
609
/* We store a copy of the xcoff_ar_hdr in the arelt_data field of an
610
   archive element.  Similar for the big archive.  */
611
#define arch_eltdata(bfd) ((struct areltdata *) ((bfd)->arelt_data))
612
#define arch_xhdr(bfd) \
613
  ((struct xcoff_ar_hdr *) arch_eltdata (bfd)->arch_header)
614
#define arch_xhdr_big(bfd) \
615
  ((struct xcoff_ar_hdr_big *) arch_eltdata (bfd)->arch_header)
616
 
617
#endif /* _INTERNAL_XCOFF_H */

powered by: WebSVN 2.1.0

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