xcoff-target.h revision 104834
1284990Scy/* Common definitions for backends based on IBM RS/6000 "XCOFF64" files.
2284990Scy   Copyright 2000, 2001, 2002
3284990Scy   Free Software Foundation, Inc.
4284990Scy   Contributed by Cygnus Support.
5284990Scy
6284990ScyThis file is part of BFD, the Binary File Descriptor library.
7284990Scy
8284990ScyThis program is free software; you can redistribute it and/or modify
9284990Scyit under the terms of the GNU General Public License as published by
10284990Scythe Free Software Foundation; either version 2 of the License, or
11284990Scy(at your option) any later version.
12284990Scy
13284990ScyThis program is distributed in the hope that it will be useful,
14284990Scybut WITHOUT ANY WARRANTY; without even the implied warranty of
15284990ScyMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16284990ScyGNU General Public License for more details.
17284990Scy
18284990ScyYou should have received a copy of the GNU General Public License
19284990Scyalong with this program; if not, write to the Free Software
20284990ScyFoundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
21284990Scy
22284990Scy/* Internalcoff.h and coffcode.h modify themselves based on this flag.  */
23284990Scy#define RS6000COFF_C 1
24284990Scy
25284990Scy#define SELECT_RELOC(internal, howto)					\
26284990Scy  {									\
27284990Scy    internal.r_type = howto->type;					\
28284990Scy    internal.r_size =							\
29284990Scy      ((howto->complain_on_overflow == complain_overflow_signed		\
30290000Sglebius	? 0x80								\
31290000Sglebius	: 0)								\
32284990Scy       | (howto->bitsize - 1));						\
33284990Scy  }
34284990Scy
35284990Scy#define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (3)
36284990Scy
37284990Scy#define COFF_LONG_FILENAMES
38284990Scy
39284990Scy#define NO_COFF_SYMBOLS
40284990Scy
41284990Scy#define RTYPE2HOWTO(cache_ptr, dst) _bfd_xcoff_rtype2howto (cache_ptr, dst)
42284990Scy
43284990Scy#define coff_mkobject _bfd_xcoff_mkobject
44284990Scy#define coff_bfd_copy_private_bfd_data _bfd_xcoff_copy_private_bfd_data
45284990Scy#define coff_bfd_is_local_label_name _bfd_xcoff_is_local_label_name
46284990Scy#define coff_bfd_reloc_type_lookup _bfd_xcoff_reloc_type_lookup
47284990Scy#define coff_relocate_section _bfd_ppc_xcoff_relocate_section
48284990Scy
49284990Scy#define CORE_FILE_P _bfd_dummy_target
50284990Scy
51284990Scy#define coff_core_file_failing_command _bfd_nocore_core_file_failing_command
52284990Scy#define coff_core_file_failing_signal _bfd_nocore_core_file_failing_signal
53284990Scy#define coff_core_file_matches_executable_p \
54284990Scy  _bfd_nocore_core_file_matches_executable_p
55284990Scy
56284990Scy#ifdef AIX_CORE
57284990Scy#undef CORE_FILE_P
58284990Scy#define CORE_FILE_P rs6000coff_core_p
59284990Scyextern const bfd_target * rs6000coff_core_p ();
60284990Scyextern boolean rs6000coff_core_file_matches_executable_p ();
61284990Scy
62284990Scy#undef	coff_core_file_matches_executable_p
63284990Scy#define coff_core_file_matches_executable_p  \
64284990Scy				     rs6000coff_core_file_matches_executable_p
65284990Scy
66284990Scyextern char *rs6000coff_core_file_failing_command PARAMS ((bfd *abfd));
67284990Scy#undef coff_core_file_failing_command
68284990Scy#define coff_core_file_failing_command rs6000coff_core_file_failing_command
69284990Scy
70284990Scyextern int rs6000coff_core_file_failing_signal PARAMS ((bfd *abfd));
71284990Scy#undef coff_core_file_failing_signal
72284990Scy#define coff_core_file_failing_signal rs6000coff_core_file_failing_signal
73#endif /* AIX_CORE */
74
75#ifdef LYNX_CORE
76
77#undef CORE_FILE_P
78#define CORE_FILE_P lynx_core_file_p
79extern const bfd_target *lynx_core_file_p PARAMS ((bfd *abfd));
80
81extern boolean lynx_core_file_matches_executable_p PARAMS ((bfd *core_bfd,
82							    bfd *exec_bfd));
83#undef	coff_core_file_matches_executable_p
84#define coff_core_file_matches_executable_p lynx_core_file_matches_executable_p
85
86extern char *lynx_core_file_failing_command PARAMS ((bfd *abfd));
87#undef coff_core_file_failing_command
88#define coff_core_file_failing_command lynx_core_file_failing_command
89
90extern int lynx_core_file_failing_signal PARAMS ((bfd *abfd));
91#undef coff_core_file_failing_signal
92#define coff_core_file_failing_signal lynx_core_file_failing_signal
93
94#endif /* LYNX_CORE */
95
96#define _bfd_xcoff_bfd_get_relocated_section_contents \
97  coff_bfd_get_relocated_section_contents
98#define _bfd_xcoff_bfd_relax_section coff_bfd_relax_section
99#define _bfd_xcoff_bfd_gc_sections coff_bfd_gc_sections
100#define _bfd_xcoff_bfd_merge_sections coff_bfd_merge_sections
101#define _bfd_xcoff_bfd_discard_group bfd_generic_discard_group
102#define _bfd_xcoff_bfd_link_split_section coff_bfd_link_split_section
103
104/* XCOFF archives do not have anything which corresponds to an
105   extended name table.  */
106
107#define _bfd_xcoff_slurp_extended_name_table bfd_false
108#define _bfd_xcoff_construct_extended_name_table \
109  ((boolean (*) PARAMS ((bfd *, char **, bfd_size_type *, const char **))) \
110   bfd_false)
111#define _bfd_xcoff_truncate_arname bfd_dont_truncate_arname
112
113/* We can use the standard get_elt_at_index routine.  */
114
115#define _bfd_xcoff_get_elt_at_index _bfd_generic_get_elt_at_index
116
117/* XCOFF archives do not have a timestamp.  */
118
119#define _bfd_xcoff_update_armap_timestamp bfd_true
120
121extern boolean _bfd_xcoff_mkobject PARAMS ((bfd *));
122extern boolean _bfd_xcoff_copy_private_bfd_data PARAMS ((bfd *, bfd *));
123extern boolean _bfd_xcoff_is_local_label_name PARAMS ((bfd *, const char *));
124extern void _bfd_xcoff_rtype2howto
125  PARAMS ((arelent *, struct internal_reloc *));
126extern reloc_howto_type *_bfd_xcoff_reloc_type_lookup
127  PARAMS ((bfd *, bfd_reloc_code_real_type));
128extern boolean _bfd_xcoff_slurp_armap PARAMS ((bfd *));
129extern const bfd_target *_bfd_xcoff_archive_p PARAMS ((bfd *));
130extern PTR _bfd_xcoff_read_ar_hdr PARAMS ((bfd *));
131extern bfd *_bfd_xcoff_openr_next_archived_file PARAMS ((bfd *, bfd *));
132extern int _bfd_xcoff_generic_stat_arch_elt PARAMS ((bfd *, struct stat *));
133extern boolean _bfd_xcoff_write_armap
134  PARAMS ((bfd *, unsigned int, struct orl *, unsigned int, int));
135extern boolean _bfd_xcoff_write_archive_contents PARAMS ((bfd *));
136extern int _bfd_xcoff_sizeof_headers PARAMS ((bfd *, boolean));
137extern void _bfd_xcoff_swap_sym_in PARAMS ((bfd *, PTR, PTR));
138extern unsigned int _bfd_xcoff_swap_sym_out PARAMS ((bfd *, PTR, PTR));
139extern void _bfd_xcoff_swap_aux_in PARAMS ((bfd *, PTR, int, int, int, int, PTR));
140extern unsigned int _bfd_xcoff_swap_aux_out PARAMS ((bfd *, PTR, int, int, int, int, PTR));
141
142#ifndef coff_SWAP_sym_in
143#define coff_SWAP_sym_in _bfd_xcoff_swap_sym_in
144#define coff_SWAP_sym_out _bfd_xcoff_swap_sym_out
145#define coff_SWAP_aux_in _bfd_xcoff_swap_aux_in
146#define coff_SWAP_aux_out _bfd_xcoff_swap_aux_out
147#endif
148
149#include "coffcode.h"
150
151/* The transfer vector that leads the outside world to all of the above.  */
152
153const bfd_target TARGET_SYM =
154{
155  TARGET_NAME,
156  bfd_target_xcoff_flavour,
157  BFD_ENDIAN_BIG,		/* data byte order is big */
158  BFD_ENDIAN_BIG,		/* header byte order is big */
159
160  (HAS_RELOC | EXEC_P |		/* object flags */
161   HAS_LINENO | HAS_DEBUG | DYNAMIC |
162   HAS_SYMS | HAS_LOCALS | WP_TEXT),
163
164  (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
165  0,				/* leading char */
166  '/',				/* ar_pad_char */
167  15,				/* ar_max_namelen??? FIXMEmgo */
168
169  bfd_getb64, bfd_getb_signed_64, bfd_putb64,
170     bfd_getb32, bfd_getb_signed_32, bfd_putb32,
171     bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* data */
172  bfd_getb64, bfd_getb_signed_64, bfd_putb64,
173     bfd_getb32, bfd_getb_signed_32, bfd_putb32,
174     bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* hdrs */
175
176  {_bfd_dummy_target, coff_object_p, 	/* bfd_check_format */
177     _bfd_xcoff_archive_p, CORE_FILE_P},
178  {bfd_false, coff_mkobject,		/* bfd_set_format */
179     _bfd_generic_mkarchive, bfd_false},
180  {bfd_false, coff_write_object_contents,	/* bfd_write_contents */
181     _bfd_xcoff_write_archive_contents, bfd_false},
182
183     BFD_JUMP_TABLE_GENERIC (coff),
184     BFD_JUMP_TABLE_COPY (coff),
185     BFD_JUMP_TABLE_CORE (coff),
186     BFD_JUMP_TABLE_ARCHIVE (_bfd_xcoff),
187     BFD_JUMP_TABLE_SYMBOLS (coff),
188     BFD_JUMP_TABLE_RELOCS (coff),
189     BFD_JUMP_TABLE_WRITE (coff),
190     BFD_JUMP_TABLE_LINK (_bfd_xcoff),
191     BFD_JUMP_TABLE_DYNAMIC (_bfd_xcoff),
192
193  NULL,
194
195  COFF_SWAP_TABLE
196};
197