home *** CD-ROM | disk | FTP | other *** search
/ Geek Gadgets 1 / ADE-1.bin / ade-dist / binutils-2.7-src.tgz / tar.out / fsf / binutils / bfd / libamiga.h < prev    next >
C/C++ Source or Header  |  1996-09-28  |  6KB  |  209 lines

  1. /* BFD back-end data structures for AmigaOS.
  2.    Copyright (C) 1992-1994 Free Software Foundation, Inc.
  3.    Contributed by Leonard Norrgard.
  4.    Extended by Stephan Thesing Nov 94
  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., 675 Mass Ave, Cambridge, MA 02139, USA.  */
  21.  
  22. #ifdef __STDC__
  23. #define CAT3(a,b,c) a##b##c
  24. #else
  25. #define CAT3(a,b,c) a/**/b/**/c
  26. #endif
  27.  
  28. #define GET_WORD bfd_h_get_32
  29. #define GET_SWORD (int32_type)GET_WORD
  30. #define PUT_WORD bfd_h_put_32
  31. #define NAME(x,y) CAT3(x,_32_,y)
  32. #define JNAME(x) CAT(x,_32)
  33. #define BYTES_IN_WORD 4
  34.  
  35. /* Hunk ID numbers.*/  
  36. #define HUNK_UNIT        999
  37. #define HUNK_NAME        1000
  38. #define HUNK_CODE        1001
  39. #define HUNK_DATA        1002
  40. #define HUNK_BSS        1003
  41. #define HUNK_RELOC32        1004
  42. #define HUNK_ABSRELOC32        HUNK_RELOC32
  43. #define HUNK_RELOC16        1005
  44. #define HUNK_RELRELOC16        HUNK_RELOC16
  45. #define HUNK_RELOC8        1006
  46. #define HUNK_RELRELOC8        HUNK_RELOC8
  47. #define HUNK_EXT        1007
  48. #define HUNK_SYMBOL        1008
  49. #define HUNK_DEBUG        1009
  50. #define HUNK_END        1010
  51. #define HUNK_HEADER        1011
  52. #define HUNK_OVERLAY        1013
  53. #define HUNK_BREAK        1014
  54. #define HUNK_DREL32        1015
  55. #define HUNK_DREL16        1016
  56. #define HUNK_DREL8        1017
  57. #define HUNK_LIB        1018
  58. #define HUNK_INDEX        1019
  59. #define HUNK_RELOC32SHORT    1020
  60. #define HUNK_RELRELOC32        1021
  61. #define HUNK_ABSRELOC16        1022
  62.  
  63. /* The hunk ID part.  */
  64.  
  65. #define HUNK_VALUE(hunk_id)    ((hunk_id) & 0x3fffffff)
  66.  
  67. /* Attributes of a hunk.  */
  68.  
  69. #define HUNK_ATTRIBUTE(hunk_id)    ((hunk_id) >> 30)
  70. #define HUNK_ATTR_CHIP         0x01    /* Hunk contents must go into chip ram.  */
  71. #define HUNK_ATTR_FAST        0x02    /* fast */
  72. #define HUNK_ATTR_FOLLOWS    0x03    /* Mem id follows */
  73.  
  74. #define EXT_SYMB        0
  75. #define EXT_DEF            1
  76. #define EXT_ABS            2
  77. #define EXT_RES            3
  78. #define EXT_REF32        129
  79. #define EXT_ABSREF32        EXT_REF32
  80. #define EXT_COMMON        130
  81. #define EXT_ABSCOMMON        EXT_COMMON
  82. #define EXT_REF16        131
  83. #define EXT_RELREF16        EXT_REF16
  84. #define EXT_REF8        132
  85. #define EXT_RELREF8        EXT_REF8
  86. #define EXT_DEXT32        133
  87. #define EXT_DREF32        EXT_DEXT32
  88. #define EXT_DEXT16        134
  89. #define EXT_DREF16        EXT_DEXT16
  90. #define EXT_DEXT8        135
  91. #define EXT_DREF8        EXT_DEXT8
  92. #define EXT_RELREF32        136
  93. #define EXT_RELCOMMON        137
  94. #define EXT_ABSREF16        138
  95. #define EXT_ABSREF8        139
  96.  
  97.  
  98. typedef struct amiga_reloc {
  99.   arelent relent;
  100.   struct amiga_reloc *next;
  101.   struct amiga_symbol *symbol;
  102.   long target_hunk;
  103. } amiga_reloc_type;
  104.  
  105. typedef struct amiga_symbol {
  106.   asymbol symbol;
  107.   struct amiga_symbol *next;
  108.   long hunk_number;
  109.   unsigned char type;
  110. } amiga_symbol_type;
  111.  
  112. struct amiga_raw_symbol {
  113.   struct amiga_raw_symbol *next;
  114.   unsigned long data[1];
  115. };
  116.  
  117. typedef struct amiga_per_section
  118. {
  119.   amiga_reloc_type *reloc_tail; /* last reloc */ /* first is in section->relocation */
  120.   int attribute; /* Memory type required by this section */
  121.   int real_length; /* This is the length, occuring in the hunk */
  122.                    /* _raw_size may be larger than this */
  123.   int max_raw_relocs; /* Size of array */
  124.   int num_raw_relocs; /* # of relocs, this points to : */
  125.   unsigned long  **raw_relocs; /* Points to array of raw_relocs */
  126.                              /* every array element points to the raw data */
  127.   struct amiga_raw_symbol *first;
  128.   struct amiga_raw_symbol *last; /* tail */
  129.   
  130. } amiga_per_section_type;
  131. #define amiga_per_section(x) ((amiga_per_section_type *)((x)->used_by_bfd))
  132.  
  133. /* The `tdata' struct for all a.out-like object file formats.
  134.    Various things depend on this struct being around any time an a.out
  135.    file is being handled.  An example is dbxread.c in GDB.  */
  136.  
  137. struct amiga_data {
  138.   struct internal_exec *hdr;        /* exec file header */
  139.   amiga_symbol_type *symbols;        /* symtab for input bfd */
  140.  
  141.   /* Filler, so we can pretend to be an a.out to GDB.  */
  142.   asection *textsec;
  143.   asection *datasec;
  144.   asection *bsssec;
  145.  
  146.   /* The positions of the string table and symbol table.  */
  147.   file_ptr sym_filepos;
  148.   file_ptr str_filepos;
  149.  
  150.   unsigned int n_symbols;               /* number of symbols */
  151.  
  152.   /* Size of a relocation entry in external form */
  153.   unsigned dummy_reloc_entry_size;
  154.  
  155.   /* Size of a symbol table entry in external form */
  156.   unsigned symbol_entry_size;
  157.  
  158.   unsigned exec_bytes_size;
  159.   unsigned vma_adjusted : 1;
  160. };
  161.  
  162. typedef struct  amiga_data_struct {
  163.   struct amiga_data a;
  164.  
  165.   unsigned long symtab_size;
  166.   unsigned long stringtab_size;
  167.  
  168.   unsigned long *first_byte;
  169.   unsigned long *file_end;
  170.   unsigned long *file_pointer;
  171.   amiga_symbol_type *symbols;
  172.   amiga_symbol_type *symbol_tail;
  173.   boolean IsLoadFile; /* If true, this is a load file (for output bfd only) */
  174.   int maxsymbols;     /* Used by final_link routine to add symbols to output bfd.
  175.                          This is the # of entries, allocated in abdfd->osymbols */
  176.   /* The two following fields are set at final_link time
  177.      for the output bfd only */
  178.   boolean baserel;    /* true if there is ___init_a4 in the global hash table */
  179.   bfd_vma a4init;     /* cache the value for efficiency */
  180. } amiga_data_type;
  181.  
  182. #define    adata(bfd)        ((bfd)->tdata.amiga_data->a)
  183.  
  184. /* We take the address of the first element of an asymbol to ensure that the
  185.    macro is only ever applied to an asymbol */
  186. #define amiga_symbol(asymbol) ((amiga_symbol_type *)(&(asymbol)->the_bfd))
  187.  
  188. #define AMIGA_DATA(abfd) ((abfd)->tdata.amiga_data)
  189.  
  190. #define HUNKB_ADVISORY        29
  191. #define HUNKB_CHIP        30
  192. #define HUNKB_FAST        31
  193. #define HUNKF_ADVISORY        (1L << HUNKB_ADVISORY)
  194. #define HUNKF_CHIP        (1L << HUNKB_CHIP)
  195. #define HUNKF_FAST        (1L << HUNKB_FAST)
  196.  
  197. #define MEMF_ANY        (0L)
  198. #define MEMF_PUBLIC        (1L << 0)
  199. #define MEMF_CHIP        (1L << 1)
  200. #define MEMF_FAST        (1L << 2)
  201. #define MEMF_LOCAL        (1L << 8)
  202. #define MEMF_24BITDMA        (1L << 9)
  203. #define    MEMF_KICK        (1L << 10)
  204. #define MEMF_CLEAR        (1L << 16)
  205. #define MEMF_LARGEST        (1L << 17)
  206. #define MEMF_REVERSE        (1L << 18)
  207. #define MEMF_TOTAL        (1L << 19)
  208. #define    MEMF_NO_EXPUNGE        (1L << 31)
  209.