184865Sobrien/* Common definitions for backends based on IBM RS/6000 "XCOFF64" files.
2218822Sdim   Copyright 2000, 2001, 2002, 2004, 2005, 2006
384865Sobrien   Free Software Foundation, Inc.
484865Sobrien   Contributed by Cygnus Support.
584865Sobrien
6218822Sdim   This file is part of BFD, the Binary File Descriptor library.
784865Sobrien
8218822Sdim   This program is free software; you can redistribute it and/or modify
9218822Sdim   it under the terms of the GNU General Public License as published by
10218822Sdim   the Free Software Foundation; either version 2 of the License, or
11218822Sdim   (at your option) any later version.
1284865Sobrien
13218822Sdim   This program is distributed in the hope that it will be useful,
14218822Sdim   but WITHOUT ANY WARRANTY; without even the implied warranty of
15218822Sdim   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16218822Sdim   GNU General Public License for more details.
1784865Sobrien
18218822Sdim   You should have received a copy of the GNU General Public License
19218822Sdim   along with this program; if not, write to the Free Software
20218822Sdim   Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.  */
2184865Sobrien
2284865Sobrien/* Internalcoff.h and coffcode.h modify themselves based on this flag.  */
2384865Sobrien#define RS6000COFF_C 1
2484865Sobrien
2584865Sobrien#define SELECT_RELOC(internal, howto)					\
2684865Sobrien  {									\
2784865Sobrien    internal.r_type = howto->type;					\
2884865Sobrien    internal.r_size =							\
2984865Sobrien      ((howto->complain_on_overflow == complain_overflow_signed		\
3084865Sobrien	? 0x80								\
3184865Sobrien	: 0)								\
3284865Sobrien       | (howto->bitsize - 1));						\
3384865Sobrien  }
3484865Sobrien
35218822Sdim#define COFF_DEFAULT_SECTION_ALIGNMENT_POWER 3
3684865Sobrien
3784865Sobrien#define COFF_LONG_FILENAMES
3884865Sobrien
3984865Sobrien#define NO_COFF_SYMBOLS
4084865Sobrien
4184865Sobrien#define RTYPE2HOWTO(cache_ptr, dst) _bfd_xcoff_rtype2howto (cache_ptr, dst)
4284865Sobrien
43218822Sdim#define coff_mkobject                                  _bfd_xcoff_mkobject
44218822Sdim#define coff_bfd_copy_private_bfd_data                 _bfd_xcoff_copy_private_bfd_data
45218822Sdim#define coff_bfd_is_local_label_name                   _bfd_xcoff_is_local_label_name
46218822Sdim#define coff_bfd_is_target_special_symbol  ((bfd_boolean (*) (bfd *, asymbol *)) bfd_false)
47218822Sdim#define coff_bfd_reloc_type_lookup                     _bfd_xcoff_reloc_type_lookup
48218822Sdim#define coff_relocate_section                          _bfd_ppc_xcoff_relocate_section
49218822Sdim#define coff_core_file_failing_command                 _bfd_nocore_core_file_failing_command
50218822Sdim#define coff_core_file_failing_signal                  _bfd_nocore_core_file_failing_signal
51218822Sdim#define coff_core_file_matches_executable_p            _bfd_nocore_core_file_matches_executable_p
52218822Sdim#define _bfd_xcoff_bfd_get_relocated_section_contents  coff_bfd_get_relocated_section_contents
53218822Sdim#define _bfd_xcoff_bfd_relax_section                   coff_bfd_relax_section
54218822Sdim#define _bfd_xcoff_bfd_gc_sections                     coff_bfd_gc_sections
55218822Sdim#define _bfd_xcoff_bfd_merge_sections                  coff_bfd_merge_sections
56218822Sdim#define _bfd_xcoff_bfd_discard_group                   bfd_generic_discard_group
57218822Sdim#define _bfd_xcoff_section_already_linked              _bfd_generic_section_already_linked
58218822Sdim#define _bfd_xcoff_bfd_link_split_section              coff_bfd_link_split_section
5984865Sobrien
6084865Sobrien#define CORE_FILE_P _bfd_dummy_target
6184865Sobrien
62218822Sdim#ifdef AIX_CORE
6384865Sobrien
64218822Sdim#undef  CORE_FILE_P
6584865Sobrien#define CORE_FILE_P rs6000coff_core_p
66218822Sdimextern const bfd_target * rs6000coff_core_p (bfd *);
67218822Sdimextern bfd_boolean rs6000coff_core_file_matches_executable_p (bfd *, bfd*);
6884865Sobrien
6984865Sobrien#undef	coff_core_file_matches_executable_p
7084865Sobrien#define coff_core_file_matches_executable_p  \
7184865Sobrien				     rs6000coff_core_file_matches_executable_p
7284865Sobrien
73218822Sdimextern char *rs6000coff_core_file_failing_command (bfd *);
74218822Sdim#undef  coff_core_file_failing_command
7584865Sobrien#define coff_core_file_failing_command rs6000coff_core_file_failing_command
7684865Sobrien
77218822Sdimextern int rs6000coff_core_file_failing_signal (bfd *);
78218822Sdim#undef  coff_core_file_failing_signal
7984865Sobrien#define coff_core_file_failing_signal rs6000coff_core_file_failing_signal
8084865Sobrien#endif /* AIX_CORE */
8184865Sobrien
8284865Sobrien#ifdef LYNX_CORE
8384865Sobrien
84218822Sdim#undef  CORE_FILE_P
8584865Sobrien#define CORE_FILE_P lynx_core_file_p
86218822Sdimextern const bfd_target *lynx_core_file_p (bfd *);
8784865Sobrien
88218822Sdimextern bfd_boolean lynx_core_file_matches_executable_p (bfd *, bfd *);
8984865Sobrien#undef	coff_core_file_matches_executable_p
9084865Sobrien#define coff_core_file_matches_executable_p lynx_core_file_matches_executable_p
9184865Sobrien
92218822Sdimextern char *lynx_core_file_failing_command (bfd *);
93218822Sdim#undef  coff_core_file_failing_command
9484865Sobrien#define coff_core_file_failing_command lynx_core_file_failing_command
9584865Sobrien
96218822Sdimextern int lynx_core_file_failing_signal (bfd *);
97218822Sdim#undef  coff_core_file_failing_signal
9884865Sobrien#define coff_core_file_failing_signal lynx_core_file_failing_signal
9984865Sobrien
10084865Sobrien#endif /* LYNX_CORE */
10184865Sobrien
10284865Sobrien/* XCOFF archives do not have anything which corresponds to an
10384865Sobrien   extended name table.  */
10484865Sobrien
10584865Sobrien#define _bfd_xcoff_slurp_extended_name_table bfd_false
10684865Sobrien#define _bfd_xcoff_construct_extended_name_table \
107218822Sdim  ((bfd_boolean (*) (bfd *, char **, bfd_size_type *, const char **)) bfd_false)
10884865Sobrien#define _bfd_xcoff_truncate_arname bfd_dont_truncate_arname
10984865Sobrien
11084865Sobrien/* We can use the standard get_elt_at_index routine.  */
11184865Sobrien
11284865Sobrien#define _bfd_xcoff_get_elt_at_index _bfd_generic_get_elt_at_index
11384865Sobrien
11484865Sobrien/* XCOFF archives do not have a timestamp.  */
11584865Sobrien
11684865Sobrien#define _bfd_xcoff_update_armap_timestamp bfd_true
11784865Sobrien
118218822Sdimextern bfd_boolean        _bfd_xcoff_mkobject (bfd *);
119218822Sdimextern bfd_boolean        _bfd_xcoff_copy_private_bfd_data (bfd *, bfd *);
120218822Sdimextern bfd_boolean        _bfd_xcoff_is_local_label_name (bfd *, const char *);
121218822Sdimextern void               _bfd_xcoff_rtype2howto  (arelent *, struct internal_reloc *);
122218822Sdimextern bfd_boolean        _bfd_xcoff_slurp_armap (bfd *);
123218822Sdimextern void *             _bfd_xcoff_read_ar_hdr (bfd *);
124218822Sdimextern bfd *              _bfd_xcoff_openr_next_archived_file (bfd *, bfd *);
125218822Sdimextern int                _bfd_xcoff_generic_stat_arch_elt (bfd *, struct stat *);
126218822Sdimextern bfd_boolean        _bfd_xcoff_write_armap  (bfd *, unsigned int, struct orl *, unsigned int, int);
127218822Sdimextern bfd_boolean        _bfd_xcoff_write_archive_contents (bfd *);
128218822Sdimextern int                _bfd_xcoff_sizeof_headers (bfd *, struct bfd_link_info *);
129218822Sdimextern void               _bfd_xcoff_swap_sym_in (bfd *, void *, void *);
130218822Sdimextern unsigned int       _bfd_xcoff_swap_sym_out (bfd *, void *, void *);
131218822Sdimextern void               _bfd_xcoff_swap_aux_in (bfd *, void *, int, int, int, int, void *);
132218822Sdimextern unsigned int       _bfd_xcoff_swap_aux_out (bfd *, void *, int, int, int, int, void *);
133218822Sdimextern reloc_howto_type * _bfd_xcoff_reloc_type_lookup  (bfd *, bfd_reloc_code_real_type);
134218822Sdimextern const bfd_target * _bfd_xcoff_archive_p (bfd *);
13584865Sobrien
13684865Sobrien#ifndef coff_SWAP_sym_in
137218822Sdim#define coff_SWAP_sym_in  _bfd_xcoff_swap_sym_in
13884865Sobrien#define coff_SWAP_sym_out _bfd_xcoff_swap_sym_out
139218822Sdim#define coff_SWAP_aux_in  _bfd_xcoff_swap_aux_in
14084865Sobrien#define coff_SWAP_aux_out _bfd_xcoff_swap_aux_out
14184865Sobrien#endif
14284865Sobrien
14384865Sobrien#include "coffcode.h"
14484865Sobrien
14584865Sobrien/* The transfer vector that leads the outside world to all of the above.  */
14684865Sobrien
14784865Sobrienconst bfd_target TARGET_SYM =
14884865Sobrien{
14984865Sobrien  TARGET_NAME,
15084865Sobrien  bfd_target_xcoff_flavour,
151218822Sdim  BFD_ENDIAN_BIG,		/* Data byte order is big.  */
152218822Sdim  BFD_ENDIAN_BIG,		/* Header byte order is big.  */
15384865Sobrien
154218822Sdim  (HAS_RELOC | EXEC_P |		/* Object flags.  */
15584865Sobrien   HAS_LINENO | HAS_DEBUG | DYNAMIC |
15684865Sobrien   HAS_SYMS | HAS_LOCALS | WP_TEXT),
15784865Sobrien
158218822Sdim  (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* Section flags.  */
159218822Sdim  0,				/* Leading char.  */
160218822Sdim  '/',				/* AR_pad_char.  */
161218822Sdim  15,				/* AR_max_namelen??? FIXME.  */
16284865Sobrien
16384865Sobrien  bfd_getb64, bfd_getb_signed_64, bfd_putb64,
16484865Sobrien     bfd_getb32, bfd_getb_signed_32, bfd_putb32,
165218822Sdim     bfd_getb16, bfd_getb_signed_16, bfd_putb16,/* Data.  */
16684865Sobrien  bfd_getb64, bfd_getb_signed_64, bfd_putb64,
16784865Sobrien     bfd_getb32, bfd_getb_signed_32, bfd_putb32,
168218822Sdim     bfd_getb16, bfd_getb_signed_16, bfd_putb16,/* Headers.  */
16984865Sobrien
170218822Sdim  {_bfd_dummy_target, coff_object_p, 		/* bfd_check_format.  */
17184865Sobrien     _bfd_xcoff_archive_p, CORE_FILE_P},
172218822Sdim  {bfd_false, coff_mkobject,			/* bfd_set_format.  */
17384865Sobrien     _bfd_generic_mkarchive, bfd_false},
174218822Sdim  {bfd_false, coff_write_object_contents,	/* bfd_write_contents.  */
17584865Sobrien     _bfd_xcoff_write_archive_contents, bfd_false},
17684865Sobrien
17784865Sobrien     BFD_JUMP_TABLE_GENERIC (coff),
17884865Sobrien     BFD_JUMP_TABLE_COPY (coff),
17984865Sobrien     BFD_JUMP_TABLE_CORE (coff),
18084865Sobrien     BFD_JUMP_TABLE_ARCHIVE (_bfd_xcoff),
18184865Sobrien     BFD_JUMP_TABLE_SYMBOLS (coff),
18284865Sobrien     BFD_JUMP_TABLE_RELOCS (coff),
18384865Sobrien     BFD_JUMP_TABLE_WRITE (coff),
18484865Sobrien     BFD_JUMP_TABLE_LINK (_bfd_xcoff),
18584865Sobrien     BFD_JUMP_TABLE_DYNAMIC (_bfd_xcoff),
18684865Sobrien
18784865Sobrien  NULL,
18884865Sobrien
18984865Sobrien  COFF_SWAP_TABLE
19084865Sobrien};
191