Subversion Repositories Kolibri OS

Rev

Rev 5197 | Blame | Compare with Previous | Last modification | View Log | RSS feed

  1. /* BFD back-end data structures for a.out (and similar) files.
  2.    Copyright (C) 1990-2015 Free Software Foundation, Inc.
  3.    Written by Cygnus Support.
  4.  
  5.    This file is part of BFD, the Binary File Descriptor library.
  6.  
  7.    This program is free software; you can redistribute it and/or modify
  8.    it under the terms of the GNU General Public License as published by
  9.    the Free Software Foundation; either version 3 of the License, or
  10.    (at your option) any later version.
  11.  
  12.    This program is distributed in the hope that it will be useful,
  13.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  14.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15.    GNU General Public License for more details.
  16.  
  17.    You should have received a copy of the GNU General Public License
  18.    along with this program; if not, write to the Free Software
  19.    Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
  20.    MA 02110-1301, USA.  */
  21.  
  22. #ifndef LIBAOUT_H
  23. #define LIBAOUT_H
  24.  
  25. /* We try to encapsulate the differences in the various a.out file
  26.    variants in a few routines, and otherwise share large masses of code.
  27.    This means we only have to fix bugs in one place, most of the time.  */
  28.  
  29. #include "bfdlink.h"
  30.  
  31. /* Macros for accessing components in an aout header.  */
  32.  
  33. #define H_PUT_64  bfd_h_put_64
  34. #define H_PUT_32  bfd_h_put_32
  35. #define H_PUT_16  bfd_h_put_16
  36. #define H_PUT_8   bfd_h_put_8
  37. #define H_PUT_S64 bfd_h_put_signed_64
  38. #define H_PUT_S32 bfd_h_put_signed_32
  39. #define H_PUT_S16 bfd_h_put_signed_16
  40. #define H_PUT_S8  bfd_h_put_signed_8
  41. #define H_GET_64  bfd_h_get_64
  42. #define H_GET_32  bfd_h_get_32
  43. #define H_GET_16  bfd_h_get_16
  44. #define H_GET_8   bfd_h_get_8
  45. #define H_GET_S64 bfd_h_get_signed_64
  46. #define H_GET_S32 bfd_h_get_signed_32
  47. #define H_GET_S16 bfd_h_get_signed_16
  48. #define H_GET_S8  bfd_h_get_signed_8
  49.  
  50. /* Parameterize the a.out code based on whether it is being built
  51.    for a 32-bit architecture or a 64-bit architecture.  */
  52. /* Do not "beautify" the CONCAT* macro args.  Traditional C will not
  53.    remove whitespace added here, and thus will fail to concatenate
  54.    the tokens.  */
  55. #if ARCH_SIZE==64
  56. #define GET_WORD  H_GET_64
  57. #define GET_SWORD H_GET_S64
  58. #define GET_MAGIC H_GET_32
  59. #define PUT_WORD  H_PUT_64
  60. #define PUT_MAGIC H_PUT_32
  61. #ifndef NAME
  62. #define NAME(x,y) CONCAT3 (x,_64_,y)
  63. #endif
  64. #define JNAME(x) CONCAT2 (x,_64)
  65. #define BYTES_IN_WORD 8
  66. #else
  67. #if ARCH_SIZE==16
  68. #define GET_WORD  H_GET_16
  69. #define GET_SWORD H_GET_S16
  70. #define GET_MAGIC H_GET_16
  71. #define PUT_WORD  H_PUT_16
  72. #define PUT_MAGIC H_PUT_16
  73. #ifndef NAME
  74. #define NAME(x,y) CONCAT3 (x,_16_,y)
  75. #endif
  76. #define JNAME(x) CONCAT2 (x,_16)
  77. #define BYTES_IN_WORD 2
  78. #else /* ARCH_SIZE == 32 */
  79. #define GET_WORD  H_GET_32
  80. #define GET_SWORD H_GET_S32
  81. #define GET_MAGIC H_GET_32
  82. #define PUT_WORD  H_PUT_32
  83. #define PUT_MAGIC H_PUT_32
  84. #ifndef NAME
  85. #define NAME(x,y) CONCAT3 (x,_32_,y)
  86. #endif
  87. #define JNAME(x) CONCAT2 (x,_32)
  88. #define BYTES_IN_WORD 4
  89. #endif /* ARCH_SIZE==32 */
  90. #endif /* ARCH_SIZE==64 */
  91.  
  92. /* Declare at file level, since used in parameter lists, which have
  93.    weird scope.  */
  94. struct external_exec;
  95. struct external_nlist;
  96. struct reloc_ext_external;
  97. struct reloc_std_external;
  98. /* a.out backend linker hash table entries.  */
  99.  
  100. struct aout_link_hash_entry
  101. {
  102.   struct bfd_link_hash_entry root;
  103.   /* Whether this symbol has been written out.  */
  104.   bfd_boolean written;
  105.   /* Symbol index in output file.  */
  106.   int indx;
  107. };
  108.  
  109. /* a.out backend linker hash table.  */
  110.  
  111. struct aout_link_hash_table
  112. {
  113.   struct bfd_link_hash_table root;
  114. };
  115.  
  116. /* Look up an entry in an a.out link hash table.  */
  117.  
  118. #define aout_link_hash_lookup(table, string, create, copy, follow) \
  119.   ((struct aout_link_hash_entry *) \
  120.    bfd_link_hash_lookup (&(table)->root, (string), (create), (copy), (follow)))
  121.  
  122. /* Traverse an a.out link hash table.  */
  123.  
  124. #define aout_link_hash_traverse(table, func, info)                      \
  125.   (bfd_link_hash_traverse                                               \
  126.    (&(table)->root,                                                     \
  127.     (bfd_boolean (*) (struct bfd_link_hash_entry *, void *)) (func),    \
  128.     (info)))
  129.  
  130. /* Get the a.out link hash table from the info structure.  This is
  131.    just a cast.  */
  132.  
  133. #define aout_hash_table(p) ((struct aout_link_hash_table *) ((p)->hash))
  134. /* Back-end information for various a.out targets.  */
  135. struct aout_backend_data
  136. {
  137.   /* Are ZMAGIC files mapped contiguously?  If so, the text section may
  138.      need more padding, if the segment size (granularity for memory access
  139.      control) is larger than the page size.  */
  140.   unsigned char zmagic_mapped_contiguous;
  141.   /* If this flag is set, ZMAGIC/NMAGIC file headers get mapped in with the
  142.      text section, which starts immediately after the file header.
  143.      If not, the text section starts on the next page.  */
  144.   unsigned char text_includes_header;
  145.  
  146.   /* If this flag is set, then if the entry address is not in the
  147.      first SEGMENT_SIZE bytes of the text section, it is taken to be
  148.      the address of the start of the text section.  This can be useful
  149.      for kernels.  */
  150.   unsigned char entry_is_text_address;
  151.  
  152.   /* The value to pass to N_SET_FLAGS.  */
  153.   unsigned char exec_hdr_flags;
  154.  
  155.   /* If the text section VMA isn't specified, and we need an absolute
  156.      address, use this as the default.  If we're producing a relocatable
  157.      file, zero is always used.  */
  158.   /* ?? Perhaps a callback would be a better choice?  Will this do anything
  159.      reasonable for a format that handles multiple CPUs with different
  160.      load addresses for each?  */
  161.   bfd_vma default_text_vma;
  162.  
  163.   /* Callback for setting the page and segment sizes, if they can't be
  164.      trivially determined from the architecture.  */
  165.   bfd_boolean (*set_sizes) (bfd *);
  166.  
  167.   /* zmagic files only. For go32, the length of the exec header contributes
  168.      to the size of the text section in the file for alignment purposes but
  169.      does *not* get counted in the length of the text section. */
  170.   unsigned char exec_header_not_counted;
  171.  
  172.   /* Callback from the add symbols phase of the linker code to handle
  173.      a dynamic object.  */
  174.   bfd_boolean (*add_dynamic_symbols)
  175.     (bfd *, struct bfd_link_info *, struct external_nlist **,
  176.      bfd_size_type *, char **);
  177.  
  178.   /* Callback from the add symbols phase of the linker code to handle
  179.      adding a single symbol to the global linker hash table.  */
  180.   bfd_boolean (*add_one_symbol)
  181.     (struct bfd_link_info *, bfd *, const char *, flagword,
  182.      asection *, bfd_vma, const char *, bfd_boolean, bfd_boolean,
  183.      struct bfd_link_hash_entry **);
  184.  
  185.   /* Called to handle linking a dynamic object.  */
  186.   bfd_boolean (*link_dynamic_object)
  187.     (struct bfd_link_info *, bfd *);
  188.  
  189.   /* Called for each global symbol being written out by the linker.
  190.      This should write out the dynamic symbol information.  */
  191.   bfd_boolean (*write_dynamic_symbol)
  192.     (bfd *, struct bfd_link_info *, struct aout_link_hash_entry *);
  193.  
  194.   /* If this callback is not NULL, the linker calls it for each reloc.
  195.      RELOC is a pointer to the unswapped reloc.  If *SKIP is set to
  196.      TRUE, the reloc will be skipped.  *RELOCATION may be changed to
  197.      change the effects of the relocation.  */
  198.   bfd_boolean (*check_dynamic_reloc)
  199.     (struct bfd_link_info *info, bfd *input_bfd,
  200.      asection *input_section, struct aout_link_hash_entry *h,
  201.      void * reloc, bfd_byte *contents, bfd_boolean *skip,
  202.      bfd_vma *relocation);
  203.  
  204.   /* Called at the end of a link to finish up any dynamic linking
  205.      information.  */
  206.   bfd_boolean (*finish_dynamic_link) (bfd *, struct bfd_link_info *);
  207. };
  208. #define aout_backend_info(abfd) \
  209.         ((const struct aout_backend_data *)((abfd)->xvec->backend_data))
  210.  
  211. /* This is the layout in memory of a "struct exec" while we process it.
  212.    All 'lengths' are given as a number of bytes.
  213.    All 'alignments' are for relinkable files only;  an alignment of
  214.         'n' indicates the corresponding segment must begin at an
  215.         address that is a multiple of (2**n).  */
  216.  
  217. struct internal_exec
  218. {
  219.   long a_info;                  /* Magic number and flags, packed.  */
  220.   bfd_vma a_text;               /* Length of text, in bytes.  */
  221.   bfd_vma a_data;               /* Length of data, in bytes.  */
  222.   bfd_vma a_bss;                /* Length of uninitialized data area in mem.  */
  223.   bfd_vma a_syms;               /* Length of symbol table data in file.  */
  224.   bfd_vma a_entry;              /* Start address.  */
  225.   bfd_vma a_trsize;             /* Length of text's relocation info, in bytes.  */
  226.   bfd_vma a_drsize;             /* Length of data's relocation info, in bytes.  */
  227.   /* Added for i960 */
  228.   bfd_vma a_tload;              /* Text runtime load address.  */
  229.   bfd_vma a_dload;              /* Data runtime load address.  */
  230.   unsigned char a_talign;       /* Alignment of text segment.  */
  231.   unsigned char a_dalign;       /* Alignment of data segment.  */
  232.   unsigned char a_balign;       /* Alignment of bss segment.  */
  233.   char a_relaxable;             /* Enough info for linker relax.  */
  234. };
  235.  
  236. /* Magic number is written
  237.    < MSB          >
  238.    3130292827262524232221201918171615141312111009080706050403020100
  239.    < FLAGS        >< MACHINE TYPE ><  MAGIC NUMBER                >  */
  240.  
  241. /* Magic number for NetBSD is
  242.    <MSB           >
  243.    3130292827262524232221201918171615141312111009080706050403020100
  244.    < FLAGS    >< MACHINE TYPE     ><  MAGIC NUMBER                >  */
  245.  
  246. enum machine_type
  247. {
  248.   M_UNKNOWN = 0,
  249.   M_68010 = 1,
  250.   M_68020 = 2,
  251.   M_SPARC = 3,
  252.   /* Skip a bunch so we don't run into any of SUN's numbers.  */
  253.   /* Make these up for the ns32k.  */
  254.   M_NS32032 = (64),       /* NS32032 running ?  */
  255.   M_NS32532 = (64 + 5),   /* NS32532 running mach.  */
  256.   M_386 = 100,
  257.   M_29K = 101,            /* AMD 29000.  */
  258.   M_386_DYNIX = 102,      /* Sequent running dynix.  */
  259.   M_ARM = 103,            /* Advanced Risc Machines ARM.  */
  260.   M_SPARCLET = 131,       /* SPARClet = M_SPARC + 128.  */
  261.   M_386_NETBSD = 134,     /* NetBSD/i386 binary.  */
  262.   M_68K_NETBSD = 135,     /* NetBSD/m68k binary.  */
  263.   M_68K4K_NETBSD = 136,   /* NetBSD/m68k4k binary.  */
  264.   M_532_NETBSD = 137,     /* NetBSD/ns32k binary.  */
  265.   M_SPARC_NETBSD = 138,   /* NetBSD/sparc binary.  */
  266.   M_PMAX_NETBSD = 139,    /* NetBSD/pmax (MIPS little-endian) binary.  */
  267.   M_VAX_NETBSD = 140,     /* NetBSD/vax binary.  */
  268.   M_ALPHA_NETBSD = 141,   /* NetBSD/alpha binary.  */
  269.   M_ARM6_NETBSD = 143,    /* NetBSD/arm32 binary.  */
  270.   M_SPARCLET_1 = 147,     /* 0x93, reserved.  */
  271.   M_POWERPC_NETBSD = 149, /* NetBSD/powerpc (big-endian) binary.  */
  272.   M_VAX4K_NETBSD = 150,   /* NetBSD/vax 4K pages binary.  */
  273.   M_MIPS1 = 151,          /* MIPS R2000/R3000 binary.  */
  274.   M_MIPS2 = 152,          /* MIPS R4000/R6000 binary.  */
  275.   M_88K_OPENBSD = 153,    /* OpenBSD/m88k binary.  */
  276.   M_HPPA_OPENBSD = 154,   /* OpenBSD/hppa binary.  */
  277.   M_SPARC64_NETBSD = 156, /* NetBSD/sparc64 binary.  */
  278.   M_X86_64_NETBSD = 157,  /* NetBSD/amd64 binary.  */
  279.   M_SPARCLET_2 = 163,     /* 0xa3, reserved.  */
  280.   M_SPARCLET_3 = 179,     /* 0xb3, reserved.  */
  281.   M_SPARCLET_4 = 195,     /* 0xc3, reserved.  */
  282.   M_HP200 = 200,          /* HP 200 (68010) BSD binary.  */
  283.   M_HP300 = (300 % 256),  /* HP 300 (68020+68881) BSD binary.  */
  284.   M_HPUX = (0x20c % 256), /* HP 200/300 HPUX binary.  */
  285.   M_SPARCLET_5 = 211,     /* 0xd3, reserved.  */
  286.   M_SPARCLET_6 = 227,     /* 0xe3, reserved.  */
  287. /*M_SPARCLET_7 = 243     / * 0xf3, reserved.  */
  288.   M_SPARCLITE_LE = 243,
  289.   M_CRIS = 255            /* Axis CRIS binary.  */
  290. };
  291.  
  292. #define N_DYNAMIC(exec) ((exec).a_info & 0x80000000)
  293.  
  294. #ifndef N_MAGIC
  295. # define N_MAGIC(exec) ((exec).a_info & 0xffff)
  296. #endif
  297.  
  298. #ifndef N_MACHTYPE
  299. # define N_MACHTYPE(exec) ((enum machine_type)(((exec).a_info >> 16) & 0xff))
  300. #endif
  301.  
  302. #ifndef N_FLAGS
  303. # define N_FLAGS(exec) (((exec).a_info >> 24) & 0xff)
  304. #endif
  305.  
  306. #ifndef N_SET_INFO
  307. # define N_SET_INFO(exec, magic, type, flags) \
  308. ((exec).a_info = ((magic) & 0xffff) \
  309.  | (((int)(type) & 0xff) << 16) \
  310.  | (((flags) & 0xff) << 24))
  311. #endif
  312.  
  313. #ifndef N_SET_DYNAMIC
  314. # define N_SET_DYNAMIC(exec, dynamic) \
  315. ((exec).a_info = (dynamic) ? (long) ((exec).a_info | 0x80000000) : \
  316. ((exec).a_info & 0x7fffffff))
  317. #endif
  318.  
  319. #ifndef N_SET_MAGIC
  320. # define N_SET_MAGIC(exec, magic) \
  321. ((exec).a_info = (((exec).a_info & 0xffff0000) | ((magic) & 0xffff)))
  322. #endif
  323.  
  324. #ifndef N_SET_MACHTYPE
  325. # define N_SET_MACHTYPE(exec, machtype) \
  326. ((exec).a_info = \
  327.  ((exec).a_info&0xff00ffff) | ((((int)(machtype))&0xff) << 16))
  328. #endif
  329.  
  330. #ifndef N_SET_FLAGS
  331. # define N_SET_FLAGS(exec, flags) \
  332. ((exec).a_info = \
  333.  ((exec).a_info&0x00ffffff) | (((flags) & 0xff) << 24))
  334. #endif
  335.  
  336. typedef struct aout_symbol
  337. {
  338.   asymbol symbol;
  339.   short desc;
  340.   char other;
  341.   unsigned char type;
  342. } aout_symbol_type;
  343.  
  344. /* The `tdata' struct for all a.out-like object file formats.
  345.    Various things depend on this struct being around any time an a.out
  346.    file is being handled.  An example is dbxread.c in GDB.  */
  347.  
  348. enum aout_subformat {
  349.   default_format = 0,
  350.   /* Used on HP 9000/300 running HP/UX.  See hp300hpux.c.  */
  351.   gnu_encap_format,
  352.   /* Used on Linux, 386BSD, etc.  See include/aout/aout64.h.  */
  353.   q_magic_format
  354. };
  355.  
  356. enum aout_magic {
  357.   undecided_magic = 0,
  358.   z_magic,
  359.   o_magic,
  360.   n_magic
  361. };
  362.  
  363. struct aoutdata
  364. {
  365.   struct internal_exec *hdr;            /* Exec file header.  */
  366.   aout_symbol_type *symbols;            /* Symtab for input bfd.  */
  367.  
  368.   /* For ease, we do this.  */
  369.   asection *textsec;
  370.   asection *datasec;
  371.   asection *bsssec;
  372.  
  373.   /* We remember these offsets so that after check_file_format, we have
  374.      no dependencies on the particular format of the exec_hdr.  */
  375.   file_ptr sym_filepos;
  376.   file_ptr str_filepos;
  377.  
  378.   /* Size of a relocation entry in external form.  */
  379.   unsigned reloc_entry_size;
  380.  
  381.   /* Size of a symbol table entry in external form.  */
  382.   unsigned symbol_entry_size;
  383.  
  384.   /* Page size - needed for alignment of demand paged files.  */
  385.   unsigned long page_size;
  386.  
  387.   /* Segment size - needed for alignment of demand paged files.  */
  388.   unsigned long segment_size;
  389.  
  390.   /* Zmagic disk block size - need to align the start of the text
  391.      section in ZMAGIC binaries.  Normally the same as page_size.  */
  392.   unsigned long zmagic_disk_block_size;
  393.  
  394.   unsigned exec_bytes_size;
  395.   unsigned vma_adjusted : 1;
  396.  
  397.   /* Used when a bfd supports several highly similar formats.  */
  398.   enum aout_subformat subformat;
  399.  
  400.   enum aout_magic magic;
  401.  
  402.   /* A buffer for find_nearest_line.  */
  403.   char *line_buf;
  404.  
  405.   /* The external symbol information.  */
  406.   struct external_nlist *external_syms;
  407.   bfd_size_type external_sym_count;
  408.   bfd_window sym_window;
  409.   char *external_strings;
  410.   bfd_size_type external_string_size;
  411.   bfd_window string_window;
  412.   struct aout_link_hash_entry **sym_hashes;
  413.  
  414.   /* A pointer for shared library information.  */
  415.   void * dynamic_info;
  416.  
  417.   /* A mapping from local symbols to offsets into the global offset
  418.      table, used when linking on SunOS.  This is indexed by the symbol
  419.      index.  */
  420.   bfd_vma *local_got_offsets;
  421. };
  422.  
  423. struct  aout_data_struct
  424. {
  425.   struct aoutdata a;
  426.   struct internal_exec e;
  427. };
  428.  
  429. #define adata(bfd)                         ((bfd)->tdata.aout_data->a)
  430. #define exec_hdr(bfd)                      (adata (bfd).hdr)
  431. #define obj_aout_symbols(bfd)              (adata (bfd).symbols)
  432. #define obj_textsec(bfd)                   (adata (bfd).textsec)
  433. #define obj_datasec(bfd)                   (adata (bfd).datasec)
  434. #define obj_bsssec(bfd)                    (adata (bfd).bsssec)
  435. #define obj_sym_filepos(bfd)               (adata (bfd).sym_filepos)
  436. #define obj_str_filepos(bfd)               (adata (bfd).str_filepos)
  437. #define obj_reloc_entry_size(bfd)          (adata (bfd).reloc_entry_size)
  438. #define obj_symbol_entry_size(bfd)         (adata (bfd).symbol_entry_size)
  439. #define obj_aout_subformat(bfd)            (adata (bfd).subformat)
  440. #define obj_aout_external_syms(bfd)        (adata (bfd).external_syms)
  441. #define obj_aout_external_sym_count(bfd)   (adata (bfd).external_sym_count)
  442. #define obj_aout_sym_window(bfd)           (adata (bfd).sym_window)
  443. #define obj_aout_external_strings(bfd)     (adata (bfd).external_strings)
  444. #define obj_aout_external_string_size(bfd) (adata (bfd).external_string_size)
  445. #define obj_aout_string_window(bfd)        (adata (bfd).string_window)
  446. #define obj_aout_sym_hashes(bfd)           (adata (bfd).sym_hashes)
  447. #define obj_aout_dynamic_info(bfd)         (adata (bfd).dynamic_info)
  448.  
  449. /* We take the address of the first element of an asymbol to ensure that the
  450.    macro is only ever applied to an asymbol.  */
  451. #define aout_symbol(asymbol) ((aout_symbol_type *)(&(asymbol)->the_bfd))
  452.  
  453. /* Information we keep for each a.out section.  This is currently only
  454.    used by the a.out backend linker.  */
  455.  
  456. struct aout_section_data_struct
  457. {
  458.   /* The unswapped relocation entries for this section.  */
  459.   void * relocs;
  460. };
  461.  
  462. #define aout_section_data(s) \
  463.   ((struct aout_section_data_struct *) (s)->used_by_bfd)
  464.  
  465. #define set_aout_section_data(s,v) \
  466.   ((s)->used_by_bfd = (void *)&(v)->relocs)
  467.  
  468. /* Prototype declarations for functions defined in aoutx.h.  */
  469.  
  470. extern bfd_boolean NAME (aout, squirt_out_relocs)
  471.   (bfd *, asection *);
  472.  
  473. extern bfd_boolean NAME (aout, make_sections)
  474.   (bfd *);
  475.  
  476. extern const bfd_target * NAME (aout, some_aout_object_p)
  477.   (bfd *, struct internal_exec *, const bfd_target *(*) (bfd *));
  478.  
  479. extern bfd_boolean NAME (aout, mkobject)
  480.   (bfd *);
  481.  
  482. extern enum machine_type NAME (aout, machine_type)
  483.   (enum bfd_architecture, unsigned long, bfd_boolean *);
  484.  
  485. extern bfd_boolean NAME (aout, set_arch_mach)
  486.   (bfd *, enum bfd_architecture, unsigned long);
  487.  
  488. extern bfd_boolean NAME (aout, new_section_hook)
  489.   (bfd *, asection *);
  490.  
  491. extern bfd_boolean NAME (aout, set_section_contents)
  492.   (bfd *, sec_ptr, const void *, file_ptr, bfd_size_type);
  493.  
  494. extern asymbol * NAME (aout, make_empty_symbol)
  495.   (bfd *);
  496.  
  497. extern bfd_boolean NAME (aout, translate_symbol_table)
  498.   (bfd *, aout_symbol_type *, struct external_nlist *, bfd_size_type,
  499.            char *, bfd_size_type, bfd_boolean);
  500.  
  501. extern bfd_boolean NAME (aout, slurp_symbol_table)
  502.   (bfd *);
  503.  
  504. extern bfd_boolean NAME (aout, write_syms)
  505.   (bfd *);
  506.  
  507. extern void NAME (aout, reclaim_symbol_table)
  508.   (bfd *);
  509.  
  510. extern long NAME (aout, get_symtab_upper_bound)
  511.   (bfd *);
  512.  
  513. extern long NAME (aout, canonicalize_symtab)
  514.   (bfd *, asymbol **);
  515.  
  516. extern void NAME (aout, swap_ext_reloc_in)
  517.   (bfd *, struct reloc_ext_external *, arelent *, asymbol **,
  518.    bfd_size_type);
  519.  
  520. extern void NAME (aout, swap_std_reloc_in)
  521.   (bfd *, struct reloc_std_external *, arelent *, asymbol **,
  522.    bfd_size_type);
  523.  
  524. extern reloc_howto_type * NAME (aout, reloc_type_lookup)
  525.   (bfd *, bfd_reloc_code_real_type);
  526.  
  527. extern reloc_howto_type * NAME (aout, reloc_name_lookup)
  528.   (bfd *, const char *);
  529.  
  530. extern bfd_boolean NAME (aout, slurp_reloc_table)
  531.   (bfd *, sec_ptr, asymbol **);
  532.  
  533. extern long NAME (aout, canonicalize_reloc)
  534.   (bfd *, sec_ptr, arelent **, asymbol **);
  535.  
  536. extern long NAME (aout, get_reloc_upper_bound)
  537.   (bfd *, sec_ptr);
  538.  
  539. extern void NAME (aout, reclaim_reloc)
  540.   (bfd *, sec_ptr);
  541.  
  542. extern alent * NAME (aout, get_lineno)
  543.   (bfd *, asymbol *);
  544.  
  545. extern void NAME (aout, print_symbol)
  546.   (bfd *, void *, asymbol *, bfd_print_symbol_type);
  547.  
  548. extern void NAME (aout, get_symbol_info)
  549.   (bfd *, asymbol *, symbol_info *);
  550.  
  551. extern bfd_boolean NAME (aout, find_nearest_line)
  552.   (bfd *, asymbol **, asection *, bfd_vma,
  553.    const char **, const char **, unsigned int *, unsigned int *);
  554.  
  555. extern long NAME (aout, read_minisymbols)
  556.   (bfd *, bfd_boolean, void * *, unsigned int *);
  557.  
  558. extern asymbol * NAME (aout, minisymbol_to_symbol)
  559.   (bfd *, bfd_boolean, const void *, asymbol *);
  560.  
  561. extern int NAME (aout, sizeof_headers)
  562.   (bfd *, struct bfd_link_info *);
  563.  
  564. extern bfd_boolean NAME (aout, adjust_sizes_and_vmas)
  565.   (bfd *, bfd_size_type *, file_ptr *);
  566.  
  567. extern void NAME (aout, swap_exec_header_in)
  568.   (bfd *, struct external_exec *, struct internal_exec *);
  569.  
  570. extern void NAME (aout, swap_exec_header_out)
  571.   (bfd *, struct internal_exec *, struct external_exec *);
  572.  
  573. extern struct bfd_hash_entry * NAME (aout, link_hash_newfunc)
  574.   (struct bfd_hash_entry *, struct bfd_hash_table *, const char *);
  575.  
  576. extern bfd_boolean NAME (aout, link_hash_table_init)
  577.   (struct aout_link_hash_table *, bfd *,
  578.    struct bfd_hash_entry *(*) (struct bfd_hash_entry *,
  579.                                struct bfd_hash_table *,
  580.                                const char *),
  581.    unsigned int);
  582.  
  583. extern struct bfd_link_hash_table * NAME (aout, link_hash_table_create)
  584.   (bfd *);
  585.  
  586. extern bfd_boolean NAME (aout, link_add_symbols)
  587.   (bfd *, struct bfd_link_info *);
  588.  
  589. extern bfd_boolean NAME (aout, final_link)
  590.   (bfd *, struct bfd_link_info *,
  591.    void (*) (bfd *, file_ptr *, file_ptr *, file_ptr *));
  592.  
  593. extern bfd_boolean NAME (aout, bfd_free_cached_info)
  594.   (bfd *);
  595.  
  596. #define aout_32_find_inliner_info       _bfd_nosymbols_find_inliner_info
  597. #if 0   /* Are these needed? */
  598. #define aout_16_find_inliner_info       _bfd_nosymbols_find_inliner_info
  599. #define aout_64_find_inliner_info       _bfd_nosymbols_find_inliner_info
  600. #endif
  601.  
  602. /* A.out uses the generic versions of these routines...  */
  603.  
  604. #define aout_16_get_section_contents    _bfd_generic_get_section_contents
  605.  
  606. #define aout_32_get_section_contents    _bfd_generic_get_section_contents
  607.  
  608. #define aout_64_get_section_contents    _bfd_generic_get_section_contents
  609. #ifndef NO_WRITE_HEADER_KLUDGE
  610. #define NO_WRITE_HEADER_KLUDGE 0
  611. #endif
  612.  
  613. #ifndef aout_32_bfd_is_local_label_name
  614. #define aout_32_bfd_is_local_label_name bfd_generic_is_local_label_name
  615. #endif
  616.  
  617. #ifndef aout_32_bfd_is_target_special_symbol
  618. #define aout_32_bfd_is_target_special_symbol \
  619.   ((bfd_boolean (*) (bfd *, asymbol *)) bfd_false)
  620. #endif
  621.  
  622. #ifndef WRITE_HEADERS
  623. #define WRITE_HEADERS(abfd, execp)                                            \
  624.       {                                                                       \
  625.         bfd_size_type text_size; /* Dummy vars.  */                           \
  626.         file_ptr text_end;                                                    \
  627.                                                                               \
  628.         if (adata(abfd).magic == undecided_magic)                             \
  629.           NAME (aout, adjust_sizes_and_vmas) (abfd, & text_size, & text_end); \
  630.                                                                               \
  631.         execp->a_syms = bfd_get_symcount (abfd) * EXTERNAL_NLIST_SIZE;        \
  632.         execp->a_entry = bfd_get_start_address (abfd);                        \
  633.                                                                               \
  634.         execp->a_trsize = ((obj_textsec (abfd)->reloc_count) *                \
  635.                            obj_reloc_entry_size (abfd));                      \
  636.         execp->a_drsize = ((obj_datasec (abfd)->reloc_count) *                \
  637.                            obj_reloc_entry_size (abfd));                      \
  638.         NAME (aout, swap_exec_header_out) (abfd, execp, & exec_bytes);        \
  639.                                                                               \
  640.         if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0                      \
  641.             || bfd_bwrite (& exec_bytes, (bfd_size_type) EXEC_BYTES_SIZE,     \
  642.                           abfd) != EXEC_BYTES_SIZE)                           \
  643.           return FALSE;                                                       \
  644.         /* Now write out reloc info, followed by syms and strings.  */        \
  645.                                                                               \
  646.         if (bfd_get_outsymbols (abfd) != NULL                                 \
  647.             && bfd_get_symcount (abfd) != 0)                                  \
  648.           {                                                                   \
  649.             if (bfd_seek (abfd, (file_ptr) (N_SYMOFF(*execp)), SEEK_SET) != 0)\
  650.               return FALSE;                                                   \
  651.                                                                               \
  652.             if (! NAME (aout, write_syms) (abfd))                             \
  653.               return FALSE;                                                   \
  654.           }                                                                   \
  655.                                                                               \
  656.         if (bfd_seek (abfd, (file_ptr) (N_TRELOFF (*execp)), SEEK_SET) != 0)  \
  657.           return FALSE;                                                       \
  658.         if (!NAME (aout, squirt_out_relocs) (abfd, obj_textsec (abfd)))       \
  659.           return FALSE;                                                       \
  660.                                                                               \
  661.         if (bfd_seek (abfd, (file_ptr) (N_DRELOFF (*execp)), SEEK_SET) != 0)  \
  662.           return FALSE;                                                       \
  663.         if (!NAME (aout, squirt_out_relocs) (abfd, obj_datasec (abfd)))       \
  664.           return FALSE;                                                       \
  665.       }
  666. #endif
  667.  
  668. /* Test if a read-only section can be merged with .text.  This is
  669.    possible if:
  670.  
  671.    1. Section has file contents and is read-only.
  672.    2. The VMA of the section is after the end of .text and before
  673.       the start of .data.
  674.    3. The image is demand-pageable (otherwise, a_text in the header
  675.       will not reflect the gap between .text and .data).  */
  676.  
  677. #define aout_section_merge_with_text_p(abfd, sec)                       \
  678.   (((sec)->flags & (SEC_HAS_CONTENTS | SEC_READONLY)) ==                \
  679.       (SEC_HAS_CONTENTS | SEC_READONLY)                                 \
  680.    && obj_textsec (abfd) != NULL                                        \
  681.    && obj_datasec (abfd) != NULL                                        \
  682.    && (sec)->vma >= (obj_textsec (abfd)->vma +                          \
  683.                      obj_textsec (abfd)->size)                          \
  684.    && ((sec)->vma + (sec)->size) <= obj_datasec (abfd)->vma             \
  685.    && ((abfd)->flags & D_PAGED) != 0)
  686.  
  687. #endif /* ! defined (LIBAOUT_H) */
  688.