xref: /netbsd-src/external/gpl3/binutils.old/dist/bfd/aout-target.h (revision e992f068c547fd6e84b3f104dc2340adcc955732)
175fd0b74Schristos /* Define a target vector and some small routines for a variant of a.out.
2*e992f068Schristos    Copyright (C) 1990-2022 Free Software Foundation, Inc.
375fd0b74Schristos 
475fd0b74Schristos    This file is part of BFD, the Binary File Descriptor library.
575fd0b74Schristos 
675fd0b74Schristos    This program is free software; you can redistribute it and/or modify
775fd0b74Schristos    it under the terms of the GNU General Public License as published by
875fd0b74Schristos    the Free Software Foundation; either version 3 of the License, or
975fd0b74Schristos    (at your option) any later version.
1075fd0b74Schristos 
1175fd0b74Schristos    This program is distributed in the hope that it will be useful,
1275fd0b74Schristos    but WITHOUT ANY WARRANTY; without even the implied warranty of
1375fd0b74Schristos    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1475fd0b74Schristos    GNU General Public License for more details.
1575fd0b74Schristos 
1675fd0b74Schristos    You should have received a copy of the GNU General Public License
1775fd0b74Schristos    along with this program; if not, write to the Free Software
1875fd0b74Schristos    Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
1975fd0b74Schristos    MA 02110-1301, USA.  */
2075fd0b74Schristos 
2175fd0b74Schristos #include "aout/aout64.h"
2275fd0b74Schristos #include "aout/stab_gnu.h"
2375fd0b74Schristos #include "aout/ar.h"
2475fd0b74Schristos /*#include "libaout.h"*/
2575fd0b74Schristos 
2675fd0b74Schristos #ifndef SEGMENT_SIZE
2775fd0b74Schristos #define SEGMENT_SIZE TARGET_PAGE_SIZE
2875fd0b74Schristos #endif
2975fd0b74Schristos 
3075fd0b74Schristos extern reloc_howto_type * NAME (aout, reloc_type_lookup) (bfd *, bfd_reloc_code_real_type);
3175fd0b74Schristos extern reloc_howto_type * NAME (aout, reloc_name_lookup) (bfd *, const char *);
3275fd0b74Schristos 
3375fd0b74Schristos /* Set parameters about this a.out file that are machine-dependent.
3475fd0b74Schristos    This routine is called from some_aout_object_p just before it returns.  */
3575fd0b74Schristos #ifndef MY_callback
3675fd0b74Schristos 
37*e992f068Schristos static bfd_cleanup
MY(callback)3875fd0b74Schristos MY (callback) (bfd *abfd)
3975fd0b74Schristos {
4075fd0b74Schristos   struct internal_exec *execp = exec_hdr (abfd);
4175fd0b74Schristos   unsigned int arch_align_power;
4275fd0b74Schristos   unsigned long arch_align;
4375fd0b74Schristos 
4475fd0b74Schristos   /* Calculate the file positions of the parts of a newly read aout header.  */
4575fd0b74Schristos   obj_textsec (abfd)->size = N_TXTSIZE (execp);
4675fd0b74Schristos 
4775fd0b74Schristos   /* The virtual memory addresses of the sections.  */
4875fd0b74Schristos   obj_textsec (abfd)->vma = N_TXTADDR (execp);
4975fd0b74Schristos   obj_datasec (abfd)->vma = N_DATADDR (execp);
5075fd0b74Schristos   obj_bsssec  (abfd)->vma = N_BSSADDR (execp);
5175fd0b74Schristos 
5275fd0b74Schristos   /* For some targets, if the entry point is not in the same page
5375fd0b74Schristos      as the start of the text, then adjust the VMA so that it is.
5475fd0b74Schristos      FIXME: Do this with a macro like SET_ARCH_MACH instead?  */
5575fd0b74Schristos   if (aout_backend_info (abfd)->entry_is_text_address
5675fd0b74Schristos       && execp->a_entry > obj_textsec (abfd)->vma)
5775fd0b74Schristos     {
5875fd0b74Schristos       bfd_vma adjust;
5975fd0b74Schristos 
6075fd0b74Schristos       adjust = execp->a_entry - obj_textsec (abfd)->vma;
6175fd0b74Schristos       /* Adjust only by whole pages.  */
6275fd0b74Schristos       adjust &= ~(TARGET_PAGE_SIZE - 1);
6375fd0b74Schristos       obj_textsec (abfd)->vma += adjust;
6475fd0b74Schristos       obj_datasec (abfd)->vma += adjust;
6575fd0b74Schristos       obj_bsssec (abfd)->vma += adjust;
6675fd0b74Schristos     }
6775fd0b74Schristos 
6875fd0b74Schristos   /* Set the load addresses to be the same as the virtual addresses.  */
6975fd0b74Schristos   obj_textsec (abfd)->lma = obj_textsec (abfd)->vma;
7075fd0b74Schristos   obj_datasec (abfd)->lma = obj_datasec (abfd)->vma;
7175fd0b74Schristos   obj_bsssec (abfd)->lma = obj_bsssec (abfd)->vma;
7275fd0b74Schristos 
7375fd0b74Schristos   /* The file offsets of the sections.  */
7475fd0b74Schristos   obj_textsec (abfd)->filepos = N_TXTOFF (execp);
7575fd0b74Schristos   obj_datasec (abfd)->filepos = N_DATOFF (execp);
7675fd0b74Schristos 
7775fd0b74Schristos   /* The file offsets of the relocation info.  */
7875fd0b74Schristos   obj_textsec (abfd)->rel_filepos = N_TRELOFF (execp);
7975fd0b74Schristos   obj_datasec (abfd)->rel_filepos = N_DRELOFF (execp);
8075fd0b74Schristos 
8175fd0b74Schristos   /* The file offsets of the string table and symbol table.  */
8275fd0b74Schristos   obj_sym_filepos (abfd) = N_SYMOFF (execp);
8375fd0b74Schristos   obj_str_filepos (abfd) = N_STROFF (execp);
8475fd0b74Schristos 
8575fd0b74Schristos   /* Determine the architecture and machine type of the object file.  */
8675fd0b74Schristos #ifdef SET_ARCH_MACH
8775fd0b74Schristos   SET_ARCH_MACH (abfd, execp);
8875fd0b74Schristos #else
8975fd0b74Schristos   bfd_default_set_arch_mach (abfd, DEFAULT_ARCH, 0);
9075fd0b74Schristos #endif
9175fd0b74Schristos 
9275fd0b74Schristos   /* The number of relocation records.  This must be called after
9375fd0b74Schristos      SET_ARCH_MACH.  It assumes that SET_ARCH_MACH will set
9475fd0b74Schristos      obj_reloc_entry_size correctly, if the reloc size is not
9575fd0b74Schristos      RELOC_STD_SIZE.  */
9675fd0b74Schristos   obj_textsec (abfd)->reloc_count =
9775fd0b74Schristos     execp->a_trsize / obj_reloc_entry_size (abfd);
9875fd0b74Schristos   obj_datasec (abfd)->reloc_count =
9975fd0b74Schristos     execp->a_drsize / obj_reloc_entry_size (abfd);
10075fd0b74Schristos 
10175fd0b74Schristos   /* Now that we know the architecture, set the alignments of the
10275fd0b74Schristos      sections.  This is normally done by NAME (aout,new_section_hook),
10375fd0b74Schristos      but when the initial sections were created the architecture had
10475fd0b74Schristos      not yet been set.  However, for backward compatibility, we don't
10575fd0b74Schristos      set the alignment power any higher than as required by the size
10675fd0b74Schristos      of the section.  */
10775fd0b74Schristos   arch_align_power = bfd_get_arch_info (abfd)->section_align_power;
10875fd0b74Schristos   arch_align = 1 << arch_align_power;
10975fd0b74Schristos   if ((BFD_ALIGN (obj_textsec (abfd)->size, arch_align)
11075fd0b74Schristos        == obj_textsec (abfd)->size)
11175fd0b74Schristos       && (BFD_ALIGN (obj_datasec (abfd)->size, arch_align)
11275fd0b74Schristos 	  == obj_datasec (abfd)->size)
11375fd0b74Schristos       && (BFD_ALIGN (obj_bsssec (abfd)->size, arch_align)
11475fd0b74Schristos 	  == obj_bsssec (abfd)->size))
11575fd0b74Schristos     {
11675fd0b74Schristos       obj_textsec (abfd)->alignment_power = arch_align_power;
11775fd0b74Schristos       obj_datasec (abfd)->alignment_power = arch_align_power;
11875fd0b74Schristos       obj_bsssec (abfd)->alignment_power = arch_align_power;
11975fd0b74Schristos     }
12075fd0b74Schristos 
12175fd0b74Schristos   /* Don't set sizes now -- can't be sure until we know arch & mach.
12275fd0b74Schristos      Sizes get set in set_sizes callback, later.  */
12375fd0b74Schristos 
124*e992f068Schristos   return _bfd_no_cleanup;
12575fd0b74Schristos }
12675fd0b74Schristos #endif
12775fd0b74Schristos 
12875fd0b74Schristos #ifndef MY_object_p
12975fd0b74Schristos /* Finish up the reading of an a.out file header.  */
13075fd0b74Schristos 
131*e992f068Schristos static bfd_cleanup
MY(object_p)13275fd0b74Schristos MY (object_p) (bfd *abfd)
13375fd0b74Schristos {
13475fd0b74Schristos   struct external_exec exec_bytes;	/* Raw exec header from file.  */
13575fd0b74Schristos   struct internal_exec exec;		/* Cleaned-up exec header.  */
136*e992f068Schristos   bfd_cleanup cleanup;
137*e992f068Schristos   size_t amt = EXEC_BYTES_SIZE;
13875fd0b74Schristos 
13975fd0b74Schristos   if (bfd_bread ((void *) &exec_bytes, amt, abfd) != amt)
14075fd0b74Schristos     {
14175fd0b74Schristos       if (bfd_get_error () != bfd_error_system_call)
14275fd0b74Schristos 	bfd_set_error (bfd_error_wrong_format);
14375fd0b74Schristos       return 0;
14475fd0b74Schristos     }
14575fd0b74Schristos 
14675fd0b74Schristos #ifdef SWAP_MAGIC
14775fd0b74Schristos   exec.a_info = SWAP_MAGIC (exec_bytes.e_info);
14875fd0b74Schristos #else
14975fd0b74Schristos   exec.a_info = GET_MAGIC (abfd, exec_bytes.e_info);
15075fd0b74Schristos #endif
15175fd0b74Schristos 
15275fd0b74Schristos   if (N_BADMAG (&exec))
15375fd0b74Schristos     return 0;
15475fd0b74Schristos 
15575fd0b74Schristos #ifdef MACHTYPE_OK
15675fd0b74Schristos   if (!(MACHTYPE_OK (N_MACHTYPE (&exec))))
15775fd0b74Schristos     return 0;
15875fd0b74Schristos #endif
15975fd0b74Schristos 
16075fd0b74Schristos   NAME (aout, swap_exec_header_in) (abfd, &exec_bytes, &exec);
16175fd0b74Schristos 
16275fd0b74Schristos #ifdef SWAP_MAGIC
16375fd0b74Schristos   /* Swap_exec_header_in read in a_info with the wrong byte order.  */
16475fd0b74Schristos   exec.a_info = SWAP_MAGIC (exec_bytes.e_info);
16575fd0b74Schristos #endif
16675fd0b74Schristos 
167*e992f068Schristos   cleanup = NAME (aout, some_aout_object_p) (abfd, &exec, MY (callback));
16875fd0b74Schristos 
16975fd0b74Schristos #ifdef ENTRY_CAN_BE_ZERO
17075fd0b74Schristos   /* The NEWSOS3 entry-point is/was 0, which (amongst other lossage)
17175fd0b74Schristos      means that it isn't obvious if EXEC_P should be set.
17275fd0b74Schristos      All of the following must be true for an executable:
17375fd0b74Schristos      There must be no relocations, the bfd can be neither an
17475fd0b74Schristos      archive nor an archive element, and the file must be executable.  */
17575fd0b74Schristos 
17675fd0b74Schristos   if (exec.a_trsize + exec.a_drsize == 0
17775fd0b74Schristos       && bfd_get_format(abfd) == bfd_object && abfd->my_archive == NULL)
17875fd0b74Schristos     {
17975fd0b74Schristos       struct stat buf;
18075fd0b74Schristos #ifndef S_IXUSR
18175fd0b74Schristos #define S_IXUSR 0100	/* Execute by owner.  */
18275fd0b74Schristos #endif
183*e992f068Schristos       if (stat (bfd_get_filename (abfd), &buf) == 0
184*e992f068Schristos 	  && (buf.st_mode & S_IXUSR) != 0)
18575fd0b74Schristos 	abfd->flags |= EXEC_P;
18675fd0b74Schristos     }
18775fd0b74Schristos #endif /* ENTRY_CAN_BE_ZERO */
18875fd0b74Schristos 
189*e992f068Schristos   return cleanup;
19075fd0b74Schristos }
19175fd0b74Schristos #define MY_object_p MY (object_p)
19275fd0b74Schristos #endif
19375fd0b74Schristos 
19475fd0b74Schristos #ifndef MY_mkobject
19575fd0b74Schristos 
196*e992f068Schristos static bool
MY(mkobject)19775fd0b74Schristos MY (mkobject) (bfd *abfd)
19875fd0b74Schristos {
19975fd0b74Schristos   return NAME (aout, mkobject (abfd));
20075fd0b74Schristos }
20175fd0b74Schristos 
20275fd0b74Schristos #define MY_mkobject MY (mkobject)
20375fd0b74Schristos #endif
20475fd0b74Schristos 
20575fd0b74Schristos #ifndef MY_bfd_copy_private_section_data
20675fd0b74Schristos 
20775fd0b74Schristos /* Copy private section data.  This actually does nothing with the
20875fd0b74Schristos    sections.  It copies the subformat field.  We copy it here, because
20975fd0b74Schristos    we need to know whether this is a QMAGIC file before we set the
21075fd0b74Schristos    section contents, and copy_private_bfd_data is not called until
21175fd0b74Schristos    after the section contents have been set.  */
21275fd0b74Schristos 
213*e992f068Schristos static bool
MY_bfd_copy_private_section_data(bfd * ibfd,asection * isec ATTRIBUTE_UNUSED,bfd * obfd,asection * osec ATTRIBUTE_UNUSED)21475fd0b74Schristos MY_bfd_copy_private_section_data (bfd *ibfd,
21575fd0b74Schristos 				  asection *isec ATTRIBUTE_UNUSED,
21675fd0b74Schristos 				  bfd *obfd,
21775fd0b74Schristos 				  asection *osec ATTRIBUTE_UNUSED)
21875fd0b74Schristos {
21975fd0b74Schristos   if (bfd_get_flavour (ibfd) == bfd_target_aout_flavour
22075fd0b74Schristos       && bfd_get_flavour (obfd) == bfd_target_aout_flavour)
22175fd0b74Schristos     obj_aout_subformat (obfd) = obj_aout_subformat (ibfd);
222*e992f068Schristos   return true;
22375fd0b74Schristos }
22475fd0b74Schristos 
22575fd0b74Schristos #endif
22675fd0b74Schristos 
22775fd0b74Schristos /* Write an object file.
22875fd0b74Schristos    Section contents have already been written.  We write the
22975fd0b74Schristos    file header, symbols, and relocation.  */
23075fd0b74Schristos 
23175fd0b74Schristos #ifndef MY_write_object_contents
23275fd0b74Schristos 
233*e992f068Schristos static bool
MY(write_object_contents)23475fd0b74Schristos MY (write_object_contents) (bfd *abfd)
23575fd0b74Schristos {
23675fd0b74Schristos   struct external_exec exec_bytes;
23775fd0b74Schristos   struct internal_exec *execp = exec_hdr (abfd);
23875fd0b74Schristos 
23975fd0b74Schristos   obj_reloc_entry_size (abfd) = RELOC_STD_SIZE;
24075fd0b74Schristos 
24175fd0b74Schristos   WRITE_HEADERS (abfd, execp);
24275fd0b74Schristos 
243*e992f068Schristos   return true;
24475fd0b74Schristos }
24575fd0b74Schristos #define MY_write_object_contents MY (write_object_contents)
24675fd0b74Schristos #endif
24775fd0b74Schristos 
24875fd0b74Schristos #ifndef MY_set_sizes
24975fd0b74Schristos 
250*e992f068Schristos static bool
MY(set_sizes)25175fd0b74Schristos MY (set_sizes) (bfd *abfd)
25275fd0b74Schristos {
25375fd0b74Schristos   adata(abfd).page_size = TARGET_PAGE_SIZE;
25475fd0b74Schristos   adata(abfd).segment_size = SEGMENT_SIZE;
25575fd0b74Schristos 
25675fd0b74Schristos #ifdef ZMAGIC_DISK_BLOCK_SIZE
25775fd0b74Schristos   adata(abfd).zmagic_disk_block_size = ZMAGIC_DISK_BLOCK_SIZE;
25875fd0b74Schristos #else
25975fd0b74Schristos   adata(abfd).zmagic_disk_block_size = TARGET_PAGE_SIZE;
26075fd0b74Schristos #endif
26175fd0b74Schristos 
26275fd0b74Schristos   adata(abfd).exec_bytes_size = EXEC_BYTES_SIZE;
263*e992f068Schristos   return true;
26475fd0b74Schristos }
26575fd0b74Schristos #define MY_set_sizes MY (set_sizes)
26675fd0b74Schristos #endif
26775fd0b74Schristos 
26875fd0b74Schristos #ifndef MY_exec_hdr_flags
26975fd0b74Schristos #define MY_exec_hdr_flags 0
27075fd0b74Schristos #endif
27175fd0b74Schristos 
27275fd0b74Schristos #ifndef MY_backend_data
27375fd0b74Schristos 
27475fd0b74Schristos #ifndef MY_zmagic_contiguous
27575fd0b74Schristos #define MY_zmagic_contiguous 0
27675fd0b74Schristos #endif
27775fd0b74Schristos #ifndef MY_text_includes_header
27875fd0b74Schristos #define MY_text_includes_header 0
27975fd0b74Schristos #endif
28075fd0b74Schristos #ifndef MY_entry_is_text_address
28175fd0b74Schristos #define MY_entry_is_text_address 0
28275fd0b74Schristos #endif
28375fd0b74Schristos #ifndef MY_exec_header_not_counted
28475fd0b74Schristos #define MY_exec_header_not_counted 0
28575fd0b74Schristos #endif
28675fd0b74Schristos #ifndef MY_add_dynamic_symbols
28775fd0b74Schristos #define MY_add_dynamic_symbols 0
28875fd0b74Schristos #endif
28975fd0b74Schristos #ifndef MY_add_one_symbol
29075fd0b74Schristos #define MY_add_one_symbol 0
29175fd0b74Schristos #endif
29275fd0b74Schristos #ifndef MY_link_dynamic_object
29375fd0b74Schristos #define MY_link_dynamic_object 0
29475fd0b74Schristos #endif
29575fd0b74Schristos #ifndef MY_write_dynamic_symbol
29675fd0b74Schristos #define MY_write_dynamic_symbol 0
29775fd0b74Schristos #endif
29875fd0b74Schristos #ifndef MY_check_dynamic_reloc
29975fd0b74Schristos #define MY_check_dynamic_reloc 0
30075fd0b74Schristos #endif
30175fd0b74Schristos #ifndef MY_finish_dynamic_link
30275fd0b74Schristos #define MY_finish_dynamic_link 0
30375fd0b74Schristos #endif
30475fd0b74Schristos 
30575fd0b74Schristos static const struct aout_backend_data MY (backend_data) =
30675fd0b74Schristos {
30775fd0b74Schristos   MY_zmagic_contiguous,
30875fd0b74Schristos   MY_text_includes_header,
30975fd0b74Schristos   MY_entry_is_text_address,
31075fd0b74Schristos   MY_exec_hdr_flags,
31175fd0b74Schristos   0,				/* Text vma?  */
31275fd0b74Schristos   MY_set_sizes,
31375fd0b74Schristos   MY_exec_header_not_counted,
31475fd0b74Schristos   MY_add_dynamic_symbols,
31575fd0b74Schristos   MY_add_one_symbol,
31675fd0b74Schristos   MY_link_dynamic_object,
31775fd0b74Schristos   MY_write_dynamic_symbol,
31875fd0b74Schristos   MY_check_dynamic_reloc,
31975fd0b74Schristos   MY_finish_dynamic_link
32075fd0b74Schristos };
32175fd0b74Schristos #define MY_backend_data &MY (backend_data)
32275fd0b74Schristos #endif
32375fd0b74Schristos 
32475fd0b74Schristos #ifndef MY_final_link_callback
32575fd0b74Schristos 
32675fd0b74Schristos /* Callback for the final_link routine to set the section offsets.  */
32775fd0b74Schristos 
32875fd0b74Schristos static void
MY_final_link_callback(bfd * abfd,file_ptr * ptreloff,file_ptr * pdreloff,file_ptr * psymoff)32975fd0b74Schristos MY_final_link_callback (bfd *abfd,
33075fd0b74Schristos 			file_ptr *ptreloff,
33175fd0b74Schristos 			file_ptr *pdreloff,
33275fd0b74Schristos 			file_ptr *psymoff)
33375fd0b74Schristos {
33475fd0b74Schristos   struct internal_exec *execp = exec_hdr (abfd);
33575fd0b74Schristos 
33675fd0b74Schristos   *ptreloff = N_TRELOFF (execp);
33775fd0b74Schristos   *pdreloff = N_DRELOFF (execp);
33875fd0b74Schristos   *psymoff = N_SYMOFF (execp);
33975fd0b74Schristos }
34075fd0b74Schristos 
34175fd0b74Schristos #endif
34275fd0b74Schristos 
34375fd0b74Schristos #ifndef MY_bfd_final_link
34475fd0b74Schristos 
34575fd0b74Schristos /* Final link routine.  We need to use a call back to get the correct
34675fd0b74Schristos    offsets in the output file.  */
34775fd0b74Schristos 
348*e992f068Schristos static bool
MY_bfd_final_link(bfd * abfd,struct bfd_link_info * info)34975fd0b74Schristos MY_bfd_final_link (bfd *abfd, struct bfd_link_info *info)
35075fd0b74Schristos {
35175fd0b74Schristos   return NAME (aout, final_link) (abfd, info, MY_final_link_callback);
35275fd0b74Schristos }
35375fd0b74Schristos 
35475fd0b74Schristos #endif
35575fd0b74Schristos 
35675fd0b74Schristos /* We assume BFD generic archive files.  */
35775fd0b74Schristos #ifndef	MY_openr_next_archived_file
35875fd0b74Schristos #define	MY_openr_next_archived_file	bfd_generic_openr_next_archived_file
35975fd0b74Schristos #endif
36075fd0b74Schristos #ifndef MY_get_elt_at_index
36175fd0b74Schristos #define MY_get_elt_at_index		_bfd_generic_get_elt_at_index
36275fd0b74Schristos #endif
36375fd0b74Schristos #ifndef	MY_generic_stat_arch_elt
36475fd0b74Schristos #define	MY_generic_stat_arch_elt	bfd_generic_stat_arch_elt
36575fd0b74Schristos #endif
36675fd0b74Schristos #ifndef	MY_slurp_armap
36775fd0b74Schristos #define	MY_slurp_armap			bfd_slurp_bsd_armap
36875fd0b74Schristos #endif
36975fd0b74Schristos #ifndef	MY_slurp_extended_name_table
37075fd0b74Schristos #define	MY_slurp_extended_name_table	_bfd_slurp_extended_name_table
37175fd0b74Schristos #endif
37275fd0b74Schristos #ifndef MY_construct_extended_name_table
37375fd0b74Schristos #define MY_construct_extended_name_table \
37475fd0b74Schristos   _bfd_archive_bsd_construct_extended_name_table
37575fd0b74Schristos #endif
37675fd0b74Schristos #ifndef	MY_write_armap
377ede78133Schristos #define	MY_write_armap		_bfd_bsd_write_armap
37875fd0b74Schristos #endif
37975fd0b74Schristos #ifndef MY_read_ar_hdr
38075fd0b74Schristos #define MY_read_ar_hdr		_bfd_generic_read_ar_hdr
38175fd0b74Schristos #endif
38275fd0b74Schristos #ifndef MY_write_ar_hdr
38375fd0b74Schristos #define MY_write_ar_hdr		_bfd_generic_write_ar_hdr
38475fd0b74Schristos #endif
38575fd0b74Schristos #ifndef	MY_truncate_arname
38675fd0b74Schristos #define	MY_truncate_arname		bfd_bsd_truncate_arname
38775fd0b74Schristos #endif
38875fd0b74Schristos #ifndef MY_update_armap_timestamp
38975fd0b74Schristos #define MY_update_armap_timestamp _bfd_archive_bsd_update_armap_timestamp
39075fd0b74Schristos #endif
39175fd0b74Schristos 
39275fd0b74Schristos /* No core file defined here -- configure in trad-core.c separately.  */
39375fd0b74Schristos #ifndef	MY_core_file_failing_command
39475fd0b74Schristos #define	MY_core_file_failing_command _bfd_nocore_core_file_failing_command
39575fd0b74Schristos #endif
39675fd0b74Schristos #ifndef	MY_core_file_failing_signal
39775fd0b74Schristos #define	MY_core_file_failing_signal	_bfd_nocore_core_file_failing_signal
39875fd0b74Schristos #endif
39975fd0b74Schristos #ifndef	MY_core_file_matches_executable_p
40075fd0b74Schristos #define	MY_core_file_matches_executable_p	\
40175fd0b74Schristos 				_bfd_nocore_core_file_matches_executable_p
40275fd0b74Schristos #endif
40375fd0b74Schristos #ifndef	MY_core_file_pid
40475fd0b74Schristos #define	MY_core_file_pid _bfd_nocore_core_file_pid
40575fd0b74Schristos #endif
40675fd0b74Schristos #ifndef	MY_core_file_p
40775fd0b74Schristos #define	MY_core_file_p		_bfd_dummy_target
40875fd0b74Schristos #endif
40975fd0b74Schristos 
41075fd0b74Schristos #ifndef MY_bfd_debug_info_start
411ede78133Schristos #define MY_bfd_debug_info_start		_bfd_void_bfd
41275fd0b74Schristos #endif
41375fd0b74Schristos #ifndef MY_bfd_debug_info_end
414ede78133Schristos #define MY_bfd_debug_info_end		_bfd_void_bfd
41575fd0b74Schristos #endif
41675fd0b74Schristos #ifndef MY_bfd_debug_info_accumulate
417ede78133Schristos #define MY_bfd_debug_info_accumulate	_bfd_void_bfd_asection
41875fd0b74Schristos #endif
41975fd0b74Schristos 
42075fd0b74Schristos #ifndef MY_core_file_failing_command
42175fd0b74Schristos #define MY_core_file_failing_command NAME (aout, core_file_failing_command)
42275fd0b74Schristos #endif
42375fd0b74Schristos #ifndef MY_core_file_failing_signal
42475fd0b74Schristos #define MY_core_file_failing_signal NAME (aout, core_file_failing_signal)
42575fd0b74Schristos #endif
42675fd0b74Schristos #ifndef MY_core_file_matches_executable_p
42775fd0b74Schristos #define MY_core_file_matches_executable_p NAME (aout, core_file_matches_executable_p)
42875fd0b74Schristos #endif
42975fd0b74Schristos #ifndef MY_set_section_contents
43075fd0b74Schristos #define MY_set_section_contents NAME (aout, set_section_contents)
43175fd0b74Schristos #endif
43275fd0b74Schristos #ifndef MY_get_section_contents
43375fd0b74Schristos #define MY_get_section_contents NAME (aout, get_section_contents)
43475fd0b74Schristos #endif
43575fd0b74Schristos #ifndef MY_get_section_contents_in_window
43675fd0b74Schristos #define MY_get_section_contents_in_window _bfd_generic_get_section_contents_in_window
43775fd0b74Schristos #endif
43875fd0b74Schristos #ifndef MY_new_section_hook
43975fd0b74Schristos #define MY_new_section_hook NAME (aout, new_section_hook)
44075fd0b74Schristos #endif
44175fd0b74Schristos #ifndef MY_get_symtab_upper_bound
44275fd0b74Schristos #define MY_get_symtab_upper_bound NAME (aout, get_symtab_upper_bound)
44375fd0b74Schristos #endif
44475fd0b74Schristos #ifndef MY_canonicalize_symtab
44575fd0b74Schristos #define MY_canonicalize_symtab NAME (aout, canonicalize_symtab)
44675fd0b74Schristos #endif
44775fd0b74Schristos #ifndef MY_get_reloc_upper_bound
44875fd0b74Schristos #define MY_get_reloc_upper_bound NAME (aout,get_reloc_upper_bound)
44975fd0b74Schristos #endif
45075fd0b74Schristos #ifndef MY_canonicalize_reloc
45175fd0b74Schristos #define MY_canonicalize_reloc NAME (aout, canonicalize_reloc)
45275fd0b74Schristos #endif
453ede78133Schristos #ifndef MY_set_reloc
454ede78133Schristos #define MY_set_reloc _bfd_generic_set_reloc
455ede78133Schristos #endif
45675fd0b74Schristos #ifndef MY_make_empty_symbol
45775fd0b74Schristos #define MY_make_empty_symbol NAME (aout, make_empty_symbol)
45875fd0b74Schristos #endif
45975fd0b74Schristos #ifndef MY_print_symbol
46075fd0b74Schristos #define MY_print_symbol NAME (aout, print_symbol)
46175fd0b74Schristos #endif
46275fd0b74Schristos #ifndef MY_get_symbol_info
46375fd0b74Schristos #define MY_get_symbol_info NAME (aout, get_symbol_info)
46475fd0b74Schristos #endif
46575fd0b74Schristos #ifndef MY_get_symbol_version_string
46675fd0b74Schristos #define MY_get_symbol_version_string \
46775fd0b74Schristos   _bfd_nosymbols_get_symbol_version_string
46875fd0b74Schristos #endif
46975fd0b74Schristos #ifndef MY_get_lineno
47075fd0b74Schristos #define MY_get_lineno NAME (aout, get_lineno)
47175fd0b74Schristos #endif
47275fd0b74Schristos #ifndef MY_set_arch_mach
47375fd0b74Schristos #define MY_set_arch_mach NAME (aout, set_arch_mach)
47475fd0b74Schristos #endif
47575fd0b74Schristos #ifndef MY_find_nearest_line
47675fd0b74Schristos #define MY_find_nearest_line NAME (aout, find_nearest_line)
47775fd0b74Schristos #endif
47875fd0b74Schristos #ifndef MY_find_line
47975fd0b74Schristos #define MY_find_line _bfd_nosymbols_find_line
48075fd0b74Schristos #endif
48175fd0b74Schristos #ifndef MY_find_inliner_info
48275fd0b74Schristos #define MY_find_inliner_info _bfd_nosymbols_find_inliner_info
48375fd0b74Schristos #endif
48475fd0b74Schristos #ifndef MY_sizeof_headers
48575fd0b74Schristos #define MY_sizeof_headers NAME (aout, sizeof_headers)
48675fd0b74Schristos #endif
48775fd0b74Schristos #ifndef MY_bfd_get_relocated_section_contents
48875fd0b74Schristos #define MY_bfd_get_relocated_section_contents \
48975fd0b74Schristos 			bfd_generic_get_relocated_section_contents
49075fd0b74Schristos #endif
49175fd0b74Schristos #ifndef MY_bfd_relax_section
49275fd0b74Schristos #define MY_bfd_relax_section bfd_generic_relax_section
49375fd0b74Schristos #endif
49475fd0b74Schristos #ifndef MY_bfd_gc_sections
49575fd0b74Schristos #define MY_bfd_gc_sections bfd_generic_gc_sections
49675fd0b74Schristos #endif
49775fd0b74Schristos #ifndef MY_bfd_lookup_section_flags
49875fd0b74Schristos #define MY_bfd_lookup_section_flags bfd_generic_lookup_section_flags
49975fd0b74Schristos #endif
50075fd0b74Schristos #ifndef MY_bfd_merge_sections
50175fd0b74Schristos #define MY_bfd_merge_sections bfd_generic_merge_sections
50275fd0b74Schristos #endif
50375fd0b74Schristos #ifndef MY_bfd_is_group_section
50475fd0b74Schristos #define MY_bfd_is_group_section bfd_generic_is_group_section
50575fd0b74Schristos #endif
506012573ebSchristos #ifndef MY_bfd_group_name
507012573ebSchristos #define MY_bfd_group_name bfd_generic_group_name
508012573ebSchristos #endif
50975fd0b74Schristos #ifndef MY_bfd_discard_group
51075fd0b74Schristos #define MY_bfd_discard_group bfd_generic_discard_group
51175fd0b74Schristos #endif
51275fd0b74Schristos #ifndef MY_section_already_linked
51375fd0b74Schristos #define MY_section_already_linked \
51475fd0b74Schristos   _bfd_generic_section_already_linked
51575fd0b74Schristos #endif
51675fd0b74Schristos #ifndef MY_bfd_define_common_symbol
51775fd0b74Schristos #define MY_bfd_define_common_symbol bfd_generic_define_common_symbol
51875fd0b74Schristos #endif
519ede78133Schristos #ifndef MY_bfd_link_hide_symbol
520ede78133Schristos #define MY_bfd_link_hide_symbol _bfd_generic_link_hide_symbol
521ede78133Schristos #endif
522ede78133Schristos #ifndef MY_bfd_define_start_stop
523ede78133Schristos #define MY_bfd_define_start_stop bfd_generic_define_start_stop
524ede78133Schristos #endif
52575fd0b74Schristos #ifndef MY_bfd_reloc_type_lookup
52675fd0b74Schristos #define MY_bfd_reloc_type_lookup NAME (aout, reloc_type_lookup)
52775fd0b74Schristos #endif
52875fd0b74Schristos #ifndef MY_bfd_reloc_name_lookup
52975fd0b74Schristos #define MY_bfd_reloc_name_lookup NAME (aout, reloc_name_lookup)
53075fd0b74Schristos #endif
53175fd0b74Schristos #ifndef MY_bfd_make_debug_symbol
53275fd0b74Schristos #define MY_bfd_make_debug_symbol 0
53375fd0b74Schristos #endif
53475fd0b74Schristos #ifndef MY_read_minisymbols
53575fd0b74Schristos #define MY_read_minisymbols NAME (aout, read_minisymbols)
53675fd0b74Schristos #endif
53775fd0b74Schristos #ifndef MY_minisymbol_to_symbol
53875fd0b74Schristos #define MY_minisymbol_to_symbol NAME (aout, minisymbol_to_symbol)
53975fd0b74Schristos #endif
54075fd0b74Schristos #ifndef MY_bfd_link_hash_table_create
54175fd0b74Schristos #define MY_bfd_link_hash_table_create NAME (aout, link_hash_table_create)
54275fd0b74Schristos #endif
54375fd0b74Schristos #ifndef MY_bfd_link_add_symbols
54475fd0b74Schristos #define MY_bfd_link_add_symbols NAME (aout, link_add_symbols)
54575fd0b74Schristos #endif
54675fd0b74Schristos #ifndef MY_bfd_link_just_syms
54775fd0b74Schristos #define MY_bfd_link_just_syms _bfd_generic_link_just_syms
54875fd0b74Schristos #endif
54975fd0b74Schristos #ifndef MY_bfd_copy_link_hash_symbol_type
55075fd0b74Schristos #define MY_bfd_copy_link_hash_symbol_type \
55175fd0b74Schristos   _bfd_generic_copy_link_hash_symbol_type
55275fd0b74Schristos #endif
55375fd0b74Schristos #ifndef MY_bfd_link_split_section
55475fd0b74Schristos #define MY_bfd_link_split_section  _bfd_generic_link_split_section
55575fd0b74Schristos #endif
55675fd0b74Schristos 
55775fd0b74Schristos #ifndef MY_bfd_link_check_relocs
55875fd0b74Schristos #define MY_bfd_link_check_relocs   _bfd_generic_link_check_relocs
55975fd0b74Schristos #endif
56075fd0b74Schristos 
56175fd0b74Schristos #ifndef MY_bfd_copy_private_bfd_data
56275fd0b74Schristos #define MY_bfd_copy_private_bfd_data _bfd_generic_bfd_copy_private_bfd_data
56375fd0b74Schristos #endif
56475fd0b74Schristos 
56575fd0b74Schristos #ifndef MY_bfd_merge_private_bfd_data
56675fd0b74Schristos #define MY_bfd_merge_private_bfd_data _bfd_generic_bfd_merge_private_bfd_data
56775fd0b74Schristos #endif
56875fd0b74Schristos 
56975fd0b74Schristos #ifndef MY_bfd_copy_private_symbol_data
57075fd0b74Schristos #define MY_bfd_copy_private_symbol_data _bfd_generic_bfd_copy_private_symbol_data
57175fd0b74Schristos #endif
57275fd0b74Schristos 
57375fd0b74Schristos #ifndef MY_bfd_copy_private_header_data
57475fd0b74Schristos #define MY_bfd_copy_private_header_data _bfd_generic_bfd_copy_private_header_data
57575fd0b74Schristos #endif
57675fd0b74Schristos 
57775fd0b74Schristos #ifndef MY_bfd_print_private_bfd_data
57875fd0b74Schristos #define MY_bfd_print_private_bfd_data _bfd_generic_bfd_print_private_bfd_data
57975fd0b74Schristos #endif
58075fd0b74Schristos 
58175fd0b74Schristos #ifndef MY_bfd_set_private_flags
58275fd0b74Schristos #define MY_bfd_set_private_flags _bfd_generic_bfd_set_private_flags
58375fd0b74Schristos #endif
58475fd0b74Schristos 
58575fd0b74Schristos #ifndef MY_bfd_is_local_label_name
58675fd0b74Schristos #define MY_bfd_is_local_label_name bfd_generic_is_local_label_name
58775fd0b74Schristos #endif
58875fd0b74Schristos 
58975fd0b74Schristos #ifndef MY_bfd_is_target_special_symbol
590ede78133Schristos #define MY_bfd_is_target_special_symbol _bfd_bool_bfd_asymbol_false
59175fd0b74Schristos #endif
59275fd0b74Schristos 
59375fd0b74Schristos #ifndef MY_bfd_free_cached_info
59475fd0b74Schristos #define MY_bfd_free_cached_info NAME (aout, bfd_free_cached_info)
59575fd0b74Schristos #endif
59675fd0b74Schristos 
59775fd0b74Schristos #ifndef MY_close_and_cleanup
59875fd0b74Schristos 
59975fd0b74Schristos /* Handle closing of a BFD including the resource-releasing parts.  */
60075fd0b74Schristos 
601*e992f068Schristos static bool
MY_close_and_cleanup(bfd * abfd)60275fd0b74Schristos MY_close_and_cleanup (bfd *abfd)
60375fd0b74Schristos {
60475fd0b74Schristos   if (!MY_bfd_free_cached_info (abfd))
605*e992f068Schristos     return false;
60675fd0b74Schristos 
60775fd0b74Schristos   return _bfd_generic_close_and_cleanup (abfd);
60875fd0b74Schristos }
60975fd0b74Schristos 
61075fd0b74Schristos #endif
61175fd0b74Schristos 
61275fd0b74Schristos #ifndef MY_get_dynamic_symtab_upper_bound
61375fd0b74Schristos #define MY_get_dynamic_symtab_upper_bound \
61475fd0b74Schristos   _bfd_nodynamic_get_dynamic_symtab_upper_bound
61575fd0b74Schristos #endif
61675fd0b74Schristos #ifndef MY_canonicalize_dynamic_symtab
61775fd0b74Schristos #define MY_canonicalize_dynamic_symtab \
61875fd0b74Schristos   _bfd_nodynamic_canonicalize_dynamic_symtab
61975fd0b74Schristos #endif
62075fd0b74Schristos #ifndef MY_get_synthetic_symtab
62175fd0b74Schristos #define MY_get_synthetic_symtab \
62275fd0b74Schristos   _bfd_nodynamic_get_synthetic_symtab
62375fd0b74Schristos #endif
62475fd0b74Schristos #ifndef MY_get_dynamic_reloc_upper_bound
62575fd0b74Schristos #define MY_get_dynamic_reloc_upper_bound \
62675fd0b74Schristos   _bfd_nodynamic_get_dynamic_reloc_upper_bound
62775fd0b74Schristos #endif
62875fd0b74Schristos #ifndef MY_canonicalize_dynamic_reloc
62975fd0b74Schristos #define MY_canonicalize_dynamic_reloc \
63075fd0b74Schristos   _bfd_nodynamic_canonicalize_dynamic_reloc
63175fd0b74Schristos #endif
63275fd0b74Schristos 
63375fd0b74Schristos /* Aout symbols normally have leading underscores.  */
63475fd0b74Schristos #ifndef MY_symbol_leading_char
63575fd0b74Schristos #define MY_symbol_leading_char '_'
63675fd0b74Schristos #endif
63775fd0b74Schristos 
63875fd0b74Schristos /* Aout archives normally use spaces for padding.  */
63975fd0b74Schristos #ifndef AR_PAD_CHAR
64075fd0b74Schristos #define AR_PAD_CHAR ' '
64175fd0b74Schristos #endif
64275fd0b74Schristos 
64375fd0b74Schristos #ifndef MY_BFD_TARGET
64475fd0b74Schristos const bfd_target MY (vec) =
64575fd0b74Schristos {
64675fd0b74Schristos   TARGETNAME,			/* Name.  */
64775fd0b74Schristos   bfd_target_aout_flavour,
64875fd0b74Schristos #ifdef TARGET_IS_BIG_ENDIAN_P
64975fd0b74Schristos   BFD_ENDIAN_BIG,		/* Target byte order (big).  */
65075fd0b74Schristos   BFD_ENDIAN_BIG,		/* Target headers byte order (big).  */
65175fd0b74Schristos #else
65275fd0b74Schristos   BFD_ENDIAN_LITTLE,		/* Target byte order (little).  */
65375fd0b74Schristos   BFD_ENDIAN_LITTLE,		/* Target headers byte order (little).  */
65475fd0b74Schristos #endif
65575fd0b74Schristos   (HAS_RELOC | EXEC_P |		/* Object flags.  */
65675fd0b74Schristos    HAS_LINENO | HAS_DEBUG |
65775fd0b74Schristos    HAS_SYMS | HAS_LOCALS | DYNAMIC | WP_TEXT | D_PAGED),
65875fd0b74Schristos   (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC | SEC_CODE | SEC_DATA),
65975fd0b74Schristos   MY_symbol_leading_char,
66075fd0b74Schristos   AR_PAD_CHAR,			/* AR_pad_char.  */
66175fd0b74Schristos   15,				/* AR_max_namelen.  */
66275fd0b74Schristos   0,				/* match priority.  */
663*e992f068Schristos   TARGET_KEEP_UNUSED_SECTION_SYMBOLS, /* keep unused section symbols.  */
66475fd0b74Schristos #ifdef TARGET_IS_BIG_ENDIAN_P
66575fd0b74Schristos   bfd_getb64, bfd_getb_signed_64, bfd_putb64,
66675fd0b74Schristos      bfd_getb32, bfd_getb_signed_32, bfd_putb32,
66775fd0b74Schristos      bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* Data.  */
66875fd0b74Schristos   bfd_getb64, bfd_getb_signed_64, bfd_putb64,
66975fd0b74Schristos      bfd_getb32, bfd_getb_signed_32, bfd_putb32,
67075fd0b74Schristos      bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* Headers.  */
67175fd0b74Schristos #else
67275fd0b74Schristos   bfd_getl64, bfd_getl_signed_64, bfd_putl64,
67375fd0b74Schristos      bfd_getl32, bfd_getl_signed_32, bfd_putl32,
67475fd0b74Schristos      bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* Data.  */
67575fd0b74Schristos   bfd_getl64, bfd_getl_signed_64, bfd_putl64,
67675fd0b74Schristos      bfd_getl32, bfd_getl_signed_32, bfd_putl32,
67775fd0b74Schristos      bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* Headers.  */
67875fd0b74Schristos #endif
679ede78133Schristos     {				/* bfd_check_format.  */
680ede78133Schristos       _bfd_dummy_target,
681ede78133Schristos       MY_object_p,
682ede78133Schristos       bfd_generic_archive_p,
683ede78133Schristos       MY_core_file_p
684ede78133Schristos     },
685ede78133Schristos     {				/* bfd_set_format.  */
686ede78133Schristos       _bfd_bool_bfd_false_error,
687ede78133Schristos       MY_mkobject,
688ede78133Schristos       _bfd_generic_mkarchive,
689ede78133Schristos       _bfd_bool_bfd_false_error
690ede78133Schristos     },
691ede78133Schristos     {				/* bfd_write_contents.  */
692ede78133Schristos       _bfd_bool_bfd_false_error,
693ede78133Schristos       MY_write_object_contents,
694ede78133Schristos       _bfd_write_archive_contents,
695ede78133Schristos       _bfd_bool_bfd_false_error
696ede78133Schristos     },
69775fd0b74Schristos 
69875fd0b74Schristos      BFD_JUMP_TABLE_GENERIC (MY),
69975fd0b74Schristos      BFD_JUMP_TABLE_COPY (MY),
70075fd0b74Schristos      BFD_JUMP_TABLE_CORE (MY),
70175fd0b74Schristos      BFD_JUMP_TABLE_ARCHIVE (MY),
70275fd0b74Schristos      BFD_JUMP_TABLE_SYMBOLS (MY),
70375fd0b74Schristos      BFD_JUMP_TABLE_RELOCS (MY),
70475fd0b74Schristos      BFD_JUMP_TABLE_WRITE (MY),
70575fd0b74Schristos      BFD_JUMP_TABLE_LINK (MY),
70675fd0b74Schristos      BFD_JUMP_TABLE_DYNAMIC (MY),
70775fd0b74Schristos 
70875fd0b74Schristos   /* Alternative_target.  */
70975fd0b74Schristos   NULL,
71075fd0b74Schristos 
71175fd0b74Schristos   MY_backend_data
71275fd0b74Schristos };
71375fd0b74Schristos #endif /* MY_BFD_TARGET */
714