/[gcl]/gcl/binutils/bfd/coff-rs6000.c
ViewVC logotype

Diff of /gcl/binutils/bfd/coff-rs6000.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1.1.1 by camm, Fri Aug 9 05:34:53 2002 UTC revision 1.1.1.1.20.1 by camm, Fri Sep 30 02:08:55 2005 UTC
# Line 1  Line 1 
1  /* BFD back-end for IBM RS/6000 "XCOFF" files.  /* BFD back-end for IBM RS/6000 "XCOFF" files.
2     Copyright 1990-1999, 2000, 2001, 2002     Copyright 1990-1999, 2000, 2001, 2002, 2003, 2004, 2005
3     Free Software Foundation, Inc.     Free Software Foundation, Inc.
4     FIXME: Can someone provide a transliteration of this name into ASCII?     FIXME: Can someone provide a transliteration of this name into ASCII?
5     Using the following chars caused a compiler warning on HIUX (so I replaced     Using the following chars caused a compiler warning on HIUX (so I replaced
# Line 36  Foundation, Inc., 59 Temple Place - Suit Line 36  Foundation, Inc., 59 Temple Place - Suit
36  #include "libcoff.h"  #include "libcoff.h"
37  #include "libxcoff.h"  #include "libxcoff.h"
38    
39  extern boolean _bfd_xcoff_mkobject PARAMS ((bfd *));  extern bfd_boolean _bfd_xcoff_mkobject
40  extern boolean _bfd_xcoff_copy_private_bfd_data PARAMS ((bfd *, bfd *));    PARAMS ((bfd *));
41  extern boolean _bfd_xcoff_is_local_label_name PARAMS ((bfd *, const char *));  extern bfd_boolean _bfd_xcoff_copy_private_bfd_data
42      PARAMS ((bfd *, bfd *));
43    extern bfd_boolean _bfd_xcoff_is_local_label_name
44      PARAMS ((bfd *, const char *));
45  extern reloc_howto_type *_bfd_xcoff_reloc_type_lookup  extern reloc_howto_type *_bfd_xcoff_reloc_type_lookup
46    PARAMS ((bfd *, bfd_reloc_code_real_type));    PARAMS ((bfd *, bfd_reloc_code_real_type));
47  extern boolean _bfd_xcoff_slurp_armap PARAMS ((bfd *));  extern bfd_boolean _bfd_xcoff_slurp_armap
48  extern const bfd_target *_bfd_xcoff_archive_p PARAMS ((bfd *));    PARAMS ((bfd *));
49  extern PTR _bfd_xcoff_read_ar_hdr PARAMS ((bfd *));  extern const bfd_target *_bfd_xcoff_archive_p
50  extern bfd *_bfd_xcoff_openr_next_archived_file PARAMS ((bfd *, bfd *));    PARAMS ((bfd *));
51  extern int _bfd_xcoff_stat_arch_elt PARAMS ((bfd *, struct stat *));  extern PTR _bfd_xcoff_read_ar_hdr
52  extern boolean _bfd_xcoff_write_armap    PARAMS ((bfd *));
53    extern bfd *_bfd_xcoff_openr_next_archived_file
54      PARAMS ((bfd *, bfd *));
55    extern int _bfd_xcoff_stat_arch_elt
56      PARAMS ((bfd *, struct stat *));
57    extern bfd_boolean _bfd_xcoff_write_armap
58    PARAMS ((bfd *, unsigned int, struct orl *, unsigned int, int));    PARAMS ((bfd *, unsigned int, struct orl *, unsigned int, int));
59  extern boolean _bfd_xcoff_write_archive_contents PARAMS ((bfd *));  extern bfd_boolean _bfd_xcoff_write_archive_contents
60  extern int _bfd_xcoff_sizeof_headers PARAMS ((bfd *, boolean));    PARAMS ((bfd *));
61  extern void _bfd_xcoff_swap_sym_in PARAMS ((bfd *, PTR, PTR));  extern int _bfd_xcoff_sizeof_headers
62  extern unsigned int _bfd_xcoff_swap_sym_out PARAMS ((bfd *, PTR, PTR));    PARAMS ((bfd *, bfd_boolean));
63  extern void _bfd_xcoff_swap_aux_in PARAMS ((bfd *, PTR, int, int, int, int, PTR));  extern void _bfd_xcoff_swap_sym_in
64  extern unsigned int _bfd_xcoff_swap_aux_out PARAMS ((bfd *, PTR, int, int, int, int, PTR));    PARAMS ((bfd *, PTR, PTR));
65  static void xcoff_swap_reloc_in PARAMS ((bfd *, PTR, PTR));  extern unsigned int _bfd_xcoff_swap_sym_out
66  static unsigned int xcoff_swap_reloc_out PARAMS ((bfd *, PTR, PTR));    PARAMS ((bfd *, PTR, PTR));
67    extern void _bfd_xcoff_swap_aux_in
68      PARAMS ((bfd *, PTR, int, int, int, int, PTR));
69    extern unsigned int _bfd_xcoff_swap_aux_out
70      PARAMS ((bfd *, PTR, int, int, int, int, PTR));
71    static void xcoff_swap_reloc_in
72      PARAMS ((bfd *, PTR, PTR));
73    static unsigned int xcoff_swap_reloc_out
74      PARAMS ((bfd *, PTR, PTR));
75    
76  /* Forward declare xcoff_rtype2howto for coffcode.h macro.  */  /* Forward declare xcoff_rtype2howto for coffcode.h macro.  */
77  void xcoff_rtype2howto PARAMS ((arelent *, struct internal_reloc *));  void xcoff_rtype2howto
78      PARAMS ((arelent *, struct internal_reloc *));
79    
80  /* coffcode.h needs these to be defined.  */  /* coffcode.h needs these to be defined.  */
81  #define RS6000COFF_C 1  #define RS6000COFF_C 1
# Line 82  void xcoff_rtype2howto PARAMS ((arelent Line 99  void xcoff_rtype2howto PARAMS ((arelent
99  #define coff_bfd_is_local_label_name _bfd_xcoff_is_local_label_name  #define coff_bfd_is_local_label_name _bfd_xcoff_is_local_label_name
100  #define coff_bfd_reloc_type_lookup _bfd_xcoff_reloc_type_lookup  #define coff_bfd_reloc_type_lookup _bfd_xcoff_reloc_type_lookup
101  #ifdef AIX_CORE  #ifdef AIX_CORE
102  extern const bfd_target * rs6000coff_core_p PARAMS ((bfd *abfd));  extern const bfd_target * rs6000coff_core_p
103  extern boolean rs6000coff_core_file_matches_executable_p    PARAMS ((bfd *abfd));
104    extern bfd_boolean rs6000coff_core_file_matches_executable_p
105    PARAMS ((bfd *cbfd, bfd *ebfd));    PARAMS ((bfd *cbfd, bfd *ebfd));
106  extern char *rs6000coff_core_file_failing_command PARAMS ((bfd *abfd));  extern char *rs6000coff_core_file_failing_command
107  extern int rs6000coff_core_file_failing_signal PARAMS ((bfd *abfd));    PARAMS ((bfd *abfd));
108    extern int rs6000coff_core_file_failing_signal
109      PARAMS ((bfd *abfd));
110  #define CORE_FILE_P rs6000coff_core_p  #define CORE_FILE_P rs6000coff_core_p
111  #define coff_core_file_failing_command \  #define coff_core_file_failing_command \
112    rs6000coff_core_file_failing_command    rs6000coff_core_file_failing_command
# Line 115  extern int rs6000coff_core_file_failing_ Line 135  extern int rs6000coff_core_file_failing_
135    
136  /* The main body of code is in coffcode.h.  */  /* The main body of code is in coffcode.h.  */
137    
138  static const char *normalize_filename PARAMS ((bfd *));  static const char *normalize_filename
139  static boolean xcoff_write_armap_old    PARAMS ((bfd *));
140    static bfd_boolean xcoff_write_armap_old
141    PARAMS ((bfd *, unsigned int, struct orl *, unsigned int, int));    PARAMS ((bfd *, unsigned int, struct orl *, unsigned int, int));
142  static boolean xcoff_write_armap_big  static bfd_boolean xcoff_write_armap_big
143    PARAMS ((bfd *, unsigned int, struct orl *, unsigned int, int));    PARAMS ((bfd *, unsigned int, struct orl *, unsigned int, int));
144  static boolean xcoff_write_archive_contents_old PARAMS ((bfd *));  static bfd_boolean xcoff_write_archive_contents_old
145  static boolean xcoff_write_archive_contents_big PARAMS ((bfd *));    PARAMS ((bfd *));
146    static bfd_boolean xcoff_write_archive_contents_big
147      PARAMS ((bfd *));
148  static void xcoff_swap_ldhdr_in  static void xcoff_swap_ldhdr_in
149    PARAMS ((bfd *, const PTR, struct internal_ldhdr *));    PARAMS ((bfd *, const PTR, struct internal_ldhdr *));
150  static void xcoff_swap_ldhdr_out  static void xcoff_swap_ldhdr_out
# Line 134  static void xcoff_swap_ldrel_in Line 157  static void xcoff_swap_ldrel_in
157    PARAMS ((bfd *, const PTR, struct internal_ldrel *));    PARAMS ((bfd *, const PTR, struct internal_ldrel *));
158  static void xcoff_swap_ldrel_out  static void xcoff_swap_ldrel_out
159    PARAMS ((bfd *, const struct internal_ldrel *, PTR));    PARAMS ((bfd *, const struct internal_ldrel *, PTR));
160  static boolean xcoff_ppc_relocate_section  static bfd_boolean xcoff_ppc_relocate_section
161    PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,    PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
162             struct internal_reloc *, struct internal_syment *, asection **));             struct internal_reloc *, struct internal_syment *, asection **));
163  static boolean _bfd_xcoff_put_ldsymbol_name  static bfd_boolean _bfd_xcoff_put_ldsymbol_name
164    PARAMS ((bfd *, struct xcoff_loader_info *, struct internal_ldsym *,    PARAMS ((bfd *, struct xcoff_loader_info *, struct internal_ldsym *,
165             const char *));             const char *));
166  static asection *xcoff_create_csect_from_smclas  static asection *xcoff_create_csect_from_smclas
167    PARAMS ((bfd *, union internal_auxent *, const char *));    PARAMS ((bfd *, union internal_auxent *, const char *));
168  static boolean xcoff_is_lineno_count_overflow PARAMS ((bfd *, bfd_vma));  static bfd_boolean xcoff_is_lineno_count_overflow
169  static boolean xcoff_is_reloc_count_overflow PARAMS ((bfd *, bfd_vma));    PARAMS ((bfd *, bfd_vma));
170    static bfd_boolean xcoff_is_reloc_count_overflow
171      PARAMS ((bfd *, bfd_vma));
172  static bfd_vma xcoff_loader_symbol_offset  static bfd_vma xcoff_loader_symbol_offset
173    PARAMS ((bfd *, struct internal_ldhdr *));    PARAMS ((bfd *, struct internal_ldhdr *));
174  static bfd_vma xcoff_loader_reloc_offset  static bfd_vma xcoff_loader_reloc_offset
175    PARAMS ((bfd *, struct internal_ldhdr *));    PARAMS ((bfd *, struct internal_ldhdr *));
176  static boolean xcoff_generate_rtinit  static bfd_boolean xcoff_generate_rtinit
177    PARAMS((bfd *, const char *, const char *, boolean));    PARAMS ((bfd *, const char *, const char *, bfd_boolean));
178  static boolean do_pad PARAMS((bfd *, unsigned int));  static bfd_boolean do_pad
179  static boolean do_copy PARAMS((bfd *, bfd *));    PARAMS ((bfd *, unsigned int));
180  static boolean do_shared_object_padding PARAMS ((bfd *, bfd *, ufile_ptr *, int));  static bfd_boolean do_copy
181      PARAMS ((bfd *, bfd *));
182    static bfd_boolean do_shared_object_padding
183      PARAMS ((bfd *, bfd *, file_ptr *, int));
184    
185  /* Relocation functions */  /* Relocation functions */
186  static boolean xcoff_reloc_type_br PARAMS ((XCOFF_RELOC_FUNCTION_ARGS));  static bfd_boolean xcoff_reloc_type_br
187      PARAMS ((XCOFF_RELOC_FUNCTION_ARGS));
188    
189  static boolean xcoff_complain_overflow_dont_func  static bfd_boolean xcoff_complain_overflow_dont_func
190    PARAMS ((XCOFF_COMPLAIN_FUNCTION_ARGS));    PARAMS ((XCOFF_COMPLAIN_FUNCTION_ARGS));
191  static boolean xcoff_complain_overflow_bitfield_func  static bfd_boolean xcoff_complain_overflow_bitfield_func
192    PARAMS ((XCOFF_COMPLAIN_FUNCTION_ARGS));    PARAMS ((XCOFF_COMPLAIN_FUNCTION_ARGS));
193  static boolean xcoff_complain_overflow_signed_func  static bfd_boolean xcoff_complain_overflow_signed_func
194    PARAMS ((XCOFF_COMPLAIN_FUNCTION_ARGS));    PARAMS ((XCOFF_COMPLAIN_FUNCTION_ARGS));
195  static boolean xcoff_complain_overflow_unsigned_func  static bfd_boolean xcoff_complain_overflow_unsigned_func
196    PARAMS ((XCOFF_COMPLAIN_FUNCTION_ARGS));    PARAMS ((XCOFF_COMPLAIN_FUNCTION_ARGS));
197    
198  boolean (*xcoff_calculate_relocation[XCOFF_MAX_CALCULATE_RELOCATION])  bfd_boolean (*xcoff_calculate_relocation[XCOFF_MAX_CALCULATE_RELOCATION])
199       (XCOFF_RELOC_FUNCTION_ARGS) =    PARAMS ((XCOFF_RELOC_FUNCTION_ARGS)) =
200  {  {
201    xcoff_reloc_type_pos,  /* R_POS   (0x00) */    xcoff_reloc_type_pos,  /* R_POS   (0x00) */
202    xcoff_reloc_type_neg,  /* R_NEG   (0x01) */    xcoff_reloc_type_neg,  /* R_NEG   (0x01) */
203    xcoff_reloc_type_rel,  /* R_REL   (0x02) */    xcoff_reloc_type_rel,  /* R_REL   (0x02) */
204    xcoff_reloc_type_toc,  /* R_TOC   (0x03) */    xcoff_reloc_type_toc,  /* R_TOC   (0x03) */
205    xcoff_reloc_type_fail, /* R_RTB   (0x04) */    xcoff_reloc_type_fail, /* R_RTB   (0x04) */
206    xcoff_reloc_type_toc,  /* R_GL    (0x05) */    xcoff_reloc_type_toc,  /* R_GL    (0x05) */
207    xcoff_reloc_type_toc,  /* R_TCL   (0x06) */    xcoff_reloc_type_toc,  /* R_TCL   (0x06) */
208    xcoff_reloc_type_fail, /*         (0x07) */    xcoff_reloc_type_fail, /*         (0x07) */
209    xcoff_reloc_type_ba,   /* R_BA    (0x08) */    xcoff_reloc_type_ba,   /* R_BA    (0x08) */
210    xcoff_reloc_type_fail, /*         (0x09) */    xcoff_reloc_type_fail, /*         (0x09) */
211    xcoff_reloc_type_br,   /* R_BR    (0x0a) */    xcoff_reloc_type_br,   /* R_BR    (0x0a) */
212    xcoff_reloc_type_fail, /*         (0x0b) */    xcoff_reloc_type_fail, /*         (0x0b) */
213    xcoff_reloc_type_pos,  /* R_RL    (0x0c) */    xcoff_reloc_type_pos,  /* R_RL    (0x0c) */
214    xcoff_reloc_type_pos,  /* R_RLA   (0x0d) */    xcoff_reloc_type_pos,  /* R_RLA   (0x0d) */
215    xcoff_reloc_type_fail, /*         (0x0e) */    xcoff_reloc_type_fail, /*         (0x0e) */
216    xcoff_reloc_type_noop, /* R_REF   (0x0f) */    xcoff_reloc_type_noop, /* R_REF   (0x0f) */
217    xcoff_reloc_type_fail, /*         (0x10) */    xcoff_reloc_type_fail, /*         (0x10) */
218    xcoff_reloc_type_fail, /*         (0x11) */    xcoff_reloc_type_fail, /*         (0x11) */
219    xcoff_reloc_type_toc,  /* R_TRL   (0x12) */    xcoff_reloc_type_toc,  /* R_TRL   (0x12) */
220    xcoff_reloc_type_toc,  /* R_TRLA  (0x13) */    xcoff_reloc_type_toc,  /* R_TRLA  (0x13) */
221    xcoff_reloc_type_fail, /* R_RRTBI (0x14) */    xcoff_reloc_type_fail, /* R_RRTBI (0x14) */
222    xcoff_reloc_type_fail, /* R_RRTBA (0x15) */    xcoff_reloc_type_fail, /* R_RRTBA (0x15) */
223    xcoff_reloc_type_ba,   /* R_CAI   (0x16) */    xcoff_reloc_type_ba,   /* R_CAI   (0x16) */
224    xcoff_reloc_type_crel, /* R_CREL  (0x17) */    xcoff_reloc_type_crel, /* R_CREL  (0x17) */
225    xcoff_reloc_type_ba,   /* R_RBA   (0x18) */    xcoff_reloc_type_ba,   /* R_RBA   (0x18) */
226    xcoff_reloc_type_ba,   /* R_RBAC  (0x19) */    xcoff_reloc_type_ba,   /* R_RBAC  (0x19) */
227    xcoff_reloc_type_br,   /* R_RBR   (0x1a) */    xcoff_reloc_type_br,   /* R_RBR   (0x1a) */
228    xcoff_reloc_type_ba,   /* R_RBRC  (0x1b) */    xcoff_reloc_type_ba,   /* R_RBRC  (0x1b) */
229  };  };
230    
231  boolean (*xcoff_complain_overflow[XCOFF_MAX_COMPLAIN_OVERFLOW])  bfd_boolean (*xcoff_complain_overflow[XCOFF_MAX_COMPLAIN_OVERFLOW])
232       (XCOFF_COMPLAIN_FUNCTION_ARGS) =    PARAMS ((XCOFF_COMPLAIN_FUNCTION_ARGS)) =
233  {  {
234    xcoff_complain_overflow_dont_func,    xcoff_complain_overflow_dont_func,
235    xcoff_complain_overflow_bitfield_func,    xcoff_complain_overflow_bitfield_func,
# Line 211  boolean (*xcoff_complain_overflow[XCOFF_ Line 240  boolean (*xcoff_complain_overflow[XCOFF_
240  /* We use our own tdata type.  Its first field is the COFF tdata type,  /* We use our own tdata type.  Its first field is the COFF tdata type,
241     so the COFF routines are compatible.  */     so the COFF routines are compatible.  */
242    
243  boolean  bfd_boolean
244  _bfd_xcoff_mkobject (abfd)  _bfd_xcoff_mkobject (abfd)
245       bfd *abfd;       bfd *abfd;
246  {  {
# Line 220  _bfd_xcoff_mkobject (abfd) Line 249  _bfd_xcoff_mkobject (abfd)
249    
250    abfd->tdata.xcoff_obj_data = (struct xcoff_tdata *) bfd_zalloc (abfd, amt);    abfd->tdata.xcoff_obj_data = (struct xcoff_tdata *) bfd_zalloc (abfd, amt);
251    if (abfd->tdata.xcoff_obj_data == NULL)    if (abfd->tdata.xcoff_obj_data == NULL)
252      return false;      return FALSE;
253    coff = coff_data (abfd);    coff = coff_data (abfd);
254    coff->symbols = (coff_symbol_type *) NULL;    coff->symbols = (coff_symbol_type *) NULL;
255    coff->conversion_table = (unsigned int *) NULL;    coff->conversion_table = (unsigned int *) NULL;
# Line 239  _bfd_xcoff_mkobject (abfd) Line 268  _bfd_xcoff_mkobject (abfd)
268    /* text section alignment is different than the default */    /* text section alignment is different than the default */
269    bfd_xcoff_text_align_power (abfd) = 2;    bfd_xcoff_text_align_power (abfd) = 2;
270    
271    return true;    return TRUE;
272  }  }
273    
274  /* Copy XCOFF data from one BFD to another.  */  /* Copy XCOFF data from one BFD to another.  */
275    
276  boolean  bfd_boolean
277  _bfd_xcoff_copy_private_bfd_data (ibfd, obfd)  _bfd_xcoff_copy_private_bfd_data (ibfd, obfd)
278       bfd *ibfd;       bfd *ibfd;
279       bfd *obfd;       bfd *obfd;
# Line 253  _bfd_xcoff_copy_private_bfd_data (ibfd, Line 282  _bfd_xcoff_copy_private_bfd_data (ibfd,
282    asection *sec;    asection *sec;
283    
284    if (ibfd->xvec != obfd->xvec)    if (ibfd->xvec != obfd->xvec)
285      return true;      return TRUE;
286    ix = xcoff_data (ibfd);    ix = xcoff_data (ibfd);
287    ox = xcoff_data (obfd);    ox = xcoff_data (obfd);
288    ox->full_aouthdr = ix->full_aouthdr;    ox->full_aouthdr = ix->full_aouthdr;
# Line 284  _bfd_xcoff_copy_private_bfd_data (ibfd, Line 313  _bfd_xcoff_copy_private_bfd_data (ibfd,
313    ox->cputype = ix->cputype;    ox->cputype = ix->cputype;
314    ox->maxdata = ix->maxdata;    ox->maxdata = ix->maxdata;
315    ox->maxstack = ix->maxstack;    ox->maxstack = ix->maxstack;
316    return true;    return TRUE;
317  }  }
318    
319  /* I don't think XCOFF really has a notion of local labels based on  /* I don't think XCOFF really has a notion of local labels based on
# Line 292  _bfd_xcoff_copy_private_bfd_data (ibfd, Line 321  _bfd_xcoff_copy_private_bfd_data (ibfd,
321     The AIX native linker does not have a -X option, and it ignores the     The AIX native linker does not have a -X option, and it ignores the
322     -x option.  */     -x option.  */
323    
324  boolean  bfd_boolean
325  _bfd_xcoff_is_local_label_name (abfd, name)  _bfd_xcoff_is_local_label_name (abfd, name)
326       bfd *abfd ATTRIBUTE_UNUSED;       bfd *abfd ATTRIBUTE_UNUSED;
327       const char *name ATTRIBUTE_UNUSED;       const char *name ATTRIBUTE_UNUSED;
328  {  {
329    return false;    return FALSE;
330  }  }
331    
332  void  void
333  _bfd_xcoff_swap_sym_in (abfd, ext1, in1)  _bfd_xcoff_swap_sym_in (abfd, ext1, in1)
334       bfd            *abfd;       bfd *abfd;
335       PTR ext1;       PTR ext1;
336       PTR in1;       PTR in1;
337  {  {
# Line 311  _bfd_xcoff_swap_sym_in (abfd, ext1, in1) Line 340  _bfd_xcoff_swap_sym_in (abfd, ext1, in1)
340    
341    if (ext->e.e_name[0] != 0)    if (ext->e.e_name[0] != 0)
342      {      {
343        memcpy(in->_n._n_name, ext->e.e_name, SYMNMLEN);        memcpy (in->_n._n_name, ext->e.e_name, SYMNMLEN);
344      }      }
345    else    else
346      {      {
# Line 328  _bfd_xcoff_swap_sym_in (abfd, ext1, in1) Line 357  _bfd_xcoff_swap_sym_in (abfd, ext1, in1)
357    
358  unsigned int  unsigned int
359  _bfd_xcoff_swap_sym_out (abfd, inp, extp)  _bfd_xcoff_swap_sym_out (abfd, inp, extp)
360       bfd       *abfd;       bfd *abfd;
361       PTR        inp;       PTR inp;
362       PTR        extp;       PTR extp;
363  {  {
364    struct internal_syment *in = (struct internal_syment *)inp;    struct internal_syment *in = (struct internal_syment *)inp;
365    SYMENT *ext =(SYMENT *)extp;    SYMENT *ext =(SYMENT *)extp;
366    
367    if (in->_n._n_name[0] != 0)    if (in->_n._n_name[0] != 0)
368      {      {
369        memcpy(ext->e.e_name, in->_n._n_name, SYMNMLEN);        memcpy (ext->e.e_name, in->_n._n_name, SYMNMLEN);
370      }      }
371    else    else
372      {      {
# Line 355  _bfd_xcoff_swap_sym_out (abfd, inp, extp Line 384  _bfd_xcoff_swap_sym_out (abfd, inp, extp
384    
385  void  void
386  _bfd_xcoff_swap_aux_in (abfd, ext1, type, class, indx, numaux, in1)  _bfd_xcoff_swap_aux_in (abfd, ext1, type, class, indx, numaux, in1)
387       bfd            *abfd;       bfd *abfd;
388       PTR              ext1;       PTR ext1;
389       int             type;       int type;
390       int             class;       int class;
391       int              indx;       int indx;
392       int              numaux;       int numaux;
393       PTR              in1;       PTR in1;
394  {  {
395    AUXENT * ext = (AUXENT *)ext1;    AUXENT * ext = (AUXENT *)ext1;
396    union internal_auxent *in = (union internal_auxent *)in1;    union internal_auxent *in = (union internal_auxent *)in1;
# Line 418  _bfd_xcoff_swap_aux_in (abfd, ext1, type Line 447  _bfd_xcoff_swap_aux_in (abfd, ext1, type
447            in->x_scn.x_nreloc = H_GET_16 (abfd, ext->x_scn.x_nreloc);            in->x_scn.x_nreloc = H_GET_16 (abfd, ext->x_scn.x_nreloc);
448            in->x_scn.x_nlinno = H_GET_16 (abfd, ext->x_scn.x_nlinno);            in->x_scn.x_nlinno = H_GET_16 (abfd, ext->x_scn.x_nlinno);
449            /* PE defines some extra fields; we zero them out for            /* PE defines some extra fields; we zero them out for
450               safety.  */               safety.  */
451            in->x_scn.x_checksum = 0;            in->x_scn.x_checksum = 0;
452            in->x_scn.x_associated = 0;            in->x_scn.x_associated = 0;
453            in->x_scn.x_comdat = 0;            in->x_scn.x_comdat = 0;
# Line 468  _bfd_xcoff_swap_aux_in (abfd, ext1, type Line 497  _bfd_xcoff_swap_aux_in (abfd, ext1, type
497  }  }
498    
499    
500  unsigned int _bfd_xcoff_swap_aux_out PARAMS ((bfd *, PTR, int, int, int, int, PTR));  unsigned int _bfd_xcoff_swap_aux_out
501      PARAMS ((bfd *, PTR, int, int, int, int, PTR));
502    
503  unsigned int  unsigned int
504  _bfd_xcoff_swap_aux_out (abfd, inp, type, class, indx, numaux, extp)  _bfd_xcoff_swap_aux_out (abfd, inp, type, class, indx, numaux, extp)
# Line 483  _bfd_xcoff_swap_aux_out (abfd, inp, type Line 513  _bfd_xcoff_swap_aux_out (abfd, inp, type
513    union internal_auxent *in = (union internal_auxent *)inp;    union internal_auxent *in = (union internal_auxent *)inp;
514    AUXENT *ext = (AUXENT *)extp;    AUXENT *ext = (AUXENT *)extp;
515    
516    memset((PTR)ext, 0, bfd_coff_auxesz (abfd));    memset ((PTR)ext, 0, bfd_coff_auxesz (abfd));
517    switch (class)    switch (class)
518      {      {
519      case C_FILE:      case C_FILE:
# Line 578  end: Line 608  end:
608  reloc_howto_type xcoff_howto_table[] =  reloc_howto_type xcoff_howto_table[] =
609  {  {
610    /* Standard 32 bit relocation.  */    /* Standard 32 bit relocation.  */
611    HOWTO (R_POS,                 /* type */    HOWTO (R_POS,                 /* type */
612           0,                     /* rightshift */           0,                     /* rightshift */
613           2,                     /* size (0 = byte, 1 = short, 2 = long) */           2,                     /* size (0 = byte, 1 = short, 2 = long) */
614           32,                    /* bitsize */           32,                    /* bitsize */
615           false,                 /* pc_relative */           FALSE,                 /* pc_relative */
616           0,                     /* bitpos */           0,                     /* bitpos */
617           complain_overflow_bitfield, /* complain_on_overflow */           complain_overflow_bitfield, /* complain_on_overflow */
618           0,                     /* special_function */           0,                     /* special_function */
619           "R_POS",               /* name */           "R_POS",               /* name */
620           true,                  /* partial_inplace */           TRUE,                  /* partial_inplace */
621           0xffffffff,            /* src_mask */           0xffffffff,            /* src_mask */
622           0xffffffff,            /* dst_mask */           0xffffffff,            /* dst_mask */
623           false),                /* pcrel_offset */           FALSE),                /* pcrel_offset */
624    
625    /* 32 bit relocation, but store negative value.  */    /* 32 bit relocation, but store negative value.  */
626    HOWTO (R_NEG,                 /* type */    HOWTO (R_NEG,                 /* type */
627           0,                     /* rightshift */           0,                     /* rightshift */
628           -2,                    /* size (0 = byte, 1 = short, 2 = long) */           -2,                    /* size (0 = byte, 1 = short, 2 = long) */
629           32,                    /* bitsize */           32,                    /* bitsize */
630           false,                 /* pc_relative */           FALSE,                 /* pc_relative */
631           0,                     /* bitpos */           0,                     /* bitpos */
632           complain_overflow_bitfield, /* complain_on_overflow */           complain_overflow_bitfield, /* complain_on_overflow */
633           0,                     /* special_function */           0,                     /* special_function */
634           "R_NEG",               /* name */           "R_NEG",               /* name */
635           true,                  /* partial_inplace */           TRUE,                  /* partial_inplace */
636           0xffffffff,            /* src_mask */           0xffffffff,            /* src_mask */
637           0xffffffff,            /* dst_mask */           0xffffffff,            /* dst_mask */
638           false),                /* pcrel_offset */           FALSE),                /* pcrel_offset */
639    
640    /* 32 bit PC relative relocation.  */    /* 32 bit PC relative relocation.  */
641    HOWTO (R_REL,                 /* type */    HOWTO (R_REL,                 /* type */
642           0,                     /* rightshift */           0,                     /* rightshift */
643           2,                     /* size (0 = byte, 1 = short, 2 = long) */           2,                     /* size (0 = byte, 1 = short, 2 = long) */
644           32,                    /* bitsize */           32,                    /* bitsize */
645           true,                  /* pc_relative */           TRUE,                  /* pc_relative */
646           0,                     /* bitpos */           0,                     /* bitpos */
647           complain_overflow_signed, /* complain_on_overflow */           complain_overflow_signed, /* complain_on_overflow */
648           0,                     /* special_function */           0,                     /* special_function */
649           "R_REL",               /* name */           "R_REL",               /* name */
650           true,                  /* partial_inplace */           TRUE,                  /* partial_inplace */
651           0xffffffff,            /* src_mask */           0xffffffff,            /* src_mask */
652           0xffffffff,            /* dst_mask */           0xffffffff,            /* dst_mask */
653           false),                /* pcrel_offset */           FALSE),                /* pcrel_offset */
654    
655    /* 16 bit TOC relative relocation.  */    /* 16 bit TOC relative relocation.  */
656    HOWTO (R_TOC,                 /* type */    HOWTO (R_TOC,                 /* type */
657           0,                     /* rightshift */           0,                     /* rightshift */
658           1,                     /* size (0 = byte, 1 = short, 2 = long) */           1,                     /* size (0 = byte, 1 = short, 2 = long) */
659           16,                    /* bitsize */           16,                    /* bitsize */
660           false,                 /* pc_relative */           FALSE,                 /* pc_relative */
661           0,                     /* bitpos */           0,                     /* bitpos */
662           complain_overflow_bitfield, /* complain_on_overflow */           complain_overflow_bitfield, /* complain_on_overflow */
663           0,                     /* special_function */           0,                     /* special_function */
664           "R_TOC",               /* name */           "R_TOC",               /* name */
665           true,                  /* partial_inplace */           TRUE,                  /* partial_inplace */
666           0xffff,                /* src_mask */           0xffff,                /* src_mask */
667           0xffff,                /* dst_mask */           0xffff,                /* dst_mask */
668           false),                /* pcrel_offset */           FALSE),                /* pcrel_offset */
669    
670    /* I don't really know what this is.  */    /* I don't really know what this is.  */
671    HOWTO (R_RTB,                 /* type */    HOWTO (R_RTB,                 /* type */
672           1,                     /* rightshift */           1,                     /* rightshift */
673           2,                     /* size (0 = byte, 1 = short, 2 = long) */           2,                     /* size (0 = byte, 1 = short, 2 = long) */
674           32,                    /* bitsize */           32,                    /* bitsize */
675           false,                 /* pc_relative */           FALSE,                 /* pc_relative */
676           0,                     /* bitpos */           0,                     /* bitpos */
677           complain_overflow_bitfield, /* complain_on_overflow */           complain_overflow_bitfield, /* complain_on_overflow */
678           0,                     /* special_function */           0,                     /* special_function */
679           "R_RTB",               /* name */           "R_RTB",               /* name */
680           true,                  /* partial_inplace */           TRUE,                  /* partial_inplace */
681           0xffffffff,            /* src_mask */           0xffffffff,            /* src_mask */
682           0xffffffff,            /* dst_mask */           0xffffffff,            /* dst_mask */
683           false),                /* pcrel_offset */           FALSE),                /* pcrel_offset */
684    
685    /* External TOC relative symbol.  */    /* External TOC relative symbol.  */
686    HOWTO (R_GL,                  /* type */    HOWTO (R_GL,                  /* type */
687           0,                     /* rightshift */           0,                     /* rightshift */
688           2,                     /* size (0 = byte, 1 = short, 2 = long) */           1,                     /* size (0 = byte, 1 = short, 2 = long) */
689           16,                    /* bitsize */           16,                    /* bitsize */
690           false,                 /* pc_relative */           FALSE,                 /* pc_relative */
691           0,                     /* bitpos */           0,                     /* bitpos */
692           complain_overflow_bitfield, /* complain_on_overflow */           complain_overflow_bitfield, /* complain_on_overflow */
693           0,                     /* special_function */           0,                     /* special_function */
694           "R_GL",                /* name */           "R_GL",                /* name */
695           true,                  /* partial_inplace */           TRUE,                  /* partial_inplace */
696           0xffff,                /* src_mask */           0xffff,                /* src_mask */
697           0xffff,                /* dst_mask */           0xffff,                /* dst_mask */
698           false),                /* pcrel_offset */           FALSE),                /* pcrel_offset */
699    
700    /* Local TOC relative symbol.  */    /* Local TOC relative symbol.  */
701    HOWTO (R_TCL,                 /* type */    HOWTO (R_TCL,                 /* type */
702           0,                     /* rightshift */           0,                     /* rightshift */
703           2,                     /* size (0 = byte, 1 = short, 2 = long) */           1,                     /* size (0 = byte, 1 = short, 2 = long) */
704           16,                    /* bitsize */           16,                    /* bitsize */
705           false,                 /* pc_relative */           FALSE,                 /* pc_relative */
706           0,                     /* bitpos */           0,                     /* bitpos */
707           complain_overflow_bitfield, /* complain_on_overflow */           complain_overflow_bitfield, /* complain_on_overflow */
708           0,                     /* special_function */           0,                     /* special_function */
709           "R_TCL",               /* name */           "R_TCL",               /* name */
710           true,                  /* partial_inplace */           TRUE,                  /* partial_inplace */
711           0xffff,                /* src_mask */           0xffff,                /* src_mask */
712           0xffff,                /* dst_mask */           0xffff,                /* dst_mask */
713           false),                /* pcrel_offset */           FALSE),                /* pcrel_offset */
714    
715    EMPTY_HOWTO (7),    EMPTY_HOWTO (7),
716    
717    /* Non modifiable absolute branch.  */    /* Non modifiable absolute branch.  */
718    HOWTO (R_BA,                  /* type */    HOWTO (R_BA,                  /* type */
719           0,                     /* rightshift */           0,                     /* rightshift */
720           2,                     /* size (0 = byte, 1 = short, 2 = long) */           2,                     /* size (0 = byte, 1 = short, 2 = long) */
721           26,                    /* bitsize */           26,                    /* bitsize */
722           false,                 /* pc_relative */           FALSE,                 /* pc_relative */
723           0,                     /* bitpos */           0,                     /* bitpos */
724           complain_overflow_bitfield, /* complain_on_overflow */           complain_overflow_bitfield, /* complain_on_overflow */
725           0,                     /* special_function */           0,                     /* special_function */
726           "R_BA_26",             /* name */           "R_BA_26",             /* name */
727           true,                  /* partial_inplace */           TRUE,                  /* partial_inplace */
728           0x3fffffc,             /* src_mask */           0x03fffffc,            /* src_mask */
729           0x3fffffc,             /* dst_mask */           0x03fffffc,            /* dst_mask */
730           false),                /* pcrel_offset */           FALSE),                /* pcrel_offset */
731    
732    EMPTY_HOWTO (9),    EMPTY_HOWTO (9),
733    
734    /* Non modifiable relative branch.  */    /* Non modifiable relative branch.  */
735    HOWTO (R_BR,                  /* type */    HOWTO (R_BR,                  /* type */
736           0,                     /* rightshift */           0,                     /* rightshift */
737           2,                     /* size (0 = byte, 1 = short, 2 = long) */           2,                     /* size (0 = byte, 1 = short, 2 = long) */
738           26,                    /* bitsize */           26,                    /* bitsize */
739           true,                  /* pc_relative */           TRUE,                  /* pc_relative */
740           0,                     /* bitpos */           0,                     /* bitpos */
741           complain_overflow_signed, /* complain_on_overflow */           complain_overflow_signed, /* complain_on_overflow */
742           0,                     /* special_function */           0,                     /* special_function */
743           "R_BR",                /* name */           "R_BR",                /* name */
744           true,                  /* partial_inplace */           TRUE,                  /* partial_inplace */
745           0x3fffffc,             /* src_mask */           0x03fffffc,            /* src_mask */
746           0x3fffffc,             /* dst_mask */           0x03fffffc,            /* dst_mask */
747           false),                /* pcrel_offset */           FALSE),                /* pcrel_offset */
748    
749    EMPTY_HOWTO (0xb),    EMPTY_HOWTO (0xb),
750    
751    /* Indirect load.  */    /* Indirect load.  */
752    HOWTO (R_RL,                  /* type */    HOWTO (R_RL,                  /* type */
753           0,                     /* rightshift */           0,                     /* rightshift */
754           2,                     /* size (0 = byte, 1 = short, 2 = long) */           1,                     /* size (0 = byte, 1 = short, 2 = long) */
755           16,                    /* bitsize */           16,                    /* bitsize */
756           false,                 /* pc_relative */           FALSE,                 /* pc_relative */
757           0,                     /* bitpos */           0,                     /* bitpos */
758           complain_overflow_bitfield, /* complain_on_overflow */           complain_overflow_bitfield, /* complain_on_overflow */
759           0,                     /* special_function */           0,                     /* special_function */
760           "R_RL",                /* name */           "R_RL",                /* name */
761           true,                  /* partial_inplace */           TRUE,                  /* partial_inplace */
762           0xffff,                /* src_mask */           0xffff,                /* src_mask */
763           0xffff,                /* dst_mask */           0xffff,                /* dst_mask */
764           false),                /* pcrel_offset */           FALSE),                /* pcrel_offset */
765    
766    /* Load address.  */    /* Load address.  */
767    HOWTO (R_RLA,                 /* type */    HOWTO (R_RLA,                 /* type */
768           0,                     /* rightshift */           0,                     /* rightshift */
769           2,                     /* size (0 = byte, 1 = short, 2 = long) */           1,                     /* size (0 = byte, 1 = short, 2 = long) */
770           16,                    /* bitsize */           16,                    /* bitsize */
771           false,                 /* pc_relative */           FALSE,                 /* pc_relative */
772           0,                     /* bitpos */           0,                     /* bitpos */
773           complain_overflow_bitfield, /* complain_on_overflow */           complain_overflow_bitfield, /* complain_on_overflow */
774           0,                     /* special_function */           0,                     /* special_function */
775           "R_RLA",               /* name */           "R_RLA",               /* name */
776           true,                  /* partial_inplace */           TRUE,                  /* partial_inplace */
777           0xffff,                /* src_mask */           0xffff,                /* src_mask */
778           0xffff,                /* dst_mask */           0xffff,                /* dst_mask */
779           false),                /* pcrel_offset */           FALSE),                /* pcrel_offset */
780    
781    EMPTY_HOWTO (0xe),    EMPTY_HOWTO (0xe),
782    
783    /* Non-relocating reference.  */    /* Non-relocating reference.  */
784    HOWTO (R_REF,                 /* type */    HOWTO (R_REF,                 /* type */
785           0,                     /* rightshift */           0,                     /* rightshift */
786           2,                     /* size (0 = byte, 1 = short, 2 = long) */           2,                     /* size (0 = byte, 1 = short, 2 = long) */
787           32,                    /* bitsize */           32,                    /* bitsize */
788           false,                 /* pc_relative */           FALSE,                 /* pc_relative */
789           0,                     /* bitpos */           0,                     /* bitpos */
790           complain_overflow_bitfield, /* complain_on_overflow */           complain_overflow_dont, /* complain_on_overflow */
791           0,                     /* special_function */           0,                     /* special_function */
792           "R_REF",               /* name */           "R_REF",               /* name */
793           false,                 /* partial_inplace */           FALSE,                 /* partial_inplace */
794           0,                     /* src_mask */           0,                     /* src_mask */
795           0,                     /* dst_mask */           0,                     /* dst_mask */
796           false),                /* pcrel_offset */           FALSE),                /* pcrel_offset */
797    
798    EMPTY_HOWTO (0x10),    EMPTY_HOWTO (0x10),
799    EMPTY_HOWTO (0x11),    EMPTY_HOWTO (0x11),
800    
801    /* TOC relative indirect load.  */    /* TOC relative indirect load.  */
802    HOWTO (R_TRL,                 /* type */    HOWTO (R_TRL,                 /* type */
803           0,                     /* rightshift */           0,                     /* rightshift */
804           2,                     /* size (0 = byte, 1 = short, 2 = long) */           1,                     /* size (0 = byte, 1 = short, 2 = long) */
805           16,                    /* bitsize */           16,                    /* bitsize */
806           false,                 /* pc_relative */           FALSE,                 /* pc_relative */
807           0,                     /* bitpos */           0,                     /* bitpos */
808           complain_overflow_bitfield, /* complain_on_overflow */           complain_overflow_bitfield, /* complain_on_overflow */
809           0,                     /* special_function */           0,                     /* special_function */
810           "R_TRL",               /* name */           "R_TRL",               /* name */
811           true,                  /* partial_inplace */           TRUE,                  /* partial_inplace */
812           0xffff,                /* src_mask */           0xffff,                /* src_mask */
813           0xffff,                /* dst_mask */           0xffff,                /* dst_mask */
814           false),                /* pcrel_offset */           FALSE),                /* pcrel_offset */
815    
816    /* TOC relative load address.  */    /* TOC relative load address.  */
817    HOWTO (R_TRLA,                /* type */    HOWTO (R_TRLA,                /* type */
818           0,                     /* rightshift */           0,                     /* rightshift */
819           2,                     /* size (0 = byte, 1 = short, 2 = long) */           1,                     /* size (0 = byte, 1 = short, 2 = long) */
820           16,                    /* bitsize */           16,                    /* bitsize */
821           false,                 /* pc_relative */           FALSE,                 /* pc_relative */
822           0,                     /* bitpos */           0,                     /* bitpos */
823           complain_overflow_bitfield, /* complain_on_overflow */           complain_overflow_bitfield, /* complain_on_overflow */
824           0,                     /* special_function */           0,                     /* special_function */
825           "R_TRLA",              /* name */           "R_TRLA",              /* name */
826           true,                  /* partial_inplace */           TRUE,                  /* partial_inplace */
827           0xffff,                /* src_mask */           0xffff,                /* src_mask */
828           0xffff,                /* dst_mask */           0xffff,                /* dst_mask */
829           false),                /* pcrel_offset */           FALSE),                /* pcrel_offset */
830    
831    /* Modifiable relative branch.  */    /* Modifiable relative branch.  */
832    HOWTO (R_RRTBI,                /* type */    HOWTO (R_RRTBI,                /* type */
833           1,                     /* rightshift */           1,                     /* rightshift */
834           2,                     /* size (0 = byte, 1 = short, 2 = long) */           2,                     /* size (0 = byte, 1 = short, 2 = long) */
835           32,                    /* bitsize */           32,                    /* bitsize */
836           false,                 /* pc_relative */           FALSE,                 /* pc_relative */
837           0,                     /* bitpos */           0,                     /* bitpos */
838           complain_overflow_bitfield, /* complain_on_overflow */           complain_overflow_bitfield, /* complain_on_overflow */
839           0,                     /* special_function */           0,                     /* special_function */
840           "R_RRTBI",             /* name */           "R_RRTBI",             /* name */
841           true,                  /* partial_inplace */           TRUE,                  /* partial_inplace */
842           0xffffffff,            /* src_mask */           0xffffffff,            /* src_mask */
843           0xffffffff,            /* dst_mask */           0xffffffff,            /* dst_mask */
844           false),                /* pcrel_offset */           FALSE),                /* pcrel_offset */
845    
846    /* Modifiable absolute branch.  */    /* Modifiable absolute branch.  */
847    HOWTO (R_RRTBA,                /* type */    HOWTO (R_RRTBA,                /* type */
848           1,                     /* rightshift */           1,                     /* rightshift */
849           2,                     /* size (0 = byte, 1 = short, 2 = long) */           2,                     /* size (0 = byte, 1 = short, 2 = long) */
850           32,                    /* bitsize */           32,                    /* bitsize */
851           false,                 /* pc_relative */           FALSE,                 /* pc_relative */
852           0,                     /* bitpos */           0,                     /* bitpos */
853           complain_overflow_bitfield, /* complain_on_overflow */           complain_overflow_bitfield, /* complain_on_overflow */
854           0,                     /* special_function */           0,                     /* special_function */
855           "R_RRTBA",             /* name */           "R_RRTBA",             /* name */
856           true,                  /* partial_inplace */           TRUE,                  /* partial_inplace */
857           0xffffffff,            /* src_mask */           0xffffffff,            /* src_mask */
858           0xffffffff,            /* dst_mask */           0xffffffff,            /* dst_mask */
859           false),                /* pcrel_offset */           FALSE),                /* pcrel_offset */
860    
861    /* Modifiable call absolute indirect.  */    /* Modifiable call absolute indirect.  */
862    HOWTO (R_CAI,                 /* type */    HOWTO (R_CAI,                 /* type */
863           0,                     /* rightshift */           0,                     /* rightshift */
864           2,                     /* size (0 = byte, 1 = short, 2 = long) */           1,                     /* size (0 = byte, 1 = short, 2 = long) */
865           16,                    /* bitsize */           16,                    /* bitsize */
866           false,                 /* pc_relative */           FALSE,                 /* pc_relative */
867           0,                     /* bitpos */           0,                     /* bitpos */
868           complain_overflow_bitfield, /* complain_on_overflow */           complain_overflow_bitfield, /* complain_on_overflow */
869           0,                     /* special_function */           0,                     /* special_function */
870           "R_CAI",               /* name */           "R_CAI",               /* name */
871           true,                  /* partial_inplace */           TRUE,                  /* partial_inplace */
872           0xffff,                /* src_mask */           0xffff,                /* src_mask */
873           0xffff,                /* dst_mask */           0xffff,                /* dst_mask */
874           false),                /* pcrel_offset */           FALSE),                /* pcrel_offset */
875    
876    /* Modifiable call relative.  */    /* Modifiable call relative.  */
877    HOWTO (R_CREL,                /* type */    HOWTO (R_CREL,                /* type */
878           0,                     /* rightshift */           0,                     /* rightshift */
879           2,                     /* size (0 = byte, 1 = short, 2 = long) */           1,                     /* size (0 = byte, 1 = short, 2 = long) */
880           16,                    /* bitsize */           16,                    /* bitsize */
881           false,                 /* pc_relative */           FALSE,                 /* pc_relative */
882           0,                     /* bitpos */           0,                     /* bitpos */
883           complain_overflow_bitfield, /* complain_on_overflow */           complain_overflow_bitfield, /* complain_on_overflow */
884           0,                     /* special_function */           0,                     /* special_function */
885           "R_CREL",              /* name */           "R_CREL",              /* name */
886           true,                  /* partial_inplace */           TRUE,                  /* partial_inplace */
887           0xffff,                /* src_mask */           0xffff,                /* src_mask */
888           0xffff,                /* dst_mask */           0xffff,                /* dst_mask */
889           false),                /* pcrel_offset */           FALSE),                /* pcrel_offset */
890    
891    /* Modifiable branch absolute.  */    /* Modifiable branch absolute.  */
892    HOWTO (R_RBA,                 /* type */    HOWTO (R_RBA,                 /* type */
893           0,                     /* rightshift */           0,                     /* rightshift */
894           2,                     /* size (0 = byte, 1 = short, 2 = long) */           2,                     /* size (0 = byte, 1 = short, 2 = long) */
895           26,                    /* bitsize */           26,                    /* bitsize */
896           false,                 /* pc_relative */           FALSE,                 /* pc_relative */
897           0,                     /* bitpos */           0,                     /* bitpos */
898           complain_overflow_bitfield, /* complain_on_overflow */           complain_overflow_bitfield, /* complain_on_overflow */
899           0,                     /* special_function */           0,                     /* special_function */
900           "R_RBA",               /* name */           "R_RBA",               /* name */
901           true,                  /* partial_inplace */           TRUE,                  /* partial_inplace */
902           0xffff,                /* src_mask */           0x03fffffc,            /* src_mask */
903           0xffff,                /* dst_mask */           0x03fffffc,            /* dst_mask */
904           false),                /* pcrel_offset */           FALSE),                /* pcrel_offset */
905    
906    /* Modifiable branch absolute.  */    /* Modifiable branch absolute.  */
907    HOWTO (R_RBAC,                /* type */    HOWTO (R_RBAC,                /* type */
908           0,                     /* rightshift */           0,                     /* rightshift */
909           2,                     /* size (0 = byte, 1 = short, 2 = long) */           2,                     /* size (0 = byte, 1 = short, 2 = long) */
910           32,                    /* bitsize */           32,                    /* bitsize */
911           false,                 /* pc_relative */           FALSE,                 /* pc_relative */
912           0,                     /* bitpos */           0,                     /* bitpos */
913           complain_overflow_bitfield, /* complain_on_overflow */           complain_overflow_bitfield, /* complain_on_overflow */
914           0,                     /* special_function */           0,                     /* special_function */
915           "R_RBAC",              /* name */           "R_RBAC",              /* name */
916           true,                  /* partial_inplace */           TRUE,                  /* partial_inplace */
917           0xffff,                /* src_mask */           0xffffffff,            /* src_mask */
918           0xffff,                /* dst_mask */           0xffffffff,            /* dst_mask */
919           false),                /* pcrel_offset */           FALSE),                /* pcrel_offset */
920    
921    /* Modifiable branch relative.  */    /* Modifiable branch relative.  */
922    HOWTO (R_RBR,                 /* type */    HOWTO (R_RBR,                 /* type */
923           0,                     /* rightshift */           0,                     /* rightshift */
924           2,                     /* size (0 = byte, 1 = short, 2 = long) */           2,                     /* size (0 = byte, 1 = short, 2 = long) */
925           26,                    /* bitsize */           26,                    /* bitsize */
926           false,                 /* pc_relative */           FALSE,                 /* pc_relative */
927           0,                     /* bitpos */           0,                     /* bitpos */
928           complain_overflow_signed, /* complain_on_overflow */           complain_overflow_signed, /* complain_on_overflow */
929           0,                     /* special_function */           0,                     /* special_function */
930           "R_RBR_26",            /* name */           "R_RBR_26",            /* name */
931           true,                  /* partial_inplace */           TRUE,                  /* partial_inplace */
932           0xffff,                /* src_mask */           0x03fffffc,            /* src_mask */
933           0xffff,                /* dst_mask */           0x03fffffc,            /* dst_mask */
934           false),                /* pcrel_offset */           FALSE),                /* pcrel_offset */
935    
936    /* Modifiable branch absolute.  */    /* Modifiable branch absolute.  */
937    HOWTO (R_RBRC,                /* type */    HOWTO (R_RBRC,                /* type */
938           0,                     /* rightshift */           0,                     /* rightshift */
939           2,                     /* size (0 = byte, 1 = short, 2 = long) */           1,                     /* size (0 = byte, 1 = short, 2 = long) */
940           16,                    /* bitsize */           16,                    /* bitsize */
941           false,                 /* pc_relative */           FALSE,                 /* pc_relative */
942           0,                     /* bitpos */           0,                     /* bitpos */
943           complain_overflow_bitfield, /* complain_on_overflow */           complain_overflow_bitfield, /* complain_on_overflow */
944           0,                     /* special_function */           0,                     /* special_function */
945           "R_RBRC",              /* name */           "R_RBRC",              /* name */
946           true,                  /* partial_inplace */           TRUE,                  /* partial_inplace */
947           0xffff,                /* src_mask */           0xffff,                /* src_mask */
948           0xffff,                /* dst_mask */           0xffff,                /* dst_mask */
949           false),                /* pcrel_offset */           FALSE),                /* pcrel_offset */
950    
951    /* 16 bit Non modifiable absolute branch.  */    /* 16 bit Non modifiable absolute branch.  */
952    HOWTO (R_BA,                  /* type */    HOWTO (R_BA,                  /* type */
953           0,                     /* rightshift */           0,                     /* rightshift */
954           1,                     /* size (0 = byte, 1 = short, 2 = long) */           1,                     /* size (0 = byte, 1 = short, 2 = long) */
955           16,                    /* bitsize */           16,                    /* bitsize */
956           false,                 /* pc_relative */           FALSE,                 /* pc_relative */
957           0,                     /* bitpos */           0,                     /* bitpos */
958           complain_overflow_bitfield, /* complain_on_overflow */           complain_overflow_bitfield, /* complain_on_overflow */
959           0,                     /* special_function */           0,                     /* special_function */
960           "R_BA_16",             /* name */           "R_BA_16",             /* name */
961           true,                  /* partial_inplace */           TRUE,                  /* partial_inplace */
962           0xfffc,                /* src_mask */           0xfffc,                /* src_mask */
963           0xfffc,                /* dst_mask */           0xfffc,                /* dst_mask */
964           false),                /* pcrel_offset */           FALSE),                /* pcrel_offset */
965    
966    /* Modifiable branch relative.  */    /* Modifiable branch relative.  */
967    HOWTO (R_RBR,                 /* type */    HOWTO (R_RBR,                 /* type */
968           0,                     /* rightshift */           0,                     /* rightshift */
969           1,                     /* size (0 = byte, 1 = short, 2 = long) */           1,                     /* size (0 = byte, 1 = short, 2 = long) */
970           16,                    /* bitsize */           16,                    /* bitsize */
971           false,                 /* pc_relative */           FALSE,                 /* pc_relative */
972           0,                     /* bitpos */           0,                     /* bitpos */
973           complain_overflow_signed, /* complain_on_overflow */           complain_overflow_signed, /* complain_on_overflow */
974           0,                     /* special_function */           0,                     /* special_function */
975           "R_RBR_16",            /* name */           "R_RBR_16",            /* name */
976           true,                  /* partial_inplace */           TRUE,                  /* partial_inplace */
977           0xffff,                /* src_mask */           0xffff,                /* src_mask */
978           0xffff,                /* dst_mask */           0xffff,                /* dst_mask */
979           false),                /* pcrel_offset */           FALSE),                /* pcrel_offset */
980    
981    /* Modifiable branch relative.  */    /* Modifiable branch relative.  */
982    HOWTO (R_RBA,                 /* type */    HOWTO (R_RBA,                 /* type */
983           0,                     /* rightshift */           0,                     /* rightshift */
984           1,                     /* size (0 = byte, 1 = short, 2 = long) */           1,                     /* size (0 = byte, 1 = short, 2 = long) */
985           16,                    /* bitsize */           16,                    /* bitsize */
986           false,                 /* pc_relative */           FALSE,                 /* pc_relative */
987           0,                     /* bitpos */           0,                     /* bitpos */
988           complain_overflow_signed, /* complain_on_overflow */           complain_overflow_signed, /* complain_on_overflow */
989           0,                     /* special_function */           0,                     /* special_function */
990           "R_RBA_16",            /* name */           "R_RBA_16",            /* name */
991           true,                  /* partial_inplace */           TRUE,                  /* partial_inplace */
992           0xffff,                /* src_mask */           0xffff,                /* src_mask */
993           0xffff,                /* dst_mask */           0xffff,                /* dst_mask */
994           false),                /* pcrel_offset */           FALSE),                /* pcrel_offset */
995    
996  };  };
997    
# Line 975  xcoff_rtype2howto (relent, internal) Line 1005  xcoff_rtype2howto (relent, internal)
1005    
1006    /* Default howto layout works most of the time */    /* Default howto layout works most of the time */
1007    relent->howto = &xcoff_howto_table[internal->r_type];    relent->howto = &xcoff_howto_table[internal->r_type];
1008      
1009    /* Special case some 16 bit reoloc */    /* Special case some 16 bit reloc */
1010    if (15 == (internal->r_size & 0x1f))    if (15 == (internal->r_size & 0x1f))
1011      {      {
1012        if (R_BA == internal->r_type)        if (R_BA == internal->r_type)
1013          relent->howto = &xcoff_howto_table[0x1c];          relent->howto = &xcoff_howto_table[0x1c];
1014        else if (R_RBR == internal->r_type)        else if (R_RBR == internal->r_type)
1015          relent->howto = &xcoff_howto_table[0x1d];          relent->howto = &xcoff_howto_table[0x1d];
1016        else if (R_RBA == internal->r_type)        else if (R_RBA == internal->r_type)
1017          relent->howto = &xcoff_howto_table[0x1e];          relent->howto = &xcoff_howto_table[0x1e];
1018      }      }
1019      
1020    /* The r_size field of an XCOFF reloc encodes the bitsize of the    /* The r_size field of an XCOFF reloc encodes the bitsize of the
1021       relocation, as well as indicating whether it is signed or not.       relocation, as well as indicating whether it is signed or not.
1022       Doublecheck that the relocation information gathered from the       Doublecheck that the relocation information gathered from the
# Line 996  xcoff_rtype2howto (relent, internal) Line 1026  xcoff_rtype2howto (relent, internal)
1026        && (relent->howto->bitsize        && (relent->howto->bitsize
1027            != ((unsigned int) internal->r_size & 0x1f) + 1))            != ((unsigned int) internal->r_size & 0x1f) + 1))
1028      abort ();      abort ();
   
   /* Put a meaningful value in addend */  
   relent->addend = (internal->r_size & 0x80) ? - internal->r_vaddr  
     : internal->r_vaddr;  
1029  }  }
1030    
1031  reloc_howto_type *  reloc_howto_type *
# Line 1073  _bfd_xcoff_reloc_type_lookup (abfd, code Line 1099  _bfd_xcoff_reloc_type_lookup (abfd, code
1099    
1100  /* Set the magic for archive.  */  /* Set the magic for archive.  */
1101    
1102  boolean  bfd_boolean
1103  bfd_xcoff_ar_archive_set_magic (abfd, magic)  bfd_xcoff_ar_archive_set_magic (abfd, magic)
1104       bfd *abfd ATTRIBUTE_UNUSED;       bfd *abfd ATTRIBUTE_UNUSED;
1105       char *magic ATTRIBUTE_UNUSED;       char *magic ATTRIBUTE_UNUSED;
1106  {  {
1107    /* Not supported yet.  */    /* Not supported yet.  */
1108    return false;    return FALSE;
1109   /* bfd_xcoff_archive_set_magic (abfd, magic); */   /* bfd_xcoff_archive_set_magic (abfd, magic); */
1110  }  }
1111    
1112  /* Read in the armap of an XCOFF archive.  */  /* Read in the armap of an XCOFF archive.  */
1113    
1114  boolean  bfd_boolean
1115  _bfd_xcoff_slurp_armap (abfd)  _bfd_xcoff_slurp_armap (abfd)
1116       bfd *abfd;       bfd *abfd;
1117  {  {
# Line 1099  _bfd_xcoff_slurp_armap (abfd) Line 1125  _bfd_xcoff_slurp_armap (abfd)
1125    
1126    if (xcoff_ardata (abfd) == NULL)    if (xcoff_ardata (abfd) == NULL)
1127      {      {
1128        bfd_has_map (abfd) = false;        bfd_has_map (abfd) = FALSE;
1129        return true;        return TRUE;
1130      }      }
1131    
1132    if (! xcoff_big_format_p (abfd))    if (! xcoff_big_format_p (abfd))
# Line 1111  _bfd_xcoff_slurp_armap (abfd) Line 1137  _bfd_xcoff_slurp_armap (abfd)
1137        off = strtol (xcoff_ardata (abfd)->symoff, (char **) NULL, 10);        off = strtol (xcoff_ardata (abfd)->symoff, (char **) NULL, 10);
1138        if (off == 0)        if (off == 0)
1139          {          {
1140            bfd_has_map (abfd) = false;            bfd_has_map (abfd) = FALSE;
1141            return true;            return TRUE;
1142          }          }
1143    
1144        if (bfd_seek (abfd, off, SEEK_SET) != 0)        if (bfd_seek (abfd, off, SEEK_SET) != 0)
1145          return false;          return FALSE;
1146    
1147        /* The symbol table starts with a normal archive header.  */        /* The symbol table starts with a normal archive header.  */
1148        if (bfd_bread ((PTR) &hdr, (bfd_size_type) SIZEOF_AR_HDR, abfd)        if (bfd_bread ((PTR) &hdr, (bfd_size_type) SIZEOF_AR_HDR, abfd)
1149            != SIZEOF_AR_HDR)            != SIZEOF_AR_HDR)
1150          return false;          return FALSE;
1151    
1152        /* Skip the name (normally empty).  */        /* Skip the name (normally empty).  */
1153        namlen = strtol (hdr.namlen, (char **) NULL, 10);        namlen = strtol (hdr.namlen, (char **) NULL, 10);
1154        off = ((namlen + 1) & ~ (size_t) 1) + SXCOFFARFMAG;        off = ((namlen + 1) & ~ (size_t) 1) + SXCOFFARFMAG;
1155        if (bfd_seek (abfd, off, SEEK_CUR) != 0)        if (bfd_seek (abfd, off, SEEK_CUR) != 0)
1156          return false;          return FALSE;
1157    
1158        sz = strtol (hdr.size, (char **) NULL, 10);        sz = strtol (hdr.size, (char **) NULL, 10);
1159    
1160        /* Read in the entire symbol table.  */        /* Read in the entire symbol table.  */
1161        contents = (bfd_byte *) bfd_alloc (abfd, sz);        contents = (bfd_byte *) bfd_alloc (abfd, sz);
1162        if (contents == NULL)        if (contents == NULL)
1163          return false;          return FALSE;
1164        if (bfd_bread ((PTR) contents, sz, abfd) != sz)        if (bfd_bread ((PTR) contents, sz, abfd) != sz)
1165          return false;          return FALSE;
1166    
1167        /* The symbol table starts with a four byte count.  */        /* The symbol table starts with a four byte count.  */
1168        c = H_GET_32 (abfd, contents);        c = H_GET_32 (abfd, contents);
# Line 1144  _bfd_xcoff_slurp_armap (abfd) Line 1170  _bfd_xcoff_slurp_armap (abfd)
1170        if (c * 4 >= sz)        if (c * 4 >= sz)
1171          {          {
1172            bfd_set_error (bfd_error_bad_value);            bfd_set_error (bfd_error_bad_value);
1173            return false;            return FALSE;
1174          }          }
1175    
1176        bfd_ardata (abfd)->symdefs =        bfd_ardata (abfd)->symdefs =
1177          ((carsym *) bfd_alloc (abfd, c * sizeof (carsym)));          ((carsym *) bfd_alloc (abfd, c * sizeof (carsym)));
1178        if (bfd_ardata (abfd)->symdefs == NULL)        if (bfd_ardata (abfd)->symdefs == NULL)
1179          return false;          return FALSE;
1180    
1181        /* After the count comes a list of four byte file offsets.  */        /* After the count comes a list of four byte file offsets.  */
1182        for (i = 0, arsym = bfd_ardata (abfd)->symdefs, p = contents + 4;        for (i = 0, arsym = bfd_ardata (abfd)->symdefs, p = contents + 4;
# Line 1166  _bfd_xcoff_slurp_armap (abfd) Line 1192  _bfd_xcoff_slurp_armap (abfd)
1192        off = strtol (xcoff_ardata_big (abfd)->symoff, (char **) NULL, 10);        off = strtol (xcoff_ardata_big (abfd)->symoff, (char **) NULL, 10);
1193        if (off == 0)        if (off == 0)
1194          {          {
1195            bfd_has_map (abfd) = false;            bfd_has_map (abfd) = FALSE;
1196            return true;            return TRUE;
1197          }          }
1198    
1199        if (bfd_seek (abfd, off, SEEK_SET) != 0)        if (bfd_seek (abfd, off, SEEK_SET) != 0)
1200          return false;          return FALSE;
1201    
1202        /* The symbol table starts with a normal archive header.  */        /* The symbol table starts with a normal archive header.  */
1203        if (bfd_bread ((PTR) &hdr, (bfd_size_type) SIZEOF_AR_HDR_BIG, abfd)        if (bfd_bread ((PTR) &hdr, (bfd_size_type) SIZEOF_AR_HDR_BIG, abfd)
1204            != SIZEOF_AR_HDR_BIG)            != SIZEOF_AR_HDR_BIG)
1205          return false;          return FALSE;
1206    
1207        /* Skip the name (normally empty).  */        /* Skip the name (normally empty).  */
1208        namlen = strtol (hdr.namlen, (char **) NULL, 10);        namlen = strtol (hdr.namlen, (char **) NULL, 10);
1209        off = ((namlen + 1) & ~ (size_t) 1) + SXCOFFARFMAG;        off = ((namlen + 1) & ~ (size_t) 1) + SXCOFFARFMAG;
1210        if (bfd_seek (abfd, off, SEEK_CUR) != 0)        if (bfd_seek (abfd, off, SEEK_CUR) != 0)
1211          return false;          return FALSE;
1212    
1213        /* XXX This actually has to be a call to strtoll (at least on 32-bit        /* XXX This actually has to be a call to strtoll (at least on 32-bit
1214           machines) since the field width is 20 and there numbers with more           machines) since the field width is 20 and there numbers with more
# Line 1192  _bfd_xcoff_slurp_armap (abfd) Line 1218  _bfd_xcoff_slurp_armap (abfd)
1218        /* Read in the entire symbol table.  */        /* Read in the entire symbol table.  */
1219        contents = (bfd_byte *) bfd_alloc (abfd, sz);        contents = (bfd_byte *) bfd_alloc (abfd, sz);
1220        if (contents == NULL)        if (contents == NULL)
1221          return false;          return FALSE;
1222        if (bfd_bread ((PTR) contents, sz, abfd) != sz)        if (bfd_bread ((PTR) contents, sz, abfd) != sz)
1223          return false;          return FALSE;
1224    
1225        /* The symbol table starts with an eight byte count.  */        /* The symbol table starts with an eight byte count.  */
1226        c = H_GET_64 (abfd, contents);        c = H_GET_64 (abfd, contents);
# Line 1202  _bfd_xcoff_slurp_armap (abfd) Line 1228  _bfd_xcoff_slurp_armap (abfd)
1228        if (c * 8 >= sz)        if (c * 8 >= sz)
1229          {          {
1230            bfd_set_error (bfd_error_bad_value);            bfd_set_error (bfd_error_bad_value);
1231            return false;            return FALSE;
1232          }          }
1233    
1234        bfd_ardata (abfd)->symdefs =        bfd_ardata (abfd)->symdefs =
1235          ((carsym *) bfd_alloc (abfd, c * sizeof (carsym)));          ((carsym *) bfd_alloc (abfd, c * sizeof (carsym)));
1236        if (bfd_ardata (abfd)->symdefs == NULL)        if (bfd_ardata (abfd)->symdefs == NULL)
1237          return false;          return FALSE;
1238    
1239        /* After the count comes a list of eight byte file offsets.  */        /* After the count comes a list of eight byte file offsets.  */
1240        for (i = 0, arsym = bfd_ardata (abfd)->symdefs, p = contents + 8;        for (i = 0, arsym = bfd_ardata (abfd)->symdefs, p = contents + 8;
# Line 1226  _bfd_xcoff_slurp_armap (abfd) Line 1252  _bfd_xcoff_slurp_armap (abfd)
1252        if (p >= cend)        if (p >= cend)
1253          {          {
1254            bfd_set_error (bfd_error_bad_value);            bfd_set_error (bfd_error_bad_value);
1255            return false;            return FALSE;
1256          }          }
1257        arsym->name = (char *) p;        arsym->name = (char *) p;
1258      }      }
1259    
1260    bfd_ardata (abfd)->symdef_count = c;    bfd_ardata (abfd)->symdef_count = c;
1261    bfd_has_map (abfd) = true;    bfd_has_map (abfd) = TRUE;
1262    
1263    return true;    return TRUE;
1264  }  }
1265    
1266  /* See if this is an XCOFF archive.  */  /* See if this is an XCOFF archive.  */
# Line 1243  const bfd_target * Line 1269  const bfd_target *
1269  _bfd_xcoff_archive_p (abfd)  _bfd_xcoff_archive_p (abfd)
1270       bfd *abfd;       bfd *abfd;
1271  {  {
1272      struct artdata *tdata_hold;
1273    char magic[SXCOFFARMAG];    char magic[SXCOFFARMAG];
1274    bfd_size_type amt;    bfd_size_type amt = SXCOFFARMAG;
1275    
1276    if (bfd_bread ((PTR) magic, (bfd_size_type) SXCOFFARMAG, abfd) != SXCOFFARMAG)    if (bfd_bread ((PTR) magic, amt, abfd) != amt)
1277      {      {
1278        if (bfd_get_error () != bfd_error_system_call)        if (bfd_get_error () != bfd_error_system_call)
1279          bfd_set_error (bfd_error_wrong_format);          bfd_set_error (bfd_error_wrong_format);
# Line 1260  _bfd_xcoff_archive_p (abfd) Line 1287  _bfd_xcoff_archive_p (abfd)
1287        return NULL;        return NULL;
1288      }      }
1289    
1290    /* We are setting bfd_ardata(abfd) here, but since bfd_ardata    tdata_hold = bfd_ardata (abfd);
1291       involves a cast, we can't do it as the left operand of  
      assignment.  */  
1292    amt = sizeof (struct artdata);    amt = sizeof (struct artdata);
1293    abfd->tdata.aout_ar_data = (struct artdata *) bfd_zalloc (abfd, amt);    bfd_ardata (abfd) = (struct artdata *) bfd_zalloc (abfd, amt);
1294    if (bfd_ardata (abfd) == (struct artdata *) NULL)    if (bfd_ardata (abfd) == (struct artdata *) NULL)
1295      return NULL;      goto error_ret_restore;
1296    
1297    bfd_ardata (abfd)->cache = NULL;    bfd_ardata (abfd)->cache = NULL;
1298    bfd_ardata (abfd)->archive_head = NULL;    bfd_ardata (abfd)->archive_head = NULL;
# Line 1283  _bfd_xcoff_archive_p (abfd) Line 1309  _bfd_xcoff_archive_p (abfd)
1309        memcpy (hdr.magic, magic, SXCOFFARMAG);        memcpy (hdr.magic, magic, SXCOFFARMAG);
1310    
1311        /* Now read the rest of the file header.  */        /* Now read the rest of the file header.  */
1312        if (bfd_bread ((PTR) &hdr.memoff,        amt = SIZEOF_AR_FILE_HDR - SXCOFFARMAG;
1313                      (bfd_size_type) SIZEOF_AR_FILE_HDR - SXCOFFARMAG, abfd)        if (bfd_bread ((PTR) &hdr.memoff, amt, abfd) != amt)
           != SIZEOF_AR_FILE_HDR - SXCOFFARMAG)  
1314          {          {
1315            if (bfd_get_error () != bfd_error_system_call)            if (bfd_get_error () != bfd_error_system_call)
1316              bfd_set_error (bfd_error_wrong_format);              bfd_set_error (bfd_error_wrong_format);
1317            return NULL;            goto error_ret;
1318          }          }
1319    
1320        bfd_ardata (abfd)->first_file_filepos = strtol (hdr.firstmemoff,        bfd_ardata (abfd)->first_file_filepos = strtol (hdr.firstmemoff,
# Line 1298  _bfd_xcoff_archive_p (abfd) Line 1323  _bfd_xcoff_archive_p (abfd)
1323        amt = SIZEOF_AR_FILE_HDR;        amt = SIZEOF_AR_FILE_HDR;
1324        bfd_ardata (abfd)->tdata = bfd_zalloc (abfd, amt);        bfd_ardata (abfd)->tdata = bfd_zalloc (abfd, amt);
1325        if (bfd_ardata (abfd)->tdata == NULL)        if (bfd_ardata (abfd)->tdata == NULL)
1326          return NULL;          goto error_ret;
1327    
1328        memcpy (bfd_ardata (abfd)->tdata, &hdr, SIZEOF_AR_FILE_HDR);        memcpy (bfd_ardata (abfd)->tdata, &hdr, SIZEOF_AR_FILE_HDR);
1329      }      }
# Line 1311  _bfd_xcoff_archive_p (abfd) Line 1336  _bfd_xcoff_archive_p (abfd)
1336        memcpy (hdr.magic, magic, SXCOFFARMAG);        memcpy (hdr.magic, magic, SXCOFFARMAG);
1337    
1338        /* Now read the rest of the file header.  */        /* Now read the rest of the file header.  */
1339        if (bfd_bread ((PTR) &hdr.memoff,        amt = SIZEOF_AR_FILE_HDR_BIG - SXCOFFARMAG;
1340                      (bfd_size_type) SIZEOF_AR_FILE_HDR_BIG - SXCOFFARMAG, abfd)        if (bfd_bread ((PTR) &hdr.memoff, amt, abfd) != amt)
           != SIZEOF_AR_FILE_HDR_BIG - SXCOFFARMAG)  
1341          {          {
1342            if (bfd_get_error () != bfd_error_system_call)            if (bfd_get_error () != bfd_error_system_call)
1343              bfd_set_error (bfd_error_wrong_format);              bfd_set_error (bfd_error_wrong_format);
1344            return NULL;            goto error_ret;
1345          }          }
1346    
1347        /* XXX This actually has to be a call to strtoll (at least on 32-bit        bfd_ardata (abfd)->first_file_filepos = bfd_scan_vma (hdr.firstmemoff,
1348           machines) since the field width is 20 and there numbers with more                                                              (const char **) 0,
1349           than 32 bits can be represented.  */                                                              10);
       bfd_ardata (abfd)->first_file_filepos = strtol (hdr.firstmemoff,  
                                                       (char **) NULL, 10);  
1350    
1351        amt = SIZEOF_AR_FILE_HDR_BIG;        amt = SIZEOF_AR_FILE_HDR_BIG;
1352        bfd_ardata (abfd)->tdata = bfd_zalloc (abfd, amt);        bfd_ardata (abfd)->tdata = bfd_zalloc (abfd, amt);
1353        if (bfd_ardata (abfd)->tdata == NULL)        if (bfd_ardata (abfd)->tdata == NULL)
1354          return NULL;          goto error_ret;
1355    
1356        memcpy (bfd_ardata (abfd)->tdata, &hdr, SIZEOF_AR_FILE_HDR_BIG);        memcpy (bfd_ardata (abfd)->tdata, &hdr, SIZEOF_AR_FILE_HDR_BIG);
1357      }      }
1358    
1359    if (! _bfd_xcoff_slurp_armap (abfd))    if (! _bfd_xcoff_slurp_armap (abfd))
1360      {      {
1361        error_ret:
1362        bfd_release (abfd, bfd_ardata (abfd));        bfd_release (abfd, bfd_ardata (abfd));
1363        abfd->tdata.aout_ar_data = (struct artdata *) NULL;      error_ret_restore:
1364          bfd_ardata (abfd) = tdata_hold;
1365        return NULL;        return NULL;
1366      }      }
1367    
# Line 1551  normalize_filename (abfd) Line 1575  normalize_filename (abfd)
1575    
1576  /* Write out an XCOFF armap.  */  /* Write out an XCOFF armap.  */
1577    
1578  /*ARGSUSED*/  static bfd_boolean
 static boolean  
1579  xcoff_write_armap_old (abfd, elength, map, orl_count, stridx)  xcoff_write_armap_old (abfd, elength, map, orl_count, stridx)
1580       bfd *abfd;       bfd *abfd;
1581       unsigned int elength ATTRIBUTE_UNUSED;       unsigned int elength ATTRIBUTE_UNUSED;
# Line 1586  xcoff_write_armap_old (abfd, elength, ma Line 1609  xcoff_write_armap_old (abfd, elength, ma
1609        != SIZEOF_AR_HDR        != SIZEOF_AR_HDR
1610        || (bfd_bwrite (XCOFFARFMAG, (bfd_size_type) SXCOFFARFMAG, abfd)        || (bfd_bwrite (XCOFFARFMAG, (bfd_size_type) SXCOFFARFMAG, abfd)
1611            != SXCOFFARFMAG))            != SXCOFFARFMAG))
1612      return false;      return FALSE;
1613    
1614    H_PUT_32 (abfd, orl_count, buf);    H_PUT_32 (abfd, orl_count, buf);
1615    if (bfd_bwrite (buf, (bfd_size_type) 4, abfd) != 4)    if (bfd_bwrite (buf, (bfd_size_type) 4, abfd) != 4)
1616      return false;      return FALSE;
1617    
1618    sub = abfd->archive_head;    sub = abfd->archive_head;
1619    fileoff = SIZEOF_AR_FILE_HDR;    fileoff = SIZEOF_AR_FILE_HDR;
# Line 1603  xcoff_write_armap_old (abfd, elength, ma Line 1626  xcoff_write_armap_old (abfd, elength, ma
1626          {          {
1627            H_PUT_32 (abfd, fileoff, buf);            H_PUT_32 (abfd, fileoff, buf);
1628            if (bfd_bwrite (buf, (bfd_size_type) 4, abfd) != 4)            if (bfd_bwrite (buf, (bfd_size_type) 4, abfd) != 4)
1629              return false;              return FALSE;
1630            ++i;            ++i;
1631          }          }
1632        namlen = strlen (normalize_filename (sub));        namlen = strlen (normalize_filename (sub));
# Line 1624  xcoff_write_armap_old (abfd, elength, ma Line 1647  xcoff_write_armap_old (abfd, elength, ma
1647        name = *map[i].name;        name = *map[i].name;
1648        namlen = strlen (name);        namlen = strlen (name);
1649        if (bfd_bwrite (name, (bfd_size_type) (namlen + 1), abfd) != namlen + 1)        if (bfd_bwrite (name, (bfd_size_type) (namlen + 1), abfd) != namlen + 1)
1650          return false;          return FALSE;
1651      }      }
1652    
1653    if ((stridx & 1) != 0)    if ((stridx & 1) != 0)
# Line 1633  xcoff_write_armap_old (abfd, elength, ma Line 1656  xcoff_write_armap_old (abfd, elength, ma
1656    
1657        b = '\0';        b = '\0';
1658        if (bfd_bwrite (&b, (bfd_size_type) 1, abfd) != 1)        if (bfd_bwrite (&b, (bfd_size_type) 1, abfd) != 1)
1659          return false;          return FALSE;
1660      }      }
1661    
1662    return true;    return TRUE;
1663  }  }
1664    
1665  static char buff20[XCOFFARMAGBIG_ELEMENT_SIZE + 1];  static char buff20[XCOFFARMAGBIG_ELEMENT_SIZE + 1];
# Line 1650  static char buff20[XCOFFARMAGBIG_ELEMENT Line 1673  static char buff20[XCOFFARMAGBIG_ELEMENT
1673    
1674  #define PRINT12(d, v) \  #define PRINT12(d, v) \
1675    sprintf (buff20, FMT12, (int)(v)), \    sprintf (buff20, FMT12, (int)(v)), \
1676    memcpy ((void *) (d), buff20, 12)    memcpy ((void *) (d), buff20, 12)
1677    
1678  #define PRINT12_OCTAL(d, v) \  #define PRINT12_OCTAL(d, v) \
1679    sprintf (buff20, FMT12_OCTAL, (unsigned int)(v)), \    sprintf (buff20, FMT12_OCTAL, (unsigned int)(v)), \
# Line 1658  static char buff20[XCOFFARMAGBIG_ELEMENT Line 1681  static char buff20[XCOFFARMAGBIG_ELEMENT
1681    
1682  #define PRINT4(d, v) \  #define PRINT4(d, v) \
1683    sprintf (buff20, FMT4, (int)(v)), \    sprintf (buff20, FMT4, (int)(v)), \
1684    memcpy ((void *) (d), buff20, 4)    memcpy ((void *) (d), buff20, 4)
1685    
1686  #define READ20(d, v) \  #define READ20(d, v) \
1687    buff20[20] = 0, \    buff20[20] = 0, \
1688    memcpy (buff20, (d), 20), \    memcpy (buff20, (d), 20), \
1689    (v) = bfd_scan_vma (buff20, (const char **) NULL, 10)    (v) = bfd_scan_vma (buff20, (const char **) NULL, 10)
1690    
1691  static boolean  static bfd_boolean
1692  do_pad (abfd, number)  do_pad (abfd, number)
1693       bfd *abfd;       bfd *abfd;
1694       unsigned int number;       unsigned int number;
# Line 1674  do_pad (abfd, number) Line 1697  do_pad (abfd, number)
1697    
1698    /* Limit pad to <= 4096.  */    /* Limit pad to <= 4096.  */
1699    if (number > 4096)    if (number > 4096)
1700      return false;      return FALSE;
1701    
1702    while (number--)    while (number--)
1703      if (bfd_bwrite (&b, (bfd_size_type) 1, abfd) != 1)      if (bfd_bwrite (&b, (bfd_size_type) 1, abfd) != 1)
1704        return false;        return FALSE;
1705    
1706    return true;    return TRUE;
1707  }  }
1708    
1709  static boolean  static bfd_boolean
1710  do_copy (out_bfd, in_bfd)  do_copy (out_bfd, in_bfd)
1711       bfd *out_bfd;       bfd *out_bfd;
1712       bfd *in_bfd;       bfd *in_bfd;
# Line 1692  do_copy (out_bfd, in_bfd) Line 1715  do_copy (out_bfd, in_bfd)
1715    bfd_byte buffer[DEFAULT_BUFFERSIZE];    bfd_byte buffer[DEFAULT_BUFFERSIZE];
1716    
1717    if (bfd_seek (in_bfd, (file_ptr) 0, SEEK_SET) != 0)    if (bfd_seek (in_bfd, (file_ptr) 0, SEEK_SET) != 0)
1718      return false;      return FALSE;
1719    
1720    remaining = arelt_size (in_bfd);    remaining = arelt_size (in_bfd);
1721    
# Line 1700  do_copy (out_bfd, in_bfd) Line 1723  do_copy (out_bfd, in_bfd)
1723      {      {
1724        if (bfd_bread (buffer, DEFAULT_BUFFERSIZE, in_bfd) != DEFAULT_BUFFERSIZE        if (bfd_bread (buffer, DEFAULT_BUFFERSIZE, in_bfd) != DEFAULT_BUFFERSIZE
1725            || bfd_bwrite (buffer, DEFAULT_BUFFERSIZE, out_bfd) != DEFAULT_BUFFERSIZE)            || bfd_bwrite (buffer, DEFAULT_BUFFERSIZE, out_bfd) != DEFAULT_BUFFERSIZE)
1726          return false;          return FALSE;
1727    
1728        remaining -= DEFAULT_BUFFERSIZE;        remaining -= DEFAULT_BUFFERSIZE;
1729      }      }
1730    
1731    if (remaining)    if (remaining)
1732      {      {
1733        if (bfd_bread (buffer, remaining, in_bfd) != remaining        if (bfd_bread (buffer, remaining, in_bfd) != remaining
1734            || bfd_bwrite (buffer, remaining, out_bfd) != remaining)            || bfd_bwrite (buffer, remaining, out_bfd) != remaining)
1735          return false;          return FALSE;
1736      }      }
1737    
1738    return true;    return TRUE;
1739  }  }
1740    
1741  static boolean  static bfd_boolean
1742  do_shared_object_padding (out_bfd, in_bfd, offset, ar_header_size)  do_shared_object_padding (out_bfd, in_bfd, offset, ar_header_size)
1743       bfd *out_bfd;       bfd *out_bfd;
1744       bfd *in_bfd;       bfd *in_bfd;
1745       ufile_ptr *offset;       file_ptr *offset;
1746       int ar_header_size;       int ar_header_size;
1747  {  {
1748    if (bfd_check_format (in_bfd, bfd_object)    if (bfd_check_format (in_bfd, bfd_object)
# Line 1735  do_shared_object_padding (out_bfd, in_bf Line 1758  do_shared_object_padding (out_bfd, in_bf
1758        pad -= (*offset + ar_header_size) & (pad - 1);        pad -= (*offset + ar_header_size) & (pad - 1);
1759    
1760        if (! do_pad (out_bfd, pad))        if (! do_pad (out_bfd, pad))
1761          return false;          return FALSE;
1762    
1763        *offset += pad;        *offset += pad;
1764      }      }
1765    
1766    return true;    return TRUE;
1767  }  }
1768    
1769  static boolean  static bfd_boolean
1770  xcoff_write_armap_big (abfd, elength, map, orl_count, stridx)  xcoff_write_armap_big (abfd, elength, map, orl_count, stridx)
1771       bfd *abfd;       bfd *abfd;
1772       unsigned int elength ATTRIBUTE_UNUSED;       unsigned int elength ATTRIBUTE_UNUSED;
# Line 1756  xcoff_write_armap_big (abfd, elength, ma Line 1779  xcoff_write_armap_big (abfd, elength, ma
1779    const bfd_arch_info_type *arch_info = NULL;    const bfd_arch_info_type *arch_info = NULL;
1780    bfd *current_bfd;    bfd *current_bfd;
1781    size_t string_length;    size_t string_length;
1782    ufile_ptr nextoff, prevoff;    file_ptr nextoff, prevoff;
1783      
1784    /* First, we look through the symbols and work out which are    /* First, we look through the symbols and work out which are
1785       from 32-bit objects and which from 64-bit ones.  */       from 32-bit objects and which from 64-bit ones.  */
1786    sym_32 = sym_64 = str_32 = str_64 = 0;    sym_32 = sym_64 = str_32 = str_64 = 0;
# Line 1802  xcoff_write_armap_big (abfd, elength, ma Line 1825  xcoff_write_armap_big (abfd, elength, ma
1825    
1826    BFD_ASSERT (nextoff == bfd_tell (abfd));    BFD_ASSERT (nextoff == bfd_tell (abfd));
1827    
1828    /* Write out the symbol table.      /* Write out the symbol table.
1829       Layout :       Layout :
1830        
1831       standard big archive header       standard big archive header
1832       0x0000                   ar_size   [0x14]       0x0000                   ar_size   [0x14]
1833       0x0014                   ar_nxtmem [0x14]       0x0014                   ar_nxtmem [0x14]
1834       0x0028                   ar_prvmem [0x14]       0x0028                   ar_prvmem [0x14]
1835       0x003C                   ar_date   [0x0C]       0x003C                   ar_date   [0x0C]
1836       0x0048                   ar_uid    [0x0C]       0x0048                   ar_uid    [0x0C]
1837       0x0054                   ar_gid    [0x0C]       0x0054                   ar_gid    [0x0C]
1838       0x0060                   ar_mod    [0x0C]       0x0060                   ar_mod    [0x0C]
1839       0x006C                   ar_namelen[0x04]       0x006C                   ar_namelen[0x04]
1840       0x0070                   ar_fmag   [SXCOFFARFMAG]       0x0070                   ar_fmag   [SXCOFFARFMAG]
1841        
1842       Symbol table       Symbol table
1843       0x0072                   num_syms  [0x08], binary       0x0072                   num_syms  [0x08], binary
1844       0x0078                   offsets   [0x08 * num_syms], binary       0x0078                   offsets   [0x08 * num_syms], binary
1845       0x0086 + 0x08 * num_syms names     [??]       0x0086 + 0x08 * num_syms names     [??]
1846       ??                       pad to even bytes.       ??                       pad to even bytes.
1847    */    */
1848    
1849    if (sym_32)    if (sym_32)
1850      {      {
1851        struct xcoff_ar_hdr_big *hdr;        struct xcoff_ar_hdr_big *hdr;
1852        bfd_byte *symbol_table;        char *symbol_table;
1853        bfd_byte *st;        char *st;
1854        file_ptr fileoff;        file_ptr fileoff;
1855    
1856        bfd_vma symbol_table_size =        bfd_vma symbol_table_size =
1857          SIZEOF_AR_HDR_BIG          SIZEOF_AR_HDR_BIG
1858          + SXCOFFARFMAG          + SXCOFFARFMAG
1859          + 8          + 8
1860          + 8 * sym_32          + 8 * sym_32
1861          + str_32 + (str_32 & 1);          + str_32 + (str_32 & 1);
1862    
1863        symbol_table = NULL;        symbol_table = bfd_zmalloc (symbol_table_size);
       symbol_table = (bfd_byte *) bfd_zmalloc (symbol_table_size);  
1864        if (symbol_table == NULL)        if (symbol_table == NULL)
1865          return false;          return FALSE;
1866    
1867        hdr = (struct xcoff_ar_hdr_big *) symbol_table;        hdr = (struct xcoff_ar_hdr_big *) symbol_table;
1868            
1869        PRINT20 (hdr->size, 8 + 8 * sym_32 + str_32 + (str_32 & 1));        PRINT20 (hdr->size, 8 + 8 * sym_32 + str_32 + (str_32 & 1));
1870            
1871        if (sym_64)        if (sym_64)
1872          PRINT20 (hdr->nextoff, nextoff + symbol_table_size);          PRINT20 (hdr->nextoff, nextoff + symbol_table_size);
1873        else        else
# Line 1864  xcoff_write_armap_big (abfd, elength, ma Line 1886  xcoff_write_armap_big (abfd, elength, ma
1886    
1887        bfd_h_put_64 (abfd, sym_32, st);        bfd_h_put_64 (abfd, sym_32, st);
1888        st += 8;        st += 8;
1889          
1890        /* loop over the 32 bit offsets */        /* loop over the 32 bit offsets */
1891        current_bfd = abfd->archive_head;        current_bfd = abfd->archive_head;
1892        if (current_bfd != NULL)        if (current_bfd != NULL)
# Line 1918  xcoff_write_armap_big (abfd, elength, ma Line 1940  xcoff_write_armap_big (abfd, elength, ma
1940        bfd_bwrite (symbol_table, symbol_table_size, abfd);        bfd_bwrite (symbol_table, symbol_table_size, abfd);
1941    
1942        free (symbol_table);        free (symbol_table);
       symbol_table = NULL;  
1943    
1944        prevoff = nextoff;        prevoff = nextoff;
1945        nextoff = nextoff + symbol_table_size;        nextoff = nextoff + symbol_table_size;
1946      }      }
1947    else    else
1948      PRINT20 (fhdr->symoff, 0);      PRINT20 (fhdr->symoff, 0);
1949      
1950    if (sym_64)    if (sym_64)
1951      {      {
1952        struct xcoff_ar_hdr_big *hdr;        struct xcoff_ar_hdr_big *hdr;
1953        bfd_byte *symbol_table;        char *symbol_table;
1954        bfd_byte *st;        char *st;
1955        file_ptr fileoff;        file_ptr fileoff;
1956    
1957        bfd_vma symbol_table_size =        bfd_vma symbol_table_size =
1958          SIZEOF_AR_HDR_BIG          SIZEOF_AR_HDR_BIG
1959          + SXCOFFARFMAG          + SXCOFFARFMAG
1960          + 8          + 8
1961          + 8 * sym_64          + 8 * sym_64
1962          + str_64 + (str_64 & 1);          + str_64 + (str_64 & 1);
1963    
1964        symbol_table = NULL;        symbol_table = bfd_zmalloc (symbol_table_size);
       symbol_table = (bfd_byte *) bfd_zmalloc (symbol_table_size);  
1965        if (symbol_table == NULL)        if (symbol_table == NULL)
1966          return false;          return FALSE;
1967    
1968        hdr = (struct xcoff_ar_hdr_big *) symbol_table;        hdr = (struct xcoff_ar_hdr_big *) symbol_table;
1969    
# Line 1962  xcoff_write_armap_big (abfd, elength, ma Line 1982  xcoff_write_armap_big (abfd, elength, ma
1982    
1983        bfd_h_put_64 (abfd, sym_64, st);        bfd_h_put_64 (abfd, sym_64, st);
1984        st += 8;        st += 8;
1985          
1986        /* loop over the 64 bit offsets */        /* loop over the 64 bit offsets */
1987        current_bfd = abfd->archive_head;        current_bfd = abfd->archive_head;
1988        if (current_bfd != NULL)        if (current_bfd != NULL)
# Line 2016  xcoff_write_armap_big (abfd, elength, ma Line 2036  xcoff_write_armap_big (abfd, elength, ma
2036        bfd_bwrite (symbol_table, symbol_table_size, abfd);        bfd_bwrite (symbol_table, symbol_table_size, abfd);
2037    
2038        free (symbol_table);        free (symbol_table);
       symbol_table = NULL;  
2039    
2040        PRINT20 (fhdr->symoff64, nextoff);        PRINT20 (fhdr->symoff64, nextoff);
2041      }      }
2042    else    else
2043      PRINT20 (fhdr->symoff64, 0);      PRINT20 (fhdr->symoff64, 0);
2044      
2045    return true;    return TRUE;
2046  }  }
2047    
2048  boolean  bfd_boolean
2049  _bfd_xcoff_write_armap (abfd, elength, map, orl_count, stridx)  _bfd_xcoff_write_armap (abfd, elength, map, orl_count, stridx)
2050       bfd *abfd;       bfd *abfd;
2051       unsigned int elength ATTRIBUTE_UNUSED;       unsigned int elength ATTRIBUTE_UNUSED;
# Line 2043  _bfd_xcoff_write_armap (abfd, elength, m Line 2062  _bfd_xcoff_write_armap (abfd, elength, m
2062  /* Write out an XCOFF archive.  We always write an entire archive,  /* Write out an XCOFF archive.  We always write an entire archive,
2063     rather than fussing with the freelist and so forth.  */     rather than fussing with the freelist and so forth.  */
2064    
2065  static boolean  static bfd_boolean
2066  xcoff_write_archive_contents_old (abfd)  xcoff_write_archive_contents_old (abfd)
2067       bfd *abfd;       bfd *abfd;
2068  {  {
# Line 2051  xcoff_write_archive_contents_old (abfd) Line 2070  xcoff_write_archive_contents_old (abfd)
2070    bfd_size_type count;    bfd_size_type count;
2071    bfd_size_type total_namlen;    bfd_size_type total_namlen;
2072    file_ptr *offsets;    file_ptr *offsets;
2073    boolean makemap;    bfd_boolean makemap;
2074    boolean hasobjects;    bfd_boolean hasobjects;
2075    ufile_ptr prevoff, nextoff;    file_ptr prevoff, nextoff;
2076    bfd *sub;    bfd *sub;
2077    size_t i;    size_t i;
2078    struct xcoff_ar_hdr ahdr;    struct xcoff_ar_hdr ahdr;
# Line 2075  xcoff_write_archive_contents_old (abfd) Line 2094  xcoff_write_archive_contents_old (abfd)
2094      }      }
2095    offsets = (file_ptr *) bfd_alloc (abfd, count * sizeof (file_ptr));    offsets = (file_ptr *) bfd_alloc (abfd, count * sizeof (file_ptr));
2096    if (offsets == NULL)    if (offsets == NULL)
2097      return false;      return FALSE;
2098    
2099    if (bfd_seek (abfd, (file_ptr) SIZEOF_AR_FILE_HDR, SEEK_SET) != 0)    if (bfd_seek (abfd, (file_ptr) SIZEOF_AR_FILE_HDR, SEEK_SET) != 0)
2100      return false;      return FALSE;
2101    
2102    makemap = bfd_has_map (abfd);    makemap = bfd_has_map (abfd);
2103    hasobjects = false;    hasobjects = FALSE;
2104    prevoff = 0;    prevoff = 0;
2105    nextoff = SIZEOF_AR_FILE_HDR;    nextoff = SIZEOF_AR_FILE_HDR;
2106    for (sub = abfd->archive_head, i = 0; sub != NULL; sub = sub->next, i++)    for (sub = abfd->archive_head, i = 0; sub != NULL; sub = sub->next, i++)
# Line 2094  xcoff_write_archive_contents_old (abfd) Line 2113  xcoff_write_archive_contents_old (abfd)
2113        if (makemap && ! hasobjects)        if (makemap && ! hasobjects)
2114          {          {
2115            if (bfd_check_format (sub, bfd_object))            if (bfd_check_format (sub, bfd_object))
2116              hasobjects = true;              hasobjects = TRUE;
2117          }          }
2118    
2119        name = normalize_filename (sub);        name = normalize_filename (sub);
# Line 2114  xcoff_write_archive_contents_old (abfd) Line 2133  xcoff_write_archive_contents_old (abfd)
2133            if (stat (bfd_get_filename (sub), &s) != 0)            if (stat (bfd_get_filename (sub), &s) != 0)
2134              {              {
2135                bfd_set_error (bfd_error_system_call);                bfd_set_error (bfd_error_system_call);
2136                return false;                return FALSE;
2137              }              }
2138    
2139            sprintf (ahdrp->size, "%ld", (long) s.st_size);            sprintf (ahdrp->size, "%ld", (long) s.st_size);
# Line 2128  xcoff_write_archive_contents_old (abfd) Line 2147  xcoff_write_archive_contents_old (abfd)
2147                size = sizeof (struct areltdata);                size = sizeof (struct areltdata);
2148                sub->arelt_data = bfd_alloc (sub, size);                sub->arelt_data = bfd_alloc (sub, size);
2149                if (sub->arelt_data == NULL)                if (sub->arelt_data == NULL)
2150                  return false;                  return FALSE;
2151              }              }
2152    
2153            arch_eltdata (sub)->parsed_size = s.st_size;            arch_eltdata (sub)->parsed_size = s.st_size;
# Line 2138  xcoff_write_archive_contents_old (abfd) Line 2157  xcoff_write_archive_contents_old (abfd)
2157        sprintf (ahdrp->namlen, "%ld", (long) namlen);        sprintf (ahdrp->namlen, "%ld", (long) namlen);
2158    
2159        /* If the length of the name is odd, we write out the null byte        /* If the length of the name is odd, we write out the null byte
2160           after the name as well.  */           after the name as well.  */
2161        namlen = (namlen + 1) &~ (bfd_size_type) 1;        namlen = (namlen + 1) &~ (bfd_size_type) 1;
2162    
2163        remaining = arelt_size (sub);        remaining = arelt_size (sub);
# Line 2163  xcoff_write_archive_contents_old (abfd) Line 2182  xcoff_write_archive_contents_old (abfd)
2182    
2183        if ((bfd_bwrite ((PTR) ahdrp, (bfd_size_type) SIZEOF_AR_HDR, abfd)        if ((bfd_bwrite ((PTR) ahdrp, (bfd_size_type) SIZEOF_AR_HDR, abfd)
2184             != SIZEOF_AR_HDR)             != SIZEOF_AR_HDR)
2185            || (bfd_bwrite ((PTR) name, namlen, abfd) != namlen)            || bfd_bwrite ((PTR) name, namlen, abfd) != namlen
2186            || (bfd_bwrite ((PTR) XCOFFARFMAG, (bfd_size_type) SXCOFFARFMAG, abfd)            || bfd_bwrite ((PTR) XCOFFARFMAG, (bfd_size_type) SXCOFFARFMAG,
2187                != SXCOFFARFMAG))                           abfd) != SXCOFFARFMAG)
2188          return false;          return FALSE;
2189    
2190        if (bfd_seek (sub, (file_ptr) 0, SEEK_SET) != 0)        if (bfd_seek (sub, (file_ptr) 0, SEEK_SET) != 0)
2191          return false;          return FALSE;
2192    
2193        if (! do_copy (abfd, sub))        if (! do_copy (abfd, sub))
2194          return false;          return FALSE;
2195          
2196        if (! do_pad (abfd, size & 1))        if (! do_pad (abfd, size & 1))
2197          return false;          return FALSE;
2198      }      }
2199    
2200    sprintf (fhdr.lastmemoff, "%ld", (long) prevoff);    sprintf (fhdr.lastmemoff, "%ld", (long) prevoff);
# Line 2186  xcoff_write_archive_contents_old (abfd) Line 2205  xcoff_write_archive_contents_old (abfd)
2205    sprintf (fhdr.memoff, "%ld", (long) nextoff);    sprintf (fhdr.memoff, "%ld", (long) nextoff);
2206    
2207    memset (&ahdr, 0, sizeof ahdr);    memset (&ahdr, 0, sizeof ahdr);
2208    sprintf (ahdr.size, "%ld", (long) (XCOFFARMAG_ELEMENT_SIZE +    sprintf (ahdr.size, "%ld", (long) (XCOFFARMAG_ELEMENT_SIZE
2209                                       count * XCOFFARMAG_ELEMENT_SIZE +                                       + count * XCOFFARMAG_ELEMENT_SIZE
2210                                       total_namlen));                                       + total_namlen));
2211    sprintf (ahdr.prevoff, "%ld", (long) prevoff);    sprintf (ahdr.prevoff, "%ld", (long) prevoff);
2212    sprintf (ahdr.date, "%d", 0);    sprintf (ahdr.date, "%d", 0);
2213    sprintf (ahdr.uid, "%d", 0);    sprintf (ahdr.uid, "%d", 0);
# Line 2219  xcoff_write_archive_contents_old (abfd) Line 2238  xcoff_write_archive_contents_old (abfd)
2238         != SIZEOF_AR_HDR)         != SIZEOF_AR_HDR)
2239        || (bfd_bwrite ((PTR) XCOFFARFMAG, (bfd_size_type) SXCOFFARFMAG, abfd)        || (bfd_bwrite ((PTR) XCOFFARFMAG, (bfd_size_type) SXCOFFARFMAG, abfd)
2240            != SXCOFFARFMAG))            != SXCOFFARFMAG))
2241      return false;      return FALSE;
2242    
2243    sprintf (decbuf, "%-12ld", (long) count);    sprintf (decbuf, "%-12ld", (long) count);
2244    if (bfd_bwrite ((PTR) decbuf, (bfd_size_type) XCOFFARMAG_ELEMENT_SIZE, abfd)    if (bfd_bwrite ((PTR) decbuf, (bfd_size_type) XCOFFARMAG_ELEMENT_SIZE, abfd)
2245        != XCOFFARMAG_ELEMENT_SIZE)        != XCOFFARMAG_ELEMENT_SIZE)
2246      return false;      return FALSE;
2247    for (i = 0; i < (size_t) count; i++)    for (i = 0; i < (size_t) count; i++)
2248      {      {
2249        sprintf (decbuf, "%-12ld", (long) offsets[i]);        sprintf (decbuf, "%-12ld", (long) offsets[i]);
2250        if (bfd_bwrite ((PTR) decbuf, (bfd_size_type) XCOFFARMAG_ELEMENT_SIZE,        if (bfd_bwrite ((PTR) decbuf, (bfd_size_type) XCOFFARMAG_ELEMENT_SIZE,
2251                        abfd) != XCOFFARMAG_ELEMENT_SIZE)                        abfd) != XCOFFARMAG_ELEMENT_SIZE)
2252          return false;          return FALSE;
2253      }      }
2254    for (sub = abfd->archive_head; sub != NULL; sub = sub->next)    for (sub = abfd->archive_head; sub != NULL; sub = sub->next)
2255      {      {
# Line 2240  xcoff_write_archive_contents_old (abfd) Line 2259  xcoff_write_archive_contents_old (abfd)
2259        name = normalize_filename (sub);        name = normalize_filename (sub);
2260        namlen = strlen (name);        namlen = strlen (name);
2261        if (bfd_bwrite ((PTR) name, namlen + 1, abfd) != namlen + 1)        if (bfd_bwrite ((PTR) name, namlen + 1, abfd) != namlen + 1)
2262          return false;          return FALSE;
2263      }      }
2264    
2265    if (! do_pad (abfd, size & 1))    if (! do_pad (abfd, size & 1))
2266      return false;      return FALSE;
2267    
2268    /* Write out the armap, if appropriate.  */    /* Write out the armap, if appropriate.  */
2269    if (! makemap || ! hasobjects)    if (! makemap || ! hasobjects)
# Line 2255  xcoff_write_archive_contents_old (abfd) Line 2274  xcoff_write_archive_contents_old (abfd)
2274        sprintf (fhdr.symoff, "%ld", (long) nextoff);        sprintf (fhdr.symoff, "%ld", (long) nextoff);
2275        bfd_ardata (abfd)->tdata = (PTR) &fhdr;        bfd_ardata (abfd)->tdata = (PTR) &fhdr;
2276        if (! _bfd_compute_and_write_armap (abfd, 0))        if (! _bfd_compute_and_write_armap (abfd, 0))
2277          return false;          return FALSE;
2278      }      }
2279    
2280    /* Write out the archive file header.  */    /* Write out the archive file header.  */
# Line 2268  xcoff_write_archive_contents_old (abfd) Line 2287  xcoff_write_archive_contents_old (abfd)
2287    if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0    if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0
2288        || (bfd_bwrite ((PTR) &fhdr, (bfd_size_type) SIZEOF_AR_FILE_HDR, abfd)        || (bfd_bwrite ((PTR) &fhdr, (bfd_size_type) SIZEOF_AR_FILE_HDR, abfd)
2289            != SIZEOF_AR_FILE_HDR))            != SIZEOF_AR_FILE_HDR))
2290      return false;      return FALSE;
2291    
2292    return true;    return TRUE;
2293  }  }
2294    
2295  static boolean  static bfd_boolean
2296  xcoff_write_archive_contents_big (abfd)  xcoff_write_archive_contents_big (abfd)
2297       bfd *abfd;       bfd *abfd;
2298  {  {
# Line 2281  xcoff_write_archive_contents_big (abfd) Line 2300  xcoff_write_archive_contents_big (abfd)
2300    bfd_size_type count;    bfd_size_type count;
2301    bfd_size_type total_namlen;    bfd_size_type total_namlen;
2302    file_ptr *offsets;    file_ptr *offsets;
2303    boolean makemap;    bfd_boolean makemap;
2304    boolean hasobjects;    bfd_boolean hasobjects;
2305    ufile_ptr prevoff, nextoff;    file_ptr prevoff, nextoff;
2306    bfd *current_bfd;    bfd *current_bfd;
2307    size_t i;    size_t i;
2308    struct xcoff_ar_hdr_big *hdr, ahdr;    struct xcoff_ar_hdr_big *hdr, ahdr;
2309    bfd_size_type size;    bfd_size_type size;
2310    bfd_byte *member_table, *mt;    char *member_table, *mt;
2311    bfd_vma member_table_size;    bfd_vma member_table_size;
2312    
2313    memset (&fhdr, 0, SIZEOF_AR_FILE_HDR_BIG);    memset (&fhdr, 0, SIZEOF_AR_FILE_HDR_BIG);
2314    memcpy (fhdr.magic, XCOFFARMAGBIG, SXCOFFARMAG);    memcpy (fhdr.magic, XCOFFARMAGBIG, SXCOFFARMAG);
2315    
2316    if (bfd_seek (abfd, (file_ptr) SIZEOF_AR_FILE_HDR_BIG, SEEK_SET) != 0)    if (bfd_seek (abfd, (file_ptr) SIZEOF_AR_FILE_HDR_BIG, SEEK_SET) != 0)
2317      return false;      return FALSE;
2318      
2319    /* Calculate count and total_namlen.  */    /* Calculate count and total_namlen.  */
2320    makemap = bfd_has_map (abfd);    makemap = bfd_has_map (abfd);
2321    hasobjects = false;    hasobjects = FALSE;
2322    for (current_bfd = abfd->archive_head, count = 0, total_namlen = 0;    for (current_bfd = abfd->archive_head, count = 0, total_namlen = 0;
2323         current_bfd != NULL;         current_bfd != NULL;
2324         current_bfd = current_bfd->next, count++)         current_bfd = current_bfd->next, count++)
2325      {      {
2326        total_namlen += strlen (normalize_filename (current_bfd)) + 1;        total_namlen += strlen (normalize_filename (current_bfd)) + 1;
# Line 2309  xcoff_write_archive_contents_big (abfd) Line 2328  xcoff_write_archive_contents_big (abfd)
2328        if (makemap        if (makemap
2329            && ! hasobjects            && ! hasobjects
2330            && bfd_check_format (current_bfd, bfd_object))            && bfd_check_format (current_bfd, bfd_object))
2331          hasobjects = true;          hasobjects = TRUE;
2332      }      }
2333    
2334    offsets = NULL;    offsets = NULL;
# Line 2317  xcoff_write_archive_contents_big (abfd) Line 2336  xcoff_write_archive_contents_big (abfd)
2336      {      {
2337        offsets = (file_ptr *) bfd_malloc (count * sizeof (file_ptr));        offsets = (file_ptr *) bfd_malloc (count * sizeof (file_ptr));
2338        if (offsets == NULL)        if (offsets == NULL)
2339          return false;          return FALSE;
2340      }      }
2341    
2342    prevoff = 0;    prevoff = 0;
2343    nextoff = SIZEOF_AR_FILE_HDR_BIG;    nextoff = SIZEOF_AR_FILE_HDR_BIG;
2344    for (current_bfd = abfd->archive_head, i = 0;    for (current_bfd = abfd->archive_head, i = 0;
2345         current_bfd != NULL;         current_bfd != NULL;
2346         current_bfd = current_bfd->next, i++)         current_bfd = current_bfd->next, i++)
2347      {      {
2348        const char *name;        const char *name;
# Line 2345  xcoff_write_archive_contents_big (abfd) Line 2364  xcoff_write_archive_contents_big (abfd)
2364    
2365            ahdrp = &ahdr;            ahdrp = &ahdr;
2366            /* XXX This should actually be a call to stat64 (at least on            /* XXX This should actually be a call to stat64 (at least on
2367               32-bit machines).                 32-bit machines).
2368               XXX This call will fail if the original object is not found.  */               XXX This call will fail if the original object is not found.  */
2369            if (stat (bfd_get_filename (current_bfd), &s) != 0)            if (stat (bfd_get_filename (current_bfd), &s) != 0)
2370              {              {
2371                bfd_set_error (bfd_error_system_call);                bfd_set_error (bfd_error_system_call);
2372                return false;                return FALSE;
2373              }              }
2374    
2375            PRINT20 (ahdrp->size, s.st_size);            PRINT20 (ahdrp->size, s.st_size);
# Line 2364  xcoff_write_archive_contents_big (abfd) Line 2383  xcoff_write_archive_contents_big (abfd)
2383                size = sizeof (struct areltdata);                size = sizeof (struct areltdata);
2384                current_bfd->arelt_data = bfd_alloc (current_bfd, size);                current_bfd->arelt_data = bfd_alloc (current_bfd, size);
2385                if (current_bfd->arelt_data == NULL)                if (current_bfd->arelt_data == NULL)
2386                  return false;                  return FALSE;
2387              }              }
2388    
2389            arch_eltdata (current_bfd)->parsed_size = s.st_size;            arch_eltdata (current_bfd)->parsed_size = s.st_size;
# Line 2374  xcoff_write_archive_contents_big (abfd) Line 2393  xcoff_write_archive_contents_big (abfd)
2393        PRINT4 (ahdrp->namlen, namlen);        PRINT4 (ahdrp->namlen, namlen);
2394    
2395        /* If the length of the name is odd, we write out the null byte        /* If the length of the name is odd, we write out the null byte
2396           after the name as well.  */           after the name as well.  */
2397        namlen = (namlen + 1) &~ (bfd_size_type) 1;        namlen = (namlen + 1) &~ (bfd_size_type) 1;
2398    
2399        remaining = arelt_size (current_bfd);        remaining = arelt_size (current_bfd);
# Line 2389  xcoff_write_archive_contents_big (abfd) Line 2408  xcoff_write_archive_contents_big (abfd)
2408           Their text section needs to be aligned wrt the archive file position.           Their text section needs to be aligned wrt the archive file position.
2409           This requires extra padding before the archive header.  */           This requires extra padding before the archive header.  */
2410        if (! do_shared_object_padding (abfd, current_bfd, & nextoff,        if (! do_shared_object_padding (abfd, current_bfd, & nextoff,
2411                                        SIZEOF_AR_HDR_BIG + namlen                                        SIZEOF_AR_HDR_BIG + namlen
2412                                        + SXCOFFARFMAG))                                        + SXCOFFARFMAG))
2413          return false;          return FALSE;
2414    
2415        offsets[i] = nextoff;        offsets[i] = nextoff;
2416    
# Line 2403  xcoff_write_archive_contents_big (abfd) Line 2422  xcoff_write_archive_contents_big (abfd)
2422        if ((bfd_bwrite ((PTR) ahdrp, (bfd_size_type) SIZEOF_AR_HDR_BIG, abfd)        if ((bfd_bwrite ((PTR) ahdrp, (bfd_size_type) SIZEOF_AR_HDR_BIG, abfd)
2423             != SIZEOF_AR_HDR_BIG)             != SIZEOF_AR_HDR_BIG)
2424            || bfd_bwrite ((PTR) name, (bfd_size_type) namlen, abfd) != namlen            || bfd_bwrite ((PTR) name, (bfd_size_type) namlen, abfd) != namlen
2425            || (bfd_bwrite ((PTR) XCOFFARFMAG, (bfd_size_type) SXCOFFARFMAG,            || (bfd_bwrite ((PTR) XCOFFARFMAG, (bfd_size_type) SXCOFFARFMAG,
2426                            abfd) != SXCOFFARFMAG))                            abfd) != SXCOFFARFMAG))
2427          return false;          return FALSE;
2428    
2429        if (bfd_seek (current_bfd, (file_ptr) 0, SEEK_SET) != 0)        if (bfd_seek (current_bfd, (file_ptr) 0, SEEK_SET) != 0)
2430          return false;          return FALSE;
2431    
2432        if (! do_copy (abfd, current_bfd))        if (! do_copy (abfd, current_bfd))
2433          return false;          return FALSE;
2434      
2435        if (! do_pad (abfd, size & 1))        if (! do_pad (abfd, size & 1))
2436          return false;          return FALSE;
2437      }      }
2438    
2439    if (count)    if (count)
# Line 2423  xcoff_write_archive_contents_big (abfd) Line 2442  xcoff_write_archive_contents_big (abfd)
2442        PRINT20 (fhdr.lastmemoff, prevoff);        PRINT20 (fhdr.lastmemoff, prevoff);
2443      }      }
2444    
2445    /* Write out the member table.      /* Write out the member table.
2446       Layout :       Layout :
2447    
2448       standard big archive header       standard big archive header
2449       0x0000                   ar_size   [0x14]       0x0000                   ar_size   [0x14]
2450       0x0014                   ar_nxtmem [0x14]       0x0014                   ar_nxtmem [0x14]
2451       0x0028                   ar_prvmem [0x14]       0x0028                   ar_prvmem [0x14]
2452       0x003C                   ar_date   [0x0C]       0x003C                   ar_date   [0x0C]
2453       0x0048                   ar_uid    [0x0C]       0x0048                   ar_uid    [0x0C]
2454       0x0054                   ar_gid    [0x0C]       0x0054                   ar_gid    [0x0C]
2455       0x0060                   ar_mod    [0x0C]       0x0060                   ar_mod    [0x0C]
2456       0x006C                   ar_namelen[0x04]       0x006C                   ar_namelen[0x04]
2457       0x0070                   ar_fmag   [0x02]       0x0070                   ar_fmag   [0x02]
2458    
2459       Member table       Member table
2460       0x0072                   count     [0x14]       0x0072                   count     [0x14]
2461       0x0086                   offsets   [0x14 * counts]       0x0086                   offsets   [0x14 * counts]
2462       0x0086 + 0x14 * counts   names     [??]       0x0086 + 0x14 * counts   names     [??]
2463       ??                       pad to even bytes.       ??                       pad to even bytes.
2464     */     */
2465    
2466    BFD_ASSERT (nextoff == bfd_tell (abfd));    BFD_ASSERT (nextoff == bfd_tell (abfd));
# Line 2453  xcoff_write_archive_contents_big (abfd) Line 2472  xcoff_write_archive_contents_big (abfd)
2472                         + total_namlen);                         + total_namlen);
2473    
2474    member_table_size += member_table_size & 1;    member_table_size += member_table_size & 1;
2475    member_table = NULL;    member_table = bfd_zmalloc (member_table_size);
   member_table = (bfd_byte *) bfd_zmalloc (member_table_size);  
2476    if (member_table == NULL)    if (member_table == NULL)
2477      return false;      return FALSE;
2478    
2479    hdr = (struct xcoff_ar_hdr_big *) member_table;    hdr = (struct xcoff_ar_hdr_big *) member_table;
2480    
2481    PRINT20 (hdr->size, (XCOFFARMAGBIG_ELEMENT_SIZE +    PRINT20 (hdr->size, (XCOFFARMAGBIG_ELEMENT_SIZE
2482                         count * XCOFFARMAGBIG_ELEMENT_SIZE +                         + count * XCOFFARMAGBIG_ELEMENT_SIZE
2483                         total_namlen + (total_namlen & 1)));                         + total_namlen + (total_namlen & 1)));
2484    if (makemap && hasobjects)    if (makemap && hasobjects)
2485      PRINT20 (hdr->nextoff, nextoff + member_table_size);      PRINT20 (hdr->nextoff, nextoff + member_table_size);
2486    else    else
2487      PRINT20 (hdr->nextoff, 0);      PRINT20 (hdr->nextoff, 0);
# Line 2473  xcoff_write_archive_contents_big (abfd) Line 2491  xcoff_write_archive_contents_big (abfd)
2491    PRINT12 (hdr->gid, 0);    PRINT12 (hdr->gid, 0);
2492    PRINT12 (hdr->mode, 0);    PRINT12 (hdr->mode, 0);
2493    PRINT4 (hdr->namlen, 0);    PRINT4 (hdr->namlen, 0);
2494      
2495    mt = member_table + SIZEOF_AR_HDR_BIG;    mt = member_table + SIZEOF_AR_HDR_BIG;
2496    memcpy (mt, XCOFFARFMAG, SXCOFFARFMAG);    memcpy (mt, XCOFFARFMAG, SXCOFFARFMAG);
2497    mt += SXCOFFARFMAG;    mt += SXCOFFARFMAG;
# Line 2486  xcoff_write_archive_contents_big (abfd) Line 2504  xcoff_write_archive_contents_big (abfd)
2504        mt += XCOFFARMAGBIG_ELEMENT_SIZE;        mt += XCOFFARMAGBIG_ELEMENT_SIZE;
2505      }      }
2506    
2507    if (count)    if (count)
2508      {      {
2509        free (offsets);        free (offsets);
2510        offsets = NULL;        offsets = NULL;
2511      }      }
2512    
2513    for (current_bfd = abfd->archive_head; current_bfd != NULL;    for (current_bfd = abfd->archive_head; current_bfd != NULL;
2514         current_bfd = current_bfd->next)         current_bfd = current_bfd->next)
2515      {      {
2516        const char *name;        const char *name;
2517        size_t namlen;        size_t namlen;
2518    
2519        name = normalize_filename (current_bfd);        name = normalize_filename (current_bfd);
2520        namlen = sprintf(mt, "%s", name);        namlen = sprintf (mt, "%s", name);
2521        mt += namlen + 1;        mt += namlen + 1;
2522      }      }
2523      
2524    if (bfd_bwrite (member_table, member_table_size, abfd) != member_table_size)    if (bfd_bwrite (member_table, member_table_size, abfd) != member_table_size)
2525      return false;      return FALSE;
2526    
2527    free (member_table);    free (member_table);
   member_table = NULL;  
2528    
2529    PRINT20 (fhdr.memoff, nextoff);    PRINT20 (fhdr.memoff, nextoff);
2530    
# Line 2516  xcoff_write_archive_contents_big (abfd) Line 2533  xcoff_write_archive_contents_big (abfd)
2533    
2534    /* Write out the armap, if appropriate.  */    /* Write out the armap, if appropriate.  */
2535    
2536    if (! makemap || ! hasobjects)    if (! makemap || ! hasobjects)
2537      PRINT20 (fhdr.symoff, 0);      PRINT20 (fhdr.symoff, 0);
2538    else    else
2539      {      {
# Line 2524  xcoff_write_archive_contents_big (abfd) Line 2541  xcoff_write_archive_contents_big (abfd)
2541    
2542        /* Save nextoff in fhdr.symoff so the armap routine can use it.  */        /* Save nextoff in fhdr.symoff so the armap routine can use it.  */
2543        PRINT20 (fhdr.symoff, nextoff);        PRINT20 (fhdr.symoff, nextoff);
2544          
2545        bfd_ardata (abfd)->tdata = (PTR) &fhdr;        bfd_ardata (abfd)->tdata = (PTR) &fhdr;
2546        if (! _bfd_compute_and_write_armap (abfd, 0))        if (! _bfd_compute_and_write_armap (abfd, 0))
2547          return false;          return FALSE;
2548      }      }
2549    
2550    /* Write out the archive file header.  */    /* Write out the archive file header.  */
2551    
2552    if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0    if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0
2553        || (bfd_bwrite ((PTR) &fhdr, (bfd_size_type) SIZEOF_AR_FILE_HDR_BIG,        || (bfd_bwrite ((PTR) &fhdr, (bfd_size_type) SIZEOF_AR_FILE_HDR_BIG,
2554                        abfd) != SIZEOF_AR_FILE_HDR_BIG))                        abfd) != SIZEOF_AR_FILE_HDR_BIG))
2555      return false;      return FALSE;
2556      
2557    return true;    return TRUE;
2558  }  }
2559    
2560  boolean  bfd_boolean
2561  _bfd_xcoff_write_archive_contents (abfd)  _bfd_xcoff_write_archive_contents (abfd)
2562       bfd *abfd;       bfd *abfd;
2563  {  {
# Line 2556  _bfd_xcoff_write_archive_contents (abfd) Line 2573  _bfd_xcoff_write_archive_contents (abfd)
2573  int  int
2574  _bfd_xcoff_sizeof_headers (abfd, reloc)  _bfd_xcoff_sizeof_headers (abfd, reloc)
2575       bfd *abfd;       bfd *abfd;
2576       boolean reloc ATTRIBUTE_UNUSED;       bfd_boolean reloc ATTRIBUTE_UNUSED;
2577  {  {
2578    int size;    int size;
2579    
# Line 2731  xcoff_swap_ldrel_out (abfd, src, d) Line 2748  xcoff_swap_ldrel_out (abfd, src, d)
2748  }  }
2749    
2750    
2751  boolean  bfd_boolean
2752  xcoff_reloc_type_noop (input_bfd, input_section, output_bfd, rel, sym, howto,  xcoff_reloc_type_noop (input_bfd, input_section, output_bfd, rel, sym, howto,
2753                         val, addend, relocation, contents)                         val, addend, relocation, contents)
2754       bfd *input_bfd ATTRIBUTE_UNUSED;       bfd *input_bfd ATTRIBUTE_UNUSED;
2755       asection *input_section ATTRIBUTE_UNUSED;       asection *input_section ATTRIBUTE_UNUSED;
# Line 2745  xcoff_reloc_type_noop (input_bfd, input_ Line 2762  xcoff_reloc_type_noop (input_bfd, input_
2762       bfd_vma *relocation ATTRIBUTE_UNUSED;       bfd_vma *relocation ATTRIBUTE_UNUSED;
2763       bfd_byte *contents ATTRIBUTE_UNUSED;       bfd_byte *contents ATTRIBUTE_UNUSED;
2764  {  {
2765    return true;    return TRUE;
2766  }  }
2767    
2768  boolean  bfd_boolean
2769  xcoff_reloc_type_fail (input_bfd, input_section, output_bfd, rel, sym, howto,  xcoff_reloc_type_fail (input_bfd, input_section, output_bfd, rel, sym, howto,
2770                         val, addend, relocation, contents)                         val, addend, relocation, contents)
2771       bfd *input_bfd;       bfd *input_bfd;
2772       asection *input_section ATTRIBUTE_UNUSED;       asection *input_section ATTRIBUTE_UNUSED;
# Line 2766  xcoff_reloc_type_fail (input_bfd, input_ Line 2783  xcoff_reloc_type_fail (input_bfd, input_
2783      (_("%s: unsupported relocation type 0x%02x"),      (_("%s: unsupported relocation type 0x%02x"),
2784       bfd_get_filename (input_bfd), (unsigned int) rel->r_type);       bfd_get_filename (input_bfd), (unsigned int) rel->r_type);
2785    bfd_set_error (bfd_error_bad_value);    bfd_set_error (bfd_error_bad_value);
2786    return false;    return FALSE;
2787  }  }
2788    
2789  boolean  bfd_boolean
2790  xcoff_reloc_type_pos (input_bfd, input_section, output_bfd, rel, sym, howto,  xcoff_reloc_type_pos (input_bfd, input_section, output_bfd, rel, sym, howto,
2791                        val, addend, relocation, contents)                        val, addend, relocation, contents)
2792       bfd *input_bfd ATTRIBUTE_UNUSED;       bfd *input_bfd ATTRIBUTE_UNUSED;
2793       asection *input_section ATTRIBUTE_UNUSED;       asection *input_section ATTRIBUTE_UNUSED;
# Line 2784  xcoff_reloc_type_pos (input_bfd, input_s Line 2801  xcoff_reloc_type_pos (input_bfd, input_s
2801       bfd_byte *contents ATTRIBUTE_UNUSED;       bfd_byte *contents ATTRIBUTE_UNUSED;
2802  {  {
2803    *relocation = val + addend;    *relocation = val + addend;
2804    return true;    return TRUE;
2805  }  }
2806    
2807  boolean  bfd_boolean
2808  xcoff_reloc_type_neg (input_bfd, input_section, output_bfd, rel, sym, howto,  xcoff_reloc_type_neg (input_bfd, input_section, output_bfd, rel, sym, howto,
2809                        val, addend, relocation, contents)                        val, addend, relocation, contents)
2810       bfd *input_bfd ATTRIBUTE_UNUSED;       bfd *input_bfd ATTRIBUTE_UNUSED;
2811       asection *input_section ATTRIBUTE_UNUSED;       asection *input_section ATTRIBUTE_UNUSED;
# Line 2802  xcoff_reloc_type_neg (input_bfd, input_s Line 2819  xcoff_reloc_type_neg (input_bfd, input_s
2819       bfd_byte *contents ATTRIBUTE_UNUSED;       bfd_byte *contents ATTRIBUTE_UNUSED;
2820  {  {
2821    *relocation = addend - val;    *relocation = addend - val;
2822    return true;    return TRUE;
2823  }  }
2824    
2825  boolean  bfd_boolean
2826  xcoff_reloc_type_rel (input_bfd, input_section, output_bfd, rel, sym, howto,  xcoff_reloc_type_rel (input_bfd, input_section, output_bfd, rel, sym, howto,
2827                        val, addend, relocation, contents)                        val, addend, relocation, contents)
2828       bfd *input_bfd ATTRIBUTE_UNUSED;       bfd *input_bfd ATTRIBUTE_UNUSED;
2829       asection *input_section;       asection *input_section;
# Line 2819  xcoff_reloc_type_rel (input_bfd, input_s Line 2836  xcoff_reloc_type_rel (input_bfd, input_s
2836       bfd_vma *relocation;       bfd_vma *relocation;
2837       bfd_byte *contents ATTRIBUTE_UNUSED;       bfd_byte *contents ATTRIBUTE_UNUSED;
2838  {  {
2839    howto->pc_relative = true;    howto->pc_relative = TRUE;
2840    
2841    /* A PC relative reloc includes the section address.  */    /* A PC relative reloc includes the section address.  */
2842    addend += input_section->vma;    addend += input_section->vma;
2843    
2844    *relocation = val + addend;    *relocation = val + addend;
2845    *relocation -= (input_section->output_section->vma +    *relocation -= (input_section->output_section->vma
2846                    input_section->output_offset);                    + input_section->output_offset);
2847    return true;    return TRUE;
2848  }  }
2849    
2850  boolean  bfd_boolean
2851  xcoff_reloc_type_toc (input_bfd, input_section, output_bfd, rel, sym, howto,  xcoff_reloc_type_toc (input_bfd, input_section, output_bfd, rel, sym, howto,
2852                        val, addend, relocation, contents)                        val, addend, relocation, contents)
2853       bfd *input_bfd;       bfd *input_bfd;
2854       asection *input_section ATTRIBUTE_UNUSED;       asection *input_section ATTRIBUTE_UNUSED;
# Line 2846  xcoff_reloc_type_toc (input_bfd, input_s Line 2863  xcoff_reloc_type_toc (input_bfd, input_s
2863  {  {
2864    struct xcoff_link_hash_entry *h;    struct xcoff_link_hash_entry *h;
2865    
2866    if (0 > rel->r_symndx)    if (0 > rel->r_symndx)
2867      return false;      return FALSE;
2868    
2869    h = obj_xcoff_sym_hashes (input_bfd)[rel->r_symndx];    h = obj_xcoff_sym_hashes (input_bfd)[rel->r_symndx];
2870    
# Line 2860  xcoff_reloc_type_toc (input_bfd, input_s Line 2877  xcoff_reloc_type_toc (input_bfd, input_s
2877               bfd_get_filename (input_bfd), rel->r_vaddr,               bfd_get_filename (input_bfd), rel->r_vaddr,
2878               h->root.root.string);               h->root.root.string);
2879            bfd_set_error (bfd_error_bad_value);            bfd_set_error (bfd_error_bad_value);
2880            return false;            return FALSE;
2881          }          }
2882          
2883        BFD_ASSERT ((h->flags & XCOFF_SET_TOC) == 0);        BFD_ASSERT ((h->flags & XCOFF_SET_TOC) == 0);
2884        val = (h->toc_section->output_section->vma        val = (h->toc_section->output_section->vma
2885                + h->toc_section->output_offset);                + h->toc_section->output_offset);
2886      }      }
2887      
2888    *relocation = ((val - xcoff_data (output_bfd)->toc) -    *relocation = ((val - xcoff_data (output_bfd)->toc)
2889                   (sym->n_value - xcoff_data (input_bfd)->toc));                   - (sym->n_value - xcoff_data (input_bfd)->toc));
2890    return true;    return TRUE;
2891  }  }
2892    
2893  boolean  bfd_boolean
2894  xcoff_reloc_type_ba (input_bfd, input_section, output_bfd, rel, sym, howto,  xcoff_reloc_type_ba (input_bfd, input_section, output_bfd, rel, sym, howto,
2895                       val, addend, relocation, contents)                       val, addend, relocation, contents)
2896       bfd *input_bfd ATTRIBUTE_UNUSED;       bfd *input_bfd ATTRIBUTE_UNUSED;
2897       asection *input_section ATTRIBUTE_UNUSED;       asection *input_section ATTRIBUTE_UNUSED;
# Line 2892  xcoff_reloc_type_ba (input_bfd, input_se Line 2909  xcoff_reloc_type_ba (input_bfd, input_se
2909    
2910    *relocation = val + addend;    *relocation = val + addend;
2911    
2912    return true;    return TRUE;
2913  }  }
2914    
2915  static boolean  static bfd_boolean
2916  xcoff_reloc_type_br (input_bfd, input_section, output_bfd, rel, sym, howto,  xcoff_reloc_type_br (input_bfd, input_section, output_bfd, rel, sym, howto,
2917                       val, addend, relocation, contents)                       val, addend, relocation, contents)
2918       bfd *input_bfd;       bfd *input_bfd;
2919       asection *input_section;       asection *input_section;
# Line 2911  xcoff_reloc_type_br (input_bfd, input_se Line 2928  xcoff_reloc_type_br (input_bfd, input_se
2928  {  {
2929    struct xcoff_link_hash_entry *h;    struct xcoff_link_hash_entry *h;
2930    
2931    if (0 > rel->r_symndx)    if (0 > rel->r_symndx)
2932      return false;      return FALSE;
2933    
2934    h = obj_xcoff_sym_hashes (input_bfd)[rel->r_symndx];    h = obj_xcoff_sym_hashes (input_bfd)[rel->r_symndx];
2935    
# Line 2923  xcoff_reloc_type_br (input_bfd, input_se Line 2940  xcoff_reloc_type_br (input_bfd, input_se
2940       call is followed by a lwz r2,20(r1), but the call is not       call is followed by a lwz r2,20(r1), but the call is not
2941       going to global linkage code, we can replace the load with a       going to global linkage code, we can replace the load with a
2942       cror.  */       cror.  */
2943    if (NULL != h    if (NULL != h
2944        && bfd_link_hash_defined == h->root.type        && bfd_link_hash_defined == h->root.type
2945        && (rel->r_vaddr - input_section->vma + 8 <=        && rel->r_vaddr - input_section->vma + 8 <= input_section->size)
           input_section->_cooked_size))  
2946      {      {
2947        bfd_byte *pnext;        bfd_byte *pnext;
2948        unsigned long next;        unsigned long next;
2949          
2950        pnext = contents + (rel->r_vaddr - input_section->vma) + 4;        pnext = contents + (rel->r_vaddr - input_section->vma) + 4;
2951        next = bfd_get_32 (input_bfd, pnext);        next = bfd_get_32 (input_bfd, pnext);
2952          
2953        /* The _ptrgl function is magic.  It is used by the AIX        /* The _ptrgl function is magic.  It is used by the AIX
2954           compiler to call a function through a pointer.  */           compiler to call a function through a pointer.  */
2955        if (h->smclas == XMC_GL || strcmp (h->root.root.string, "._ptrgl") == 0)        if (h->smclas == XMC_GL || strcmp (h->root.root.string, "._ptrgl") == 0)
2956          {          {
2957            if (next == 0x4def7b82                        /* cror 15,15,15 */            if (next == 0x4def7b82                        /* cror 15,15,15 */
2958                || next == 0x4ffffb82                     /* cror 31,31,31 */                || next == 0x4ffffb82                     /* cror 31,31,31 */
2959                || next == 0x60000000)                    /* ori r0,r0,0 */                || next == 0x60000000)                    /* ori r0,r0,0 */
2960              bfd_put_32 (input_bfd, 0x80410014, pnext);  /* lwz r1,20(r1) */              bfd_put_32 (input_bfd, 0x80410014, pnext);  /* lwz r1,20(r1) */
2961              
2962          } else          }
2963            {        else
2964              if (next == 0x80410014)                      /* lwz r1,20(r1) */          {
2965                bfd_put_32 (input_bfd, 0x60000000, pnext); /* ori r0,r0,0 */            if (next == 0x80410014)                       /* lwz r1,20(r1) */
2966            }              bfd_put_32 (input_bfd, 0x60000000, pnext);  /* ori r0,r0,0 */
2967      }          }
2968    else if (NULL != h && bfd_link_hash_undefined == h->root.type)      }
2969      else if (NULL != h && bfd_link_hash_undefined == h->root.type)
2970      {      {
2971        /* Normally, this relocation is against a defined symbol.  In the        /* Normally, this relocation is against a defined symbol.  In the
2972           case where this is a partial link and the output section offset           case where this is a partial link and the output section offset
2973           is greater than 2^25, the linker will return an invalid error           is greater than 2^25, the linker will return an invalid error
2974           message that the relocation has been truncated.  Yes it has been           message that the relocation has been truncated.  Yes it has been
2975           truncated but no it not important.  For this case, disable the           truncated but no it not important.  For this case, disable the
2976           overflow checking. */           overflow checking. */
2977          
2978        howto->complain_on_overflow = complain_overflow_dont;        howto->complain_on_overflow = complain_overflow_dont;
2979      }      }
2980      
2981    howto->pc_relative = true;    howto->pc_relative = TRUE;
2982    howto->src_mask &= ~3;    howto->src_mask &= ~3;
2983    howto->dst_mask = howto->src_mask;    howto->dst_mask = howto->src_mask;
2984    
2985    /* A PC relative reloc includes the section address.  */    /* A PC relative reloc includes the section address.  */
2986    addend += input_section->vma;    addend += input_section->vma;
2987      
2988    *relocation = val + addend;    *relocation = val + addend;
2989    *relocation -= (input_section->output_section->vma +    *relocation -= (input_section->output_section->vma
2990                    input_section->output_offset);                    + input_section->output_offset);
2991    return true;    return TRUE;
2992  }  }
2993    
2994  boolean  bfd_boolean
2995  xcoff_reloc_type_crel (input_bfd, input_section, output_bfd, rel, sym, howto,  xcoff_reloc_type_crel (input_bfd, input_section, output_bfd, rel, sym, howto,
2996                         val, addend, relocation, contents)                         val, addend, relocation, contents)
2997       bfd *input_bfd ATTRIBUTE_UNUSED;       bfd *input_bfd ATTRIBUTE_UNUSED;
2998       asection *input_section;       asection *input_section;
# Line 2988  xcoff_reloc_type_crel (input_bfd, input_ Line 3005  xcoff_reloc_type_crel (input_bfd, input_
3005       bfd_vma *relocation;       bfd_vma *relocation;
3006       bfd_byte *contents ATTRIBUTE_UNUSED;       bfd_byte *contents ATTRIBUTE_UNUSED;
3007  {  {
3008    howto->pc_relative = true;    howto->pc_relative = TRUE;
3009    howto->src_mask &= ~3;    howto->src_mask &= ~3;
3010    howto->dst_mask = howto->src_mask;    howto->dst_mask = howto->src_mask;
3011    
# Line 2996  xcoff_reloc_type_crel (input_bfd, input_ Line 3013  xcoff_reloc_type_crel (input_bfd, input_
3013    addend += input_section->vma;    addend += input_section->vma;
3014    
3015    *relocation = val + addend;    *relocation = val + addend;
3016    *relocation -= (input_section->output_section->vma +    *relocation -= (input_section->output_section->vma
3017                    input_section->output_offset);                    + input_section->output_offset);
3018    return true;    return TRUE;
3019  }  }
3020    
3021  static boolean  static bfd_boolean
3022  xcoff_complain_overflow_dont_func (input_bfd, val, relocation, howto)  xcoff_complain_overflow_dont_func (input_bfd, val, relocation, howto)
3023       bfd *input_bfd ATTRIBUTE_UNUSED;       bfd *input_bfd ATTRIBUTE_UNUSED;
3024       bfd_vma val ATTRIBUTE_UNUSED;       bfd_vma val ATTRIBUTE_UNUSED;
3025       bfd_vma relocation ATTRIBUTE_UNUSED;       bfd_vma relocation ATTRIBUTE_UNUSED;
3026       struct reloc_howto_struct *howto ATTRIBUTE_UNUSED;       struct reloc_howto_struct *howto ATTRIBUTE_UNUSED;
3027  {  {
3028    return false;    return FALSE;
3029  }  }
3030    
3031  static boolean  static bfd_boolean
3032  xcoff_complain_overflow_bitfield_func (input_bfd, val, relocation, howto)  xcoff_complain_overflow_bitfield_func (input_bfd, val, relocation, howto)
3033       bfd *input_bfd;       bfd *input_bfd;
3034       bfd_vma val;       bfd_vma val;
3035       bfd_vma relocation;       bfd_vma relocation;
3036       struct reloc_howto_struct *howto;       struct reloc_howto_struct *howto;
3037  {  {
3038    bfd_vma addrmask, fieldmask, signmask, ss;    bfd_vma addrmask, fieldmask, signmask, ss;
3039    bfd_vma a, b, sum;    bfd_vma a, b, sum;
3040      
3041    /* Get the values to be added together.  For signed and unsigned    /* Get the values to be added together.  For signed and unsigned
3042       relocations, we assume that all values should be truncated to       relocations, we assume that all values should be truncated to
3043       the size of an address.  For bitfields, all the bits matter.       the size of an address.  For bitfields, all the bits matter.
# Line 3036  xcoff_complain_overflow_bitfield_func (i Line 3053  xcoff_complain_overflow_bitfield_func (i
3053       operand.  */       operand.  */
3054    a >>= howto->rightshift;    a >>= howto->rightshift;
3055    b >>= howto->bitpos;    b >>= howto->bitpos;
3056      
3057    /* Bitfields are sometimes used for signed numbers; for    /* Bitfields are sometimes used for signed numbers; for
3058       example, a 13-bit field sometimes represents values in       example, a 13-bit field sometimes represents values in
3059       0..8191 and sometimes represents values in -4096..4095.       0..8191 and sometimes represents values in -4096..4095.
# Line 3048  xcoff_complain_overflow_bitfield_func (i Line 3065  xcoff_complain_overflow_bitfield_func (i
3065       assumed that it was fully sign extended, and we will keep       assumed that it was fully sign extended, and we will keep
3066       that assumption.  */       that assumption.  */
3067    signmask = (fieldmask >> 1) + 1;    signmask = (fieldmask >> 1) + 1;
3068                      
3069    if ((a & ~ fieldmask) != 0)    if ((a & ~ fieldmask) != 0)
3070      {      {
3071        /* Some bits out of the field are set.  This might not        /* Some bits out of the field are set.  This might not
# Line 3059  xcoff_complain_overflow_bitfield_func (i Line 3076  xcoff_complain_overflow_bitfield_func (i
3076           ones, we are OK, assuming a signed bitfield.  */           ones, we are OK, assuming a signed bitfield.  */
3077        ss = (signmask << howto->rightshift) - 1;        ss = (signmask << howto->rightshift) - 1;
3078        if ((ss | relocation) != ~ (bfd_vma) 0)        if ((ss | relocation) != ~ (bfd_vma) 0)
3079          return true;          return TRUE;
3080        a &= fieldmask;        a &= fieldmask;
3081      }      }
3082      
3083    /* We just assume (b & ~ fieldmask) == 0.  */    /* We just assume (b & ~ fieldmask) == 0.  */
3084      
3085    /* We explicitly permit wrap around if this relocation    /* We explicitly permit wrap around if this relocation
3086       covers the high bit of an address.  The Linux kernel       covers the high bit of an address.  The Linux kernel
3087       relies on it, and it is the only way to write assembler       relies on it, and it is the only way to write assembler
# Line 3072  xcoff_complain_overflow_bitfield_func (i Line 3089  xcoff_complain_overflow_bitfield_func (i
3089       away from the location at which it is linked.  */       away from the location at which it is linked.  */
3090    if (howto->bitsize + howto->rightshift    if (howto->bitsize + howto->rightshift
3091        == bfd_arch_bits_per_address (input_bfd))        == bfd_arch_bits_per_address (input_bfd))
3092      return false;      return FALSE;
3093      
3094    sum = a + b;    sum = a + b;
3095    if (sum < a || (sum & ~ fieldmask) != 0)    if (sum < a || (sum & ~ fieldmask) != 0)
3096      {      {
# Line 3081  xcoff_complain_overflow_bitfield_func (i Line 3098  xcoff_complain_overflow_bitfield_func (i
3098           for signed operands again.  Here is the overflow test           for signed operands again.  Here is the overflow test
3099           is as for complain_overflow_signed.  */           is as for complain_overflow_signed.  */
3100        if (((~ (a ^ b)) & (a ^ sum)) & signmask)        if (((~ (a ^ b)) & (a ^ sum)) & signmask)
3101          return true;          return TRUE;
3102      }      }
3103      
3104    return false;    return FALSE;
3105  }  }
3106    
3107  static boolean  static bfd_boolean
3108  xcoff_complain_overflow_signed_func (input_bfd, val, relocation, howto)  xcoff_complain_overflow_signed_func (input_bfd, val, relocation, howto)
3109       bfd *input_bfd;       bfd *input_bfd;
3110       bfd_vma val;       bfd_vma val;
3111       bfd_vma relocation;       bfd_vma relocation;
# Line 3096  xcoff_complain_overflow_signed_func (inp Line 3113  xcoff_complain_overflow_signed_func (inp
3113  {  {
3114    bfd_vma addrmask, fieldmask, signmask, ss;    bfd_vma addrmask, fieldmask, signmask, ss;
3115    bfd_vma a, b, sum;    bfd_vma a, b, sum;
3116      
3117    /* Get the values to be added together.  For signed and unsigned    /* Get the values to be added together.  For signed and unsigned
3118       relocations, we assume that all values should be truncated to       relocations, we assume that all values should be truncated to
3119       the size of an address.  For bitfields, all the bits matter.       the size of an address.  For bitfields, all the bits matter.
# Line 3107  xcoff_complain_overflow_signed_func (inp Line 3124  xcoff_complain_overflow_signed_func (inp
3124    b = val & howto->src_mask;    b = val & howto->src_mask;
3125    
3126    a = (a & addrmask) >> howto->rightshift;    a = (a & addrmask) >> howto->rightshift;
3127      
3128    /* If any sign bits are set, all sign bits must be set.    /* If any sign bits are set, all sign bits must be set.
3129       That is, A must be a valid negative address after       That is, A must be a valid negative address after
3130       shifting.  */       shifting.  */
3131    signmask = ~ (fieldmask >> 1);    signmask = ~ (fieldmask >> 1);
3132    ss = a & signmask;    ss = a & signmask;
3133    if (ss != 0 && ss != ((addrmask >> howto->rightshift) & signmask))    if (ss != 0 && ss != ((addrmask >> howto->rightshift) & signmask))
3134      return true;      return TRUE;
3135      
3136    /* We only need this next bit of code if the sign bit of B    /* We only need this next bit of code if the sign bit of B
3137       is below the sign bit of A.  This would only happen if       is below the sign bit of A.  This would only happen if
3138       SRC_MASK had fewer bits than BITSIZE.  Note that if       SRC_MASK had fewer bits than BITSIZE.  Note that if
# Line 3128  xcoff_complain_overflow_signed_func (inp Line 3145  xcoff_complain_overflow_signed_func (inp
3145        /* Set all the bits above the sign bit.  */        /* Set all the bits above the sign bit.  */
3146        b -= signmask <<= 1;        b -= signmask <<= 1;
3147      }      }
3148      
3149    b = (b & addrmask) >> howto->bitpos;    b = (b & addrmask) >> howto->bitpos;
3150      
3151    /* Now we can do the addition.  */    /* Now we can do the addition.  */
3152    sum = a + b;    sum = a + b;
3153      
3154    /* See if the result has the correct sign.  Bits above the    /* See if the result has the correct sign.  Bits above the
3155       sign bit are junk now; ignore them.  If the sum is       sign bit are junk now; ignore them.  If the sum is
3156       positive, make sure we did not have all negative inputs;       positive, make sure we did not have all negative inputs;
# Line 3144  xcoff_complain_overflow_signed_func (inp Line 3161  xcoff_complain_overflow_signed_func (inp
3161    */    */
3162    signmask = (fieldmask >> 1) + 1;    signmask = (fieldmask >> 1) + 1;
3163    if (((~ (a ^ b)) & (a ^ sum)) & signmask)    if (((~ (a ^ b)) & (a ^ sum)) & signmask)
3164      return true;      return TRUE;
3165      
3166    return false;    return FALSE;
3167  }  }
3168    
3169  static boolean  static bfd_boolean
3170  xcoff_complain_overflow_unsigned_func (input_bfd, val, relocation, howto)  xcoff_complain_overflow_unsigned_func (input_bfd, val, relocation, howto)
3171       bfd *input_bfd;       bfd *input_bfd;
3172       bfd_vma val;       bfd_vma val;
3173       bfd_vma relocation;       bfd_vma relocation;
3174       struct reloc_howto_struct *howto;       struct reloc_howto_struct *howto;
3175  {  {
3176    bfd_vma addrmask, fieldmask;    bfd_vma addrmask, fieldmask;
3177    bfd_vma a, b, sum;    bfd_vma a, b, sum;
3178      
3179    /* Get the values to be added together.  For signed and unsigned    /* Get the values to be added together.  For signed and unsigned
3180       relocations, we assume that all values should be truncated to       relocations, we assume that all values should be truncated to
3181       the size of an address.  For bitfields, all the bits matter.       the size of an address.  For bitfields, all the bits matter.
# Line 3183  xcoff_complain_overflow_unsigned_func (i Line 3200  xcoff_complain_overflow_unsigned_func (i
3200    b = (b & addrmask) >> howto->bitpos;    b = (b & addrmask) >> howto->bitpos;
3201    sum = (a + b) & addrmask;    sum = (a + b) & addrmask;
3202    if ((a | b | sum) & ~ fieldmask)    if ((a | b | sum) & ~ fieldmask)
3203      return true;      return TRUE;
3204      
3205    return false;    return FALSE;
3206  }  }
3207    
3208  /* This is the relocation function for the RS/6000/POWER/PowerPC.  /* This is the relocation function for the RS/6000/POWER/PowerPC.
3209     This is currently the only processor which uses XCOFF; I hope that     This is currently the only processor which uses XCOFF; I hope that
3210     will never change.       will never change.
3211    
3212     I took the relocation type definitions from two documents:     I took the relocation type definitions from two documents:
3213     the PowerPC AIX Version 4 Application Binary Interface, First     the PowerPC AIX Version 4 Application Binary Interface, First
3214     Edition (April 1992), and the PowerOpen ABI, Big-Endian     Edition (April 1992), and the PowerOpen ABI, Big-Endian
3215     32-Bit Hardware Implementation (June 30, 1994).  Differences     32-Bit Hardware Implementation (June 30, 1994).  Differences
3216     between the documents are noted below.     between the documents are noted below.
3217    
3218     Unsupported r_type's     Unsupported r_type's
3219    
3220     R_RTB:     R_RTB:
3221     R_RRTBI:     R_RRTBI:
3222     R_RRTBA:     R_RRTBA:
3223            
3224     These relocs are defined by the PowerPC ABI to be     These relocs are defined by the PowerPC ABI to be
3225     relative branches which use half of the difference     relative branches which use half of the difference
3226     between the symbol and the program counter.  I can't     between the symbol and the program counter.  I can't
3227     quite figure out when this is useful.  These relocs are     quite figure out when this is useful.  These relocs are
3228     not defined by the PowerOpen ABI.     not defined by the PowerOpen ABI.
3229    
3230     Supported r_type's     Supported r_type's
3231    
# Line 3216  xcoff_complain_overflow_unsigned_func (i Line 3233  xcoff_complain_overflow_unsigned_func (i
3233     Simple positive relocation.     Simple positive relocation.
3234    
3235     R_NEG:     R_NEG:
3236     Simple negative relocation.     Simple negative relocation.
3237    
3238     R_REL:     R_REL:
3239     Simple PC relative relocation.     Simple PC relative relocation.
# Line 3234  xcoff_complain_overflow_unsigned_func (i Line 3251  xcoff_complain_overflow_unsigned_func (i
3251    
3252     R_GL:     R_GL:
3253     GL linkage relocation.  The value of this relocation     GL linkage relocation.  The value of this relocation
3254     is the address of the entry in the TOC section.     is the address of the entry in the TOC section.
3255    
3256     R_TCL:     R_TCL:
3257     Local object TOC address.  I can't figure out the     Local object TOC address.  I can't figure out the
3258     difference between this and case R_GL.     difference between this and case R_GL.
3259    
3260     R_TRL:     R_TRL:
3261     TOC relative relocation.  A TOC relative load instruction     TOC relative relocation.  A TOC relative load instruction
3262     which may be changed to a load address instruction.     which may be changed to a load address instruction.
3263     FIXME: We don't currently implement this optimization.     FIXME: We don't currently implement this optimization.
3264    
3265     R_TRLA:     R_TRLA:
3266     TOC relative relocation.  This is a TOC relative load     TOC relative relocation.  This is a TOC relative load
# Line 3253  xcoff_complain_overflow_unsigned_func (i Line 3270  xcoff_complain_overflow_unsigned_func (i
3270    
3271     R_BA:     R_BA:
3272     Absolute branch.  We don't want to mess with the lower     Absolute branch.  We don't want to mess with the lower
3273     two bits of the instruction.     two bits of the instruction.
3274    
3275     R_CAI:     R_CAI:
3276     The PowerPC ABI defines this as an absolute call which     The PowerPC ABI defines this as an absolute call which
3277     may be modified to become a relative call.  The PowerOpen     may be modified to become a relative call.  The PowerOpen
3278     ABI does not define this relocation type.     ABI does not define this relocation type.
3279      
3280     R_RBA:     R_RBA:
3281     Absolute branch which may be modified to become a     Absolute branch which may be modified to become a
3282     relative branch.     relative branch.
3283    
3284     R_RBAC:     R_RBAC:
3285     The PowerPC ABI defines this as an absolute branch to a     The PowerPC ABI defines this as an absolute branch to a
3286     fixed address which may be modified to an absolute branch     fixed address which may be modified to an absolute branch
3287     to a symbol.  The PowerOpen ABI does not define this     to a symbol.  The PowerOpen ABI does not define this
3288     relocation type.     relocation type.
3289    
3290     R_RBRC:     R_RBRC:
3291     The PowerPC ABI defines this as an absolute branch to a     The PowerPC ABI defines this as an absolute branch to a
3292     fixed address which may be modified to a relative branch.     fixed address which may be modified to a relative branch.
3293     The PowerOpen ABI does not define this relocation type.     The PowerOpen ABI does not define this relocation type.
3294    
3295     R_BR:     R_BR:
3296     Relative branch.  We don't want to mess with the lower     Relative branch.  We don't want to mess with the lower
3297     two bits of the instruction.     two bits of the instruction.
3298    
3299     R_CREL:     R_CREL:
3300     The PowerPC ABI defines this as a relative call which may     The PowerPC ABI defines this as a relative call which may
3301     be modified to become an absolute call.  The PowerOpen     be modified to become an absolute call.  The PowerOpen
3302     ABI does not define this relocation type.     ABI does not define this relocation type.
3303    
3304     R_RBR:     R_RBR:
3305     A relative branch which may be modified to become an     A relative branch which may be modified to become an
3306     absolute branch.  FIXME: We don't implement this,     absolute branch.  FIXME: We don't implement this,
3307     although we should for symbols of storage mapping class     although we should for symbols of storage mapping class
3308     XMC_XO.     XMC_XO.
3309    
3310     R_RL:     R_RL:
3311     The PowerPC AIX ABI describes this as a load which may be     The PowerPC AIX ABI describes this as a load which may be
3312     changed to a load address.  The PowerOpen ABI says this     changed to a load address.  The PowerOpen ABI says this
3313     is the same as case R_POS.     is the same as case R_POS.
3314    
3315     R_RLA:     R_RLA:
3316     The PowerPC AIX ABI describes this as a load address     The PowerPC AIX ABI describes this as a load address
3317     which may be changed to a load.  The PowerOpen ABI says     which may be changed to a load.  The PowerOpen ABI says
3318     this is the same as R_POS.     this is the same as R_POS.
3319  */  */
3320    
3321  boolean  bfd_boolean
3322  xcoff_ppc_relocate_section (output_bfd, info, input_bfd,  xcoff_ppc_relocate_section (output_bfd, info, input_bfd,
3323                              input_section, contents, relocs, syms,                              input_section, contents, relocs, syms,
3324                              sections)                              sections)
# Line 3333  xcoff_ppc_relocate_section (output_bfd, Line 3350  xcoff_ppc_relocate_section (output_bfd,
3350        bfd_byte *location;        bfd_byte *location;
3351    
3352        /* Relocation type R_REF is a special relocation type which is        /* Relocation type R_REF is a special relocation type which is
3353           merely used to prevent garbage collection from occurring for           merely used to prevent garbage collection from occurring for
3354           the csect including the symbol which it references.  */           the csect including the symbol which it references.  */
3355        if (rel->r_type == R_REF)        if (rel->r_type == R_REF)
3356          continue;          continue;
3357    
# Line 3343  xcoff_ppc_relocate_section (output_bfd, Line 3360  xcoff_ppc_relocate_section (output_bfd,
3360        howto.rightshift = 0;        howto.rightshift = 0;
3361        howto.bitsize = (rel->r_size & 0x1f) + 1;        howto.bitsize = (rel->r_size & 0x1f) + 1;
3362        howto.size = howto.bitsize > 16 ? 2 : 1;        howto.size = howto.bitsize > 16 ? 2 : 1;
3363        howto.pc_relative = false;        howto.pc_relative = FALSE;
3364        howto.bitpos = 0;        howto.bitpos = 0;
3365        howto.complain_on_overflow = rel->r_size & 0x80 ?        howto.complain_on_overflow = (rel->r_size & 0x80
3366          complain_overflow_signed : complain_overflow_bitfield;                                      ? complain_overflow_signed
3367                                        : complain_overflow_bitfield);
3368        howto.special_function = NULL;        howto.special_function = NULL;
3369        howto.name = "internal";        howto.name = "internal";
3370        howto.partial_inplace = true;        howto.partial_inplace = TRUE;
3371        howto.src_mask = howto.dst_mask = N_ONES(howto.bitsize);        howto.src_mask = howto.dst_mask = N_ONES (howto.bitsize);
3372        howto.pcrel_offset = false;        howto.pcrel_offset = FALSE;
3373    
3374        /* symbol */        /* symbol */
3375        val = 0;        val = 0;
3376        addend = 0;        addend = 0;
3377        h = NULL;        h = NULL;
3378        sym = NULL;        sym = NULL;
3379        symndx = rel->r_symndx;              symndx = rel->r_symndx;
3380    
3381        if (-1 != symndx)        if (-1 != symndx)
3382          {          {
3383            asection *sec;            asection *sec;
3384              
3385            h = obj_xcoff_sym_hashes (input_bfd)[symndx];            h = obj_xcoff_sym_hashes (input_bfd)[symndx];
3386            sym = syms + symndx;            sym = syms + symndx;
3387            addend = - sym->n_value;            addend = - sym->n_value;
3388              
3389            if (NULL == h)            if (NULL == h)
3390              {              {
3391                sec = sections[symndx];                sec = sections[symndx];
3392                /* Hack to make sure we use the right TOC anchor value                /* Hack to make sure we use the right TOC anchor value
# Line 3381  xcoff_ppc_relocate_section (output_bfd, Line 3399  xcoff_ppc_relocate_section (output_bfd,
3399                         + sec->output_offset                         + sec->output_offset
3400                         + sym->n_value                         + sym->n_value
3401                         - sec->vma);                         - sec->vma);
3402              }              }
3403            else            else
3404              {              {
3405                if (h->root.type == bfd_link_hash_defined                if (h->root.type == bfd_link_hash_defined
3406                    || h->root.type == bfd_link_hash_defweak)                    || h->root.type == bfd_link_hash_defweak)
3407                  {                  {
3408                    sec = h->root.u.def.section;                    sec = h->root.u.def.section;
3409                    val = (h->root.u.def.value                    val = (h->root.u.def.value
3410                           + sec->output_section->vma                           + sec->output_section->vma
3411                           + sec->output_offset);                           + sec->output_offset);
3412                  }                  }
3413                else if (h->root.type == bfd_link_hash_common)                else if (h->root.type == bfd_link_hash_common)
3414                  {                  {
3415                    sec = h->root.u.c.p->section;                    sec = h->root.u.c.p->section;
3416                    val = (sec->output_section->vma                    val = (sec->output_section->vma
3417                           + sec->output_offset);                           + sec->output_offset);
3418                      
3419                  }                  }
3420                else if ((0 == (h->flags & (XCOFF_DEF_DYNAMIC | XCOFF_IMPORT)))                else if ((0 == (h->flags & (XCOFF_DEF_DYNAMIC | XCOFF_IMPORT)))
3421                         && ! info->relocateable)                         && ! info->relocatable)
3422                  {                  {
3423                    if (! ((*info->callbacks->undefined_symbol)                    if (! ((*info->callbacks->undefined_symbol)
3424                           (info, h->root.root.string, input_bfd, input_section,                           (info, h->root.root.string, input_bfd, input_section,
3425                            rel->r_vaddr - input_section->vma, true)))                            rel->r_vaddr - input_section->vma, TRUE)))
3426                      return false;                      return FALSE;
3427                      
3428                    /* Don't try to process the reloc.  It can't help, and                    /* Don't try to process the reloc.  It can't help, and
3429                       it may generate another error.  */                       it may generate another error.  */
3430                    continue;                    continue;
# Line 3414  xcoff_ppc_relocate_section (output_bfd, Line 3432  xcoff_ppc_relocate_section (output_bfd,
3432              }              }
3433          }          }
3434    
3435        if (rel->r_type >= XCOFF_MAX_CALCULATE_RELOCATION        if (rel->r_type >= XCOFF_MAX_CALCULATE_RELOCATION
3436            || (false == xcoff_calculate_relocation[rel->r_type]            || !((*xcoff_calculate_relocation[rel->r_type])
3437                (input_bfd, input_section, output_bfd, rel, sym, &howto, val,                 (input_bfd, input_section, output_bfd, rel, sym, &howto, val,
3438                 addend, &relocation, contents)))                  addend, &relocation, contents)))
3439          return false;          return FALSE;
3440          
3441        /* address */        /* address */
3442        address = rel->r_vaddr - input_section->vma;        address = rel->r_vaddr - input_section->vma;
3443        location = contents + address;        location = contents + address;
3444          
3445        if (address > input_section->_raw_size)        if (address > input_section->size)
3446          abort();          abort ();
3447    
3448        /* Get the value we are going to relocate.  */        /* Get the value we are going to relocate.  */
3449        if (1 == howto.size)        if (1 == howto.size)
3450          value_to_relocate = bfd_get_16 (input_bfd, location);          value_to_relocate = bfd_get_16 (input_bfd, location);
3451        else        else
3452          value_to_relocate = bfd_get_32 (input_bfd, location);          value_to_relocate = bfd_get_32 (input_bfd, location);
3453          
3454        /* overflow.          /* overflow.
3455            
3456           FIXME: We may drop bits during the addition           FIXME: We may drop bits during the addition
3457           which we don't check for.  We must either check at every single           which we don't check for.  We must either check at every single
3458           operation, which would be tedious, or we must do the computations           operation, which would be tedious, or we must do the computations
3459           in a type larger than bfd_vma, which would be inefficient.  */           in a type larger than bfd_vma, which would be inefficient.  */
         
       if ((unsigned int) howto.complain_on_overflow >=  
           XCOFF_MAX_COMPLAIN_OVERFLOW)  
         abort();  
3460    
3461        if ((true == xcoff_complain_overflow[howto.complain_on_overflow]        if ((unsigned int) howto.complain_on_overflow
3462             (input_bfd, value_to_relocate, relocation, &howto)))            >= XCOFF_MAX_COMPLAIN_OVERFLOW)
3463            abort ();
3464    
3465          if (((*xcoff_complain_overflow[howto.complain_on_overflow])
3466               (input_bfd, value_to_relocate, relocation, &howto)))
3467          {          {
3468            const char *name;            const char *name;
3469            char buf[SYMNMLEN + 1];            char buf[SYMNMLEN + 1];
3470            char reloc_type_name[10];            char reloc_type_name[10];
3471              
3472            if (symndx == -1)            if (symndx == -1)
3473              {              {
3474                name = "*ABS*";                name = "*ABS*";
3475              }              }
3476            else if (h != NULL)            else if (h != NULL)
3477              {              {
3478                name = h->root.root.string;                name = NULL;
3479              }              }
3480            else            else
3481              {              {
3482                name = _bfd_coff_internal_syment_name (input_bfd, sym, buf);                name = _bfd_coff_internal_syment_name (input_bfd, sym, buf);
3483                if (name == NULL)                if (name == NULL)
3484                  name = "UNKNOWN";                  name = "UNKNOWN";
3485              }              }
3486            sprintf (reloc_type_name, "0x%02x", rel->r_type);            sprintf (reloc_type_name, "0x%02x", rel->r_type);
3487              
3488            if (! ((*info->callbacks->reloc_overflow)            if (! ((*info->callbacks->reloc_overflow)
3489                   (info, name, reloc_type_name, (bfd_vma) 0, input_bfd,                   (info, (h ? &h->root : NULL), name, reloc_type_name,
3490                    input_section, rel->r_vaddr - input_section->vma)))                    (bfd_vma) 0, input_bfd, input_section,
3491              return false;                    rel->r_vaddr - input_section->vma)))
3492                return FALSE;
3493          }          }
3494          
3495        /* Add RELOCATION to the right bits of VALUE_TO_RELOCATE.  */        /* Add RELOCATION to the right bits of VALUE_TO_RELOCATE.  */
3496        value_to_relocate = ((value_to_relocate & ~howto.dst_mask) |        value_to_relocate = ((value_to_relocate & ~howto.dst_mask)
3497                             (((value_to_relocate & howto.src_mask) +                             | (((value_to_relocate & howto.src_mask)
3498                               relocation) & howto.dst_mask));                                 + relocation) & howto.dst_mask));
3499          
3500        /* Put the value back in the object file.  */        /* Put the value back in the object file.  */
3501        if (1 == howto.size)        if (1 == howto.size)
3502          bfd_put_16 (input_bfd, value_to_relocate, location);          bfd_put_16 (input_bfd, value_to_relocate, location);
3503        else        else
3504          bfd_put_32 (input_bfd, value_to_relocate, location);          bfd_put_32 (input_bfd, value_to_relocate, location);
3505      }      }
3506    
3507    return true;    return TRUE;
3508  }  }
3509    
3510  static boolean  static bfd_boolean
3511  _bfd_xcoff_put_ldsymbol_name (abfd, ldinfo, ldsym, name)  _bfd_xcoff_put_ldsymbol_name (abfd, ldinfo, ldsym, name)
3512       bfd *abfd ATTRIBUTE_UNUSED;       bfd *abfd ATTRIBUTE_UNUSED;
3513           struct xcoff_loader_info *ldinfo;           struct xcoff_loader_info *ldinfo;
# Line 3505  _bfd_xcoff_put_ldsymbol_name (abfd, ldin Line 3524  _bfd_xcoff_put_ldsymbol_name (abfd, ldin
3524        if (ldinfo->string_size + len + 3 > ldinfo->string_alc)        if (ldinfo->string_size + len + 3 > ldinfo->string_alc)
3525          {          {
3526            bfd_size_type newalc;            bfd_size_type newalc;
3527            bfd_byte *newstrings;            char *newstrings;
3528    
3529            newalc = ldinfo->string_alc * 2;            newalc = ldinfo->string_alc * 2;
3530            if (newalc == 0)            if (newalc == 0)
# Line 3513  _bfd_xcoff_put_ldsymbol_name (abfd, ldin Line 3532  _bfd_xcoff_put_ldsymbol_name (abfd, ldin
3532            while (ldinfo->string_size + len + 3 > newalc)            while (ldinfo->string_size + len + 3 > newalc)
3533              newalc *= 2;              newalc *= 2;
3534    
3535            newstrings = ((bfd_byte *)            newstrings = bfd_realloc (ldinfo->strings, newalc);
                         bfd_realloc ((PTR) ldinfo->strings, newalc));  
3536            if (newstrings == NULL)            if (newstrings == NULL)
3537              {              {
3538                ldinfo->failed = true;                ldinfo->failed = TRUE;
3539                return false;                return FALSE;
3540              }              }
3541            ldinfo->string_alc = newalc;            ldinfo->string_alc = newalc;
3542            ldinfo->strings = newstrings;            ldinfo->strings = newstrings;
# Line 3532  _bfd_xcoff_put_ldsymbol_name (abfd, ldin Line 3550  _bfd_xcoff_put_ldsymbol_name (abfd, ldin
3550        ldinfo->string_size += len + 3;        ldinfo->string_size += len + 3;
3551      }      }
3552    
3553    return true;    return TRUE;
3554  }  }
3555    
3556  static boolean  static bfd_boolean
3557  _bfd_xcoff_put_symbol_name (bfd *abfd, struct bfd_strtab_hash *strtab,  _bfd_xcoff_put_symbol_name (bfd *abfd, struct bfd_strtab_hash *strtab,
3558                              struct internal_syment *sym,                              struct internal_syment *sym,
3559                              const char *name)                              const char *name)
# Line 3546  _bfd_xcoff_put_symbol_name (bfd *abfd, s Line 3564  _bfd_xcoff_put_symbol_name (bfd *abfd, s
3564      }      }
3565    else    else
3566      {      {
3567        boolean hash;        bfd_boolean hash;
3568        bfd_size_type indx;        bfd_size_type indx;
3569    
3570        hash = true;        hash = TRUE;
3571        if ((abfd->flags & BFD_TRADITIONAL_FORMAT) != 0)        if ((abfd->flags & BFD_TRADITIONAL_FORMAT) != 0)
3572          hash = false;          hash = FALSE;
3573        indx = _bfd_stringtab_add (strtab, name, hash, false);        indx = _bfd_stringtab_add (strtab, name, hash, FALSE);
3574        if (indx == (bfd_size_type) -1)        if (indx == (bfd_size_type) -1)
3575          return false;          return FALSE;
3576        sym->_n._n_n._n_zeroes = 0;        sym->_n._n_n._n_zeroes = 0;
3577        sym->_n._n_n._n_offset = STRING_SIZE_SIZE + indx;        sym->_n._n_n._n_offset = STRING_SIZE_SIZE + indx;
3578      }      }
3579    return true;    return TRUE;
3580  }  }
3581    
3582  static asection *  static asection *
# Line 3578  xcoff_create_csect_from_smclas (abfd, au Line 3596  xcoff_create_csect_from_smclas (abfd, au
3596      ".td", NULL, ".sv3264"      ".td", NULL, ".sv3264"
3597    };    };
3598    
3599    if ((19 >= aux->x_csect.x_smclas) &&    if ((19 >= aux->x_csect.x_smclas)
3600        (NULL != names[aux->x_csect.x_smclas]))        && (NULL != names[aux->x_csect.x_smclas]))
3601      {      {
3602        return_value = bfd_make_section_anyway        return_value = bfd_make_section_anyway
3603          (abfd, names[aux->x_csect.x_smclas]);          (abfd, names[aux->x_csect.x_smclas]);
# Line 3587  xcoff_create_csect_from_smclas (abfd, au Line 3605  xcoff_create_csect_from_smclas (abfd, au
3605    else    else
3606      {      {
3607        (*_bfd_error_handler)        (*_bfd_error_handler)
3608          (_("%s: symbol `%s' has unrecognized smclas %d"),          (_("%B: symbol `%s' has unrecognized smclas %d"),
3609           bfd_archive_filename (abfd), symbol_name, aux->x_csect.x_smclas);           abfd, symbol_name, aux->x_csect.x_smclas);
3610        bfd_set_error (bfd_error_bad_value);        bfd_set_error (bfd_error_bad_value);
3611      }      }
3612    
3613    return return_value;    return return_value;
3614  }  }
3615    
3616  static boolean  static bfd_boolean
3617  xcoff_is_lineno_count_overflow (abfd, value)  xcoff_is_lineno_count_overflow (abfd, value)
3618      bfd *abfd ATTRIBUTE_UNUSED;      bfd *abfd ATTRIBUTE_UNUSED;
3619          bfd_vma value;          bfd_vma value;
3620  {  {
3621    if (0xffff <= value)    if (0xffff <= value)
3622      return true;      return TRUE;
3623    
3624    return false;    return FALSE;
3625  }  }
3626    
3627  static boolean  static bfd_boolean
3628  xcoff_is_reloc_count_overflow (abfd, value)  xcoff_is_reloc_count_overflow (abfd, value)
3629      bfd *abfd ATTRIBUTE_UNUSED;      bfd *abfd ATTRIBUTE_UNUSED;
3630          bfd_vma value;          bfd_vma value;
3631  {  {
3632    if (0xffff <= value)    if (0xffff <= value)
3633      return true;      return TRUE;
3634    
3635    return false;    return FALSE;
3636  }  }
3637    
3638  static bfd_vma  static bfd_vma
# Line 3622  xcoff_loader_symbol_offset (abfd, ldhdr) Line 3640  xcoff_loader_symbol_offset (abfd, ldhdr)
3640      bfd *abfd;      bfd *abfd;
3641      struct internal_ldhdr *ldhdr ATTRIBUTE_UNUSED;      struct internal_ldhdr *ldhdr ATTRIBUTE_UNUSED;
3642  {  {
3643    return bfd_xcoff_ldhdrsz(abfd);    return bfd_xcoff_ldhdrsz (abfd);
3644  }  }
3645    
3646  static bfd_vma  static bfd_vma
# Line 3630  xcoff_loader_reloc_offset (abfd, ldhdr) Line 3648  xcoff_loader_reloc_offset (abfd, ldhdr)
3648      bfd *abfd;      bfd *abfd;
3649      struct internal_ldhdr *ldhdr;      struct internal_ldhdr *ldhdr;
3650  {  {
3651    return bfd_xcoff_ldhdrsz(abfd) +    return bfd_xcoff_ldhdrsz (abfd) + ldhdr->l_nsyms * bfd_xcoff_ldsymsz (abfd);
     (ldhdr->l_nsyms * bfd_xcoff_ldsymsz(abfd));  
3652  }  }
3653    
3654  static boolean  static bfd_boolean
3655  xcoff_generate_rtinit  (abfd, init, fini, rtld)  xcoff_generate_rtinit  (abfd, init, fini, rtld)
3656       bfd *abfd;       bfd *abfd;
3657       const char *init;       const char *init;
3658       const char *fini;       const char *fini;
3659       boolean rtld;       bfd_boolean rtld;
3660  {  {
3661    bfd_byte filehdr_ext[FILHSZ];    bfd_byte filehdr_ext[FILHSZ];
3662    bfd_byte scnhdr_ext[SCNHSZ];    bfd_byte scnhdr_ext[SCNHSZ];
# Line 3656  xcoff_generate_rtinit  (abfd, init, fini Line 3673  xcoff_generate_rtinit  (abfd, init, fini
3673    struct internal_syment syment;    struct internal_syment syment;
3674    union internal_auxent auxent;    union internal_auxent auxent;
3675    struct internal_reloc reloc;    struct internal_reloc reloc;
3676      
3677    char *data_name = ".data";    char *data_name = ".data";
3678    char *rtinit_name = "__rtinit";    char *rtinit_name = "__rtinit";
3679    char *rtld_name = "__rtld";    char *rtld_name = "__rtld";
3680      
3681    if (! bfd_xcoff_rtinit_size (abfd))    if (! bfd_xcoff_rtinit_size (abfd))
3682      return false;      return FALSE;
3683    
3684    initsz = (init == NULL ? 0 : 1 + strlen (init));    initsz = (init == NULL ? 0 : 1 + strlen (init));
3685    finisz = (fini == NULL ? 0 : 1 + strlen (fini));    finisz = (fini == NULL ? 0 : 1 + strlen (fini));
# Line 3671  xcoff_generate_rtinit  (abfd, init, fini Line 3688  xcoff_generate_rtinit  (abfd, init, fini
3688    memset (filehdr_ext, 0, FILHSZ);    memset (filehdr_ext, 0, FILHSZ);
3689    memset (&filehdr, 0, sizeof (struct internal_filehdr));    memset (&filehdr, 0, sizeof (struct internal_filehdr));
3690    filehdr.f_magic = bfd_xcoff_magic_number (abfd);    filehdr.f_magic = bfd_xcoff_magic_number (abfd);
3691    filehdr.f_nscns = 1;    filehdr.f_nscns = 1;
3692    filehdr.f_timdat = 0;    filehdr.f_timdat = 0;
3693    filehdr.f_nsyms = 0;  /* at least 6, no more than 10 */    filehdr.f_nsyms = 0;  /* at least 6, no more than 10 */
3694    filehdr.f_symptr = 0; /* set below */    filehdr.f_symptr = 0; /* set below */
# Line 3692  xcoff_generate_rtinit  (abfd, init, fini Line 3709  xcoff_generate_rtinit  (abfd, init, fini
3709    scnhdr.s_nlnno = 0;    scnhdr.s_nlnno = 0;
3710    scnhdr.s_flags = STYP_DATA;    scnhdr.s_flags = STYP_DATA;
3711    
3712    /* .data    /* .data
3713       0x0000           0x00000000 : rtl       0x0000           0x00000000 : rtl
3714       0x0004           0x00000010 : offset to init, or 0       0x0004           0x00000010 : offset to init, or 0
3715       0x0008           0x00000028 : offset to fini, or 0       0x0008           0x00000028 : offset to fini, or 0
3716       0x000C           0x0000000C : size of descriptor       0x000C           0x0000000C : size of descriptor
3717       0x0010           0x00000000 : init, needs a reloc       0x0010           0x00000000 : init, needs a reloc
3718       0x0014           0x00000040 : offset to init name       0x0014           0x00000040 : offset to init name
3719       0x0018           0x00000000 : flags, padded to a word       0x0018           0x00000000 : flags, padded to a word
3720       0x001C           0x00000000 : empty init       0x001C           0x00000000 : empty init
3721       0x0020           0x00000000 :       0x0020           0x00000000 :
3722       0x0024           0x00000000 :       0x0024           0x00000000 :
3723       0x0028           0x00000000 : fini, needs a reloc       0x0028           0x00000000 : fini, needs a reloc
3724       0x002C           0x00000??? : offset to fini name       0x002C           0x00000??? : offset to fini name
3725       0x0030           0x00000000 : flags, padded to a word       0x0030           0x00000000 : flags, padded to a word
3726       0x0034           0x00000000 : empty fini       0x0034           0x00000000 : empty fini
3727       0x0038           0x00000000 :       0x0038           0x00000000 :
3728       0x003C           0x00000000 :       0x003C           0x00000000 :
3729       0x0040           init name       0x0040           init name
3730       0x0040 + initsz  fini name */       0x0040 + initsz  fini name */
3731    
3732    data_buffer_size = 0x0040 + initsz + finisz;    data_buffer_size = 0x0040 + initsz + finisz;
3733    data_buffer_size += (data_buffer_size & 7) ? 8 - (data_buffer_size & 7) : 0;    data_buffer_size = (data_buffer_size + 7) &~ (bfd_size_type) 7;
3734    data_buffer = NULL;    data_buffer = NULL;
3735    data_buffer = (bfd_byte *) bfd_zmalloc (data_buffer_size);    data_buffer = (bfd_byte *) bfd_zmalloc (data_buffer_size);
3736    if (data_buffer == NULL)    if (data_buffer == NULL)
3737      return false;      return FALSE;
3738    
3739    if (initsz)    if (initsz)
3740      {      {
3741        val = 0x10;        val = 0x10;
3742        bfd_h_put_32 (abfd, val, &data_buffer[0x04]);        bfd_h_put_32 (abfd, val, &data_buffer[0x04]);
# Line 3728  xcoff_generate_rtinit  (abfd, init, fini Line 3745  xcoff_generate_rtinit  (abfd, init, fini
3745        memcpy (&data_buffer[val], init, initsz);        memcpy (&data_buffer[val], init, initsz);
3746      }      }
3747    
3748    if (finisz)    if (finisz)
3749      {      {
3750        val = 0x28;        val = 0x28;
3751        bfd_h_put_32 (abfd, val, &data_buffer[0x08]);        bfd_h_put_32 (abfd, val, &data_buffer[0x08]);
# Line 3744  xcoff_generate_rtinit  (abfd, init, fini Line 3761  xcoff_generate_rtinit  (abfd, init, fini
3761    
3762    /* string table */    /* string table */
3763    string_table_size = 0;    string_table_size = 0;
3764    if (initsz > 9)    if (initsz > 9)
3765      string_table_size += initsz;      string_table_size += initsz;
3766    if (finisz > 9)    if (finisz > 9)
3767      string_table_size += finisz;      string_table_size += finisz;
# Line 3753  xcoff_generate_rtinit  (abfd, init, fini Line 3770  xcoff_generate_rtinit  (abfd, init, fini
3770        string_table_size += 4;        string_table_size += 4;
3771        string_table = (bfd_byte *) bfd_zmalloc (string_table_size);        string_table = (bfd_byte *) bfd_zmalloc (string_table_size);
3772        if (string_table == NULL)        if (string_table == NULL)
3773          return false;          return FALSE;
3774    
3775        val = string_table_size;        val = string_table_size;
3776        bfd_h_put_32 (abfd, val, &string_table[0]);        bfd_h_put_32 (abfd, val, &string_table[0]);
3777        st_tmp = string_table + 4;        st_tmp = string_table + 4;
3778      }      }
3779      
3780    /* symbols    /* symbols
3781       0. .data csect       0. .data csect
3782       2. __rtinit       2. __rtinit
3783       4. init function       4. init function
3784       6. fini function       6. fini function
3785       8. __rtld  */       8. __rtld  */
3786    memset (syment_ext, 0, 10 * SYMESZ);    memset (syment_ext, 0, 10 * SYMESZ);
3787    memset (reloc_ext, 0, 3 * RELSZ);    memset (reloc_ext, 0, 3 * RELSZ);
# Line 3779  xcoff_generate_rtinit  (abfd, init, fini Line 3796  xcoff_generate_rtinit  (abfd, init, fini
3796    auxent.x_csect.x_scnlen.l = data_buffer_size;    auxent.x_csect.x_scnlen.l = data_buffer_size;
3797    auxent.x_csect.x_smtyp = 3 << 3 | XTY_SD;    auxent.x_csect.x_smtyp = 3 << 3 | XTY_SD;
3798    auxent.x_csect.x_smclas = XMC_RW;    auxent.x_csect.x_smclas = XMC_RW;
3799    bfd_coff_swap_sym_out (abfd, &syment,    bfd_coff_swap_sym_out (abfd, &syment,
3800                           &syment_ext[filehdr.f_nsyms * SYMESZ]);                           &syment_ext[filehdr.f_nsyms * SYMESZ]);
3801    bfd_coff_swap_aux_out (abfd, &auxent, syment.n_type, syment.n_sclass, 0,    bfd_coff_swap_aux_out (abfd, &auxent, syment.n_type, syment.n_sclass, 0,
3802                           syment.n_numaux,                           syment.n_numaux,
3803                           &syment_ext[(filehdr.f_nsyms + 1) * SYMESZ]);                           &syment_ext[(filehdr.f_nsyms + 1) * SYMESZ]);
3804    filehdr.f_nsyms += 2;    filehdr.f_nsyms += 2;
3805    
# Line 3795  xcoff_generate_rtinit  (abfd, init, fini Line 3812  xcoff_generate_rtinit  (abfd, init, fini
3812    syment.n_numaux = 1;    syment.n_numaux = 1;
3813    auxent.x_csect.x_smtyp = XTY_LD;    auxent.x_csect.x_smtyp = XTY_LD;
3814    auxent.x_csect.x_smclas = XMC_RW;    auxent.x_csect.x_smclas = XMC_RW;
3815    bfd_coff_swap_sym_out (abfd, &syment,    bfd_coff_swap_sym_out (abfd, &syment,
3816                           &syment_ext[filehdr.f_nsyms * SYMESZ]);                           &syment_ext[filehdr.f_nsyms * SYMESZ]);
3817    bfd_coff_swap_aux_out (abfd, &auxent, syment.n_type, syment.n_sclass, 0,    bfd_coff_swap_aux_out (abfd, &auxent, syment.n_type, syment.n_sclass, 0,
3818                           syment.n_numaux,                           syment.n_numaux,
3819                           &syment_ext[(filehdr.f_nsyms + 1) * SYMESZ]);                           &syment_ext[(filehdr.f_nsyms + 1) * SYMESZ]);
3820    filehdr.f_nsyms += 2;    filehdr.f_nsyms += 2;
3821    
3822    /* init */    /* init */
3823    if (initsz)    if (initsz)
3824      {      {
3825        memset (&syment, 0, sizeof (struct internal_syment));        memset (&syment, 0, sizeof (struct internal_syment));
3826        memset (&auxent, 0, sizeof (union internal_auxent));        memset (&auxent, 0, sizeof (union internal_auxent));
3827    
3828        if (initsz > 9)        if (initsz > 9)
3829          {          {
3830            syment._n._n_n._n_offset = st_tmp - string_table;            syment._n._n_n._n_offset = st_tmp - string_table;
3831            memcpy (st_tmp, init, initsz);            memcpy (st_tmp, init, initsz);
# Line 3819  xcoff_generate_rtinit  (abfd, init, fini Line 3836  xcoff_generate_rtinit  (abfd, init, fini
3836    
3837        syment.n_sclass = C_EXT;        syment.n_sclass = C_EXT;
3838        syment.n_numaux = 1;        syment.n_numaux = 1;
3839        bfd_coff_swap_sym_out (abfd, &syment,        bfd_coff_swap_sym_out (abfd, &syment,
3840                               &syment_ext[filehdr.f_nsyms * SYMESZ]);                               &syment_ext[filehdr.f_nsyms * SYMESZ]);
3841        bfd_coff_swap_aux_out (abfd, &auxent, syment.n_type, syment.n_sclass, 0,        bfd_coff_swap_aux_out (abfd, &auxent, syment.n_type, syment.n_sclass, 0,
3842                               syment.n_numaux,                               syment.n_numaux,
3843                               &syment_ext[(filehdr.f_nsyms + 1) * SYMESZ]);                               &syment_ext[(filehdr.f_nsyms + 1) * SYMESZ]);
3844    
3845        /* reloc */        /* reloc */
# Line 3836  xcoff_generate_rtinit  (abfd, init, fini Line 3853  xcoff_generate_rtinit  (abfd, init, fini
3853        filehdr.f_nsyms += 2;        filehdr.f_nsyms += 2;
3854        scnhdr.s_nreloc += 1;        scnhdr.s_nreloc += 1;
3855      }      }
3856      
3857    /* fini */    /* fini */
3858    if (finisz)    if (finisz)
3859      {      {
3860        memset (&syment, 0, sizeof (struct internal_syment));        memset (&syment, 0, sizeof (struct internal_syment));
3861        memset (&auxent, 0, sizeof (union internal_auxent));        memset (&auxent, 0, sizeof (union internal_auxent));
3862    
3863        if (finisz > 9)        if (finisz > 9)
3864          {          {
3865            syment._n._n_n._n_offset = st_tmp - string_table;            syment._n._n_n._n_offset = st_tmp - string_table;
3866            memcpy (st_tmp, fini, finisz);            memcpy (st_tmp, fini, finisz);
# Line 3854  xcoff_generate_rtinit  (abfd, init, fini Line 3871  xcoff_generate_rtinit  (abfd, init, fini
3871    
3872        syment.n_sclass = C_EXT;        syment.n_sclass = C_EXT;
3873        syment.n_numaux = 1;        syment.n_numaux = 1;
3874        bfd_coff_swap_sym_out (abfd, &syment,        bfd_coff_swap_sym_out (abfd, &syment,
3875                               &syment_ext[filehdr.f_nsyms * SYMESZ]);                               &syment_ext[filehdr.f_nsyms * SYMESZ]);
3876        bfd_coff_swap_aux_out (abfd, &auxent, syment.n_type, syment.n_sclass, 0,        bfd_coff_swap_aux_out (abfd, &auxent, syment.n_type, syment.n_sclass, 0,
3877                               syment.n_numaux,                               syment.n_numaux,
3878                               &syment_ext[(filehdr.f_nsyms + 1) * SYMESZ]);                               &syment_ext[(filehdr.f_nsyms + 1) * SYMESZ]);
3879    
3880        /* reloc */        /* reloc */
# Line 3866  xcoff_generate_rtinit  (abfd, init, fini Line 3883  xcoff_generate_rtinit  (abfd, init, fini
3883        reloc.r_symndx = filehdr.f_nsyms;        reloc.r_symndx = filehdr.f_nsyms;
3884        reloc.r_type = R_POS;        reloc.r_type = R_POS;
3885        reloc.r_size = 31;        reloc.r_size = 31;
3886        bfd_coff_swap_reloc_out (abfd, &reloc,        bfd_coff_swap_reloc_out (abfd, &reloc,
3887                                 &reloc_ext[scnhdr.s_nreloc * RELSZ]);                                 &reloc_ext[scnhdr.s_nreloc * RELSZ]);
3888    
3889        filehdr.f_nsyms += 2;        filehdr.f_nsyms += 2;
# Line 3880  xcoff_generate_rtinit  (abfd, init, fini Line 3897  xcoff_generate_rtinit  (abfd, init, fini
3897        memcpy (syment._n._n_name, rtld_name, strlen (rtld_name));        memcpy (syment._n._n_name, rtld_name, strlen (rtld_name));
3898        syment.n_sclass = C_EXT;        syment.n_sclass = C_EXT;
3899        syment.n_numaux = 1;        syment.n_numaux = 1;
3900        bfd_coff_swap_sym_out (abfd, &syment,        bfd_coff_swap_sym_out (abfd, &syment,
3901                               &syment_ext[filehdr.f_nsyms * SYMESZ]);                               &syment_ext[filehdr.f_nsyms * SYMESZ]);
3902        bfd_coff_swap_aux_out (abfd, &auxent, syment.n_type, syment.n_sclass, 0,        bfd_coff_swap_aux_out (abfd, &auxent, syment.n_type, syment.n_sclass, 0,
3903                               syment.n_numaux,                               syment.n_numaux,
3904                               &syment_ext[(filehdr.f_nsyms + 1) * SYMESZ]);                               &syment_ext[(filehdr.f_nsyms + 1) * SYMESZ]);
3905    
3906        /* reloc */        /* reloc */
# Line 3892  xcoff_generate_rtinit  (abfd, init, fini Line 3909  xcoff_generate_rtinit  (abfd, init, fini
3909        reloc.r_symndx = filehdr.f_nsyms;        reloc.r_symndx = filehdr.f_nsyms;
3910        reloc.r_type = R_POS;        reloc.r_type = R_POS;
3911        reloc.r_size = 31;        reloc.r_size = 31;
3912        bfd_coff_swap_reloc_out (abfd, &reloc,        bfd_coff_swap_reloc_out (abfd, &reloc,
3913                                 &reloc_ext[scnhdr.s_nreloc * RELSZ]);                                 &reloc_ext[scnhdr.s_nreloc * RELSZ]);
3914    
3915        filehdr.f_nsyms += 2;        filehdr.f_nsyms += 2;
# Line 3914  xcoff_generate_rtinit  (abfd, init, fini Line 3931  xcoff_generate_rtinit  (abfd, init, fini
3931    free (data_buffer);    free (data_buffer);
3932    data_buffer = NULL;    data_buffer = NULL;
3933    
3934    return true;    return TRUE;
3935  }  }
3936    
3937    
3938  static reloc_howto_type xcoff_dynamic_reloc =  static reloc_howto_type xcoff_dynamic_reloc =
3939  HOWTO (0,                       /* type */  HOWTO (0,                       /* type */
3940         0,                       /* rightshift */         0,                       /* rightshift */
3941         2,                       /* size (0 = byte, 1 = short, 2 = long) */         2,                       /* size (0 = byte, 1 = short, 2 = long) */
3942         32,                      /* bitsize */         32,                      /* bitsize */
3943         false,                   /* pc_relative */         FALSE,                   /* pc_relative */
3944         0,                       /* bitpos */         0,                       /* bitpos */
3945         complain_overflow_bitfield, /* complain_on_overflow */         complain_overflow_bitfield, /* complain_on_overflow */
3946         0,                       /* special_function */         0,                       /* special_function */
3947         "R_POS",               /* name */         "R_POS",                 /* name */
3948         true,                    /* partial_inplace */         TRUE,                    /* partial_inplace */
3949         0xffffffff,            /* src_mask */         0xffffffff,              /* src_mask */
3950         0xffffffff,            /* dst_mask */         0xffffffff,              /* dst_mask */
3951         false);                /* pcrel_offset */         FALSE);                  /* pcrel_offset */
3952    
3953  /*  glink  /*  glink
3954    
# Line 3955  static unsigned long xcoff_glink_code[9] Line 3972  static unsigned long xcoff_glink_code[9]
3972  static const struct xcoff_backend_data_rec bfd_xcoff_backend_data =  static const struct xcoff_backend_data_rec bfd_xcoff_backend_data =
3973    {    {
3974      { /* COFF backend, defined in libcoff.h.  */      { /* COFF backend, defined in libcoff.h.  */
3975        _bfd_xcoff_swap_aux_in,           /* _bfd_coff_swap_aux_in */        _bfd_xcoff_swap_aux_in,
3976        _bfd_xcoff_swap_sym_in,           /* _bfd_coff_swap_sym_in */        _bfd_xcoff_swap_sym_in,
3977        coff_swap_lineno_in,              /* _bfd_coff_swap_lineno_in */        coff_swap_lineno_in,
3978        _bfd_xcoff_swap_aux_out,          /* _bfd_swap_aux_out */        _bfd_xcoff_swap_aux_out,
3979        _bfd_xcoff_swap_sym_out,          /* _bfd_swap_sym_out */        _bfd_xcoff_swap_sym_out,
3980        coff_swap_lineno_out,             /* _bfd_swap_lineno_out */        coff_swap_lineno_out,
3981        xcoff_swap_reloc_out,             /* _bfd_swap_reloc_out */        xcoff_swap_reloc_out,
3982        coff_swap_filehdr_out,            /* _bfd_swap_filehdr_out */        coff_swap_filehdr_out,
3983        coff_swap_aouthdr_out,            /* _bfd_swap_aouthdr_out */        coff_swap_aouthdr_out,
3984        coff_swap_scnhdr_out,             /* _bfd_swap_scnhdr_out */        coff_swap_scnhdr_out,
3985        FILHSZ,                           /* _bfd_filhsz */        FILHSZ,
3986        AOUTSZ,                           /* _bfd_aoutsz */        AOUTSZ,
3987        SCNHSZ,                           /* _bfd_scnhsz */        SCNHSZ,
3988        SYMESZ,                           /* _bfd_symesz */        SYMESZ,
3989        AUXESZ,                           /* _bfd_auxesz */        AUXESZ,
3990        RELSZ,                            /* _bfd_relsz */        RELSZ,
3991        LINESZ,                           /* _bfd_linesz */        LINESZ,
3992        FILNMLEN,                         /* _bfd_filnmlen */        FILNMLEN,
3993        true,                             /* _bfd_coff_long_filenames */        TRUE,                     /* _bfd_coff_long_filenames */
3994        false,                            /* _bfd_coff_long_section_names */        FALSE,                    /* _bfd_coff_long_section_names */
3995        (3),                              /* _bfd_coff_default_section_alignment_power */        3,                        /* _bfd_coff_default_section_alignment_power */
3996        false,                            /* _bfd_coff_force_symnames_in_strings */        FALSE,                    /* _bfd_coff_force_symnames_in_strings */
3997        2,                                /* _bfd_coff_debug_string_prefix_length */        2,                        /* _bfd_coff_debug_string_prefix_length */
3998        coff_swap_filehdr_in,             /* _bfd_coff_swap_filehdr_in */        coff_swap_filehdr_in,
3999        coff_swap_aouthdr_in,             /* _bfd_swap_aouthdr_in */        coff_swap_aouthdr_in,
4000        coff_swap_scnhdr_in,              /* _bfd_swap_scnhdr_in */        coff_swap_scnhdr_in,
4001        xcoff_swap_reloc_in,              /* _bfd_reloc_in */        xcoff_swap_reloc_in,
4002        coff_bad_format_hook,             /* _bfd_bad_format_hook */        coff_bad_format_hook,
4003        coff_set_arch_mach_hook,          /* _bfd_set_arch_mach_hook */        coff_set_arch_mach_hook,
4004        coff_mkobject_hook,               /* _bfd_mkobject_hook */        coff_mkobject_hook,
4005        styp_to_sec_flags,                /* _bfd_syp_to_sec_flags */        styp_to_sec_flags,
4006        coff_set_alignment_hook,          /* _bfd_set_alignment_hook */        coff_set_alignment_hook,
4007        coff_slurp_symbol_table,          /* _bfd_coff_slurp_symbol_table */        coff_slurp_symbol_table,
4008        symname_in_debug_hook,            /* _coff_symname_in_debug_hook */        symname_in_debug_hook,
4009        coff_pointerize_aux_hook,         /* _bfd_coff_pointerize_aux_hook */        coff_pointerize_aux_hook,
4010        coff_print_aux,                   /* bfd_coff_print_aux */        coff_print_aux,
4011        dummy_reloc16_extra_cases,        /* _bfd_coff_reloc16_extra_cases */        dummy_reloc16_extra_cases,
4012        dummy_reloc16_estimate,           /* _bfd_coff_reloc16_estimate */        dummy_reloc16_estimate,
4013        NULL,                             /* bfd_coff_sym_is_global */        NULL,                     /* bfd_coff_sym_is_global */
4014        coff_compute_section_file_positions, /* _bfd_coff_compute_section_file_positions */        coff_compute_section_file_positions,
4015        NULL,                             /* _bfd_coff_start_final_link */        NULL,                     /* _bfd_coff_start_final_link */
4016        xcoff_ppc_relocate_section,       /* _bfd_coff_relocate_section */        xcoff_ppc_relocate_section,
4017        coff_rtype_to_howto,              /* _bfd_coff_rtype_to_howto */        coff_rtype_to_howto,
4018        NULL,                             /* _bfd_coff_addust_symndx */        NULL,                     /* _bfd_coff_adjust_symndx */
4019        _bfd_generic_link_add_one_symbol, /* _bfd_coff_add_one_symbol */        _bfd_generic_link_add_one_symbol,
4020        coff_link_output_has_begun,       /* _bfd_coff_link_output_has_begun */        coff_link_output_has_begun,
4021        coff_final_link_postscript        /* _bfd_coff_final_link_postscript */        coff_final_link_postscript
4022      },      },
4023    
4024      0x01DF,                             /* magic number */      0x01DF,                     /* magic number */
4025      bfd_arch_rs6000,                    /* architecture */      bfd_arch_rs6000,
4026      bfd_mach_rs6k,                      /* machine */      bfd_mach_rs6k,
4027    
4028      /* Function pointers to xcoff specific swap routines.  */      /* Function pointers to xcoff specific swap routines.  */
4029      xcoff_swap_ldhdr_in,                /* _xcoff_swap_ldhdr_in */      xcoff_swap_ldhdr_in,
4030      xcoff_swap_ldhdr_out,               /* _xcoff_swap_ldhdr_out */      xcoff_swap_ldhdr_out,
4031      xcoff_swap_ldsym_in,                /* _xcoff_swap_ldsym_in */      xcoff_swap_ldsym_in,
4032      xcoff_swap_ldsym_out,               /* _xcoff_swap_ldsym_out */      xcoff_swap_ldsym_out,
4033      xcoff_swap_ldrel_in,                /* _xcoff_swap_ldrel_in */      xcoff_swap_ldrel_in,
4034      xcoff_swap_ldrel_out,               /* _xcoff_swap_ldrel_out */      xcoff_swap_ldrel_out,
4035    
4036      /* Sizes.  */      /* Sizes.  */
4037      LDHDRSZ,                            /* _xcoff_ldhdrsz */      LDHDRSZ,
4038      LDSYMSZ,                            /* _xcoff_ldsymsz */      LDSYMSZ,
4039      LDRELSZ,                            /* _xcoff_ldrelsz */      LDRELSZ,
4040      12,                                 /* _xcoff_function_descriptor_size */      12,                         /* _xcoff_function_descriptor_size */
4041      SMALL_AOUTSZ,                       /* _xcoff_small_aout_header_size */      SMALL_AOUTSZ,
4042    
4043    /* Versions. */      /* Versions.  */
4044      1,                                   /* _xcoff_ldhdr_version */      1,                          /* _xcoff_ldhdr_version */
4045    
4046      _bfd_xcoff_put_symbol_name,          /* _xcoff_put_symbol_name */      _bfd_xcoff_put_symbol_name,
4047      _bfd_xcoff_put_ldsymbol_name,        /* _xcoff_put_ldsymbol_name */      _bfd_xcoff_put_ldsymbol_name,
4048      & xcoff_dynamic_reloc,               /* dynamic reloc howto */      &xcoff_dynamic_reloc,
4049      xcoff_create_csect_from_smclas,      /* _xcoff_create_csect_from_smclas */      xcoff_create_csect_from_smclas,
4050    
4051      /* Lineno and reloc count overflow.  */      /* Lineno and reloc count overflow.  */
4052      xcoff_is_lineno_count_overflow,      xcoff_is_lineno_count_overflow,
# Line 4039  static const struct xcoff_backend_data_r Line 4056  static const struct xcoff_backend_data_r
4056      xcoff_loader_reloc_offset,      xcoff_loader_reloc_offset,
4057    
4058      /* glink.  */      /* glink.  */
4059      & xcoff_glink_code[0],      &xcoff_glink_code[0],
4060      (36),           /* _xcoff_glink_size */      36,                         /* _xcoff_glink_size */
4061    
4062      /* rtinit */      /* rtinit */
4063      64,           /* _xcoff_rtinit_size */      64,                         /* _xcoff_rtinit_size */
4064      xcoff_generate_rtinit,  /* _xcoff_generate_rtinit */      xcoff_generate_rtinit,
4065  };    };
4066    
4067  /* The transfer vector that leads the outside world to all of the above.  */  /* The transfer vector that leads the outside world to all of the above.  */
4068  const bfd_target rs6000coff_vec =  const bfd_target rs6000coff_vec =
4069  {    {
4070    "aixcoff-rs6000",      "aixcoff-rs6000",
4071    bfd_target_xcoff_flavour,      bfd_target_xcoff_flavour,
4072    BFD_ENDIAN_BIG,               /* data byte order is big */      BFD_ENDIAN_BIG,             /* data byte order is big */
4073    BFD_ENDIAN_BIG,               /* header byte order is big */      BFD_ENDIAN_BIG,             /* header byte order is big */
4074    
4075    (HAS_RELOC | EXEC_P |         /* object flags */      (HAS_RELOC | EXEC_P | HAS_LINENO | HAS_DEBUG | DYNAMIC
4076     HAS_LINENO | HAS_DEBUG | DYNAMIC |       | HAS_SYMS | HAS_LOCALS | WP_TEXT),
4077     HAS_SYMS | HAS_LOCALS | WP_TEXT),  
4078        SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC | SEC_CODE | SEC_DATA,
4079    (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */      0,                          /* leading char */
4080    0,                            /* leading char */      '/',                        /* ar_pad_char */
4081    '/',                          /* ar_pad_char */      15,                         /* ar_max_namelen */
4082    15,                           /* ar_max_namelen??? FIXMEmgo */  
4083        /* data */
4084                        /* data */      bfd_getb64,
4085    bfd_getb64,         /* bfd_getx64 */      bfd_getb_signed_64,
4086    bfd_getb_signed_64, /* bfd_getx_signed_64 */      bfd_putb64,
4087    bfd_putb64,         /* bfd_putx64 */      bfd_getb32,
4088    bfd_getb32,         /* bfd_getx32 */      bfd_getb_signed_32,
4089    bfd_getb_signed_32, /* bfd_getx_signed_32 */      bfd_putb32,
4090    bfd_putb32,         /* bfd_putx32 */      bfd_getb16,
4091    bfd_getb16,         /* bfd_getx16 */      bfd_getb_signed_16,
4092    bfd_getb_signed_16, /* bfd_getx_signed_16 */      bfd_putb16,
4093    bfd_putb16,         /* bfd_putx16 */  
4094        /* hdrs */
4095                        /* hdrs */      bfd_getb64,
4096    bfd_getb64,         /* bfd_h_getx64 */      bfd_getb_signed_64,
4097    bfd_getb_signed_64, /* bfd_h_getx_signed_64 */      bfd_putb64,
4098    bfd_putb64,         /* bfd_h_putx64 */      bfd_getb32,
4099    bfd_getb32,         /* bfd_h_getx32 */      bfd_getb_signed_32,
4100    bfd_getb_signed_32, /* bfd_h_getx_signed_32 */      bfd_putb32,
4101    bfd_putb32,         /* bfd_h_putx32 */      bfd_getb16,
4102    bfd_getb16,         /* bfd_h_getx16 */      bfd_getb_signed_16,
4103    bfd_getb_signed_16, /* bfd_h_getx_signed_16 */      bfd_putb16,
4104    bfd_putb16,         /* bfd_h_putx16 */  
4105        { /* bfd_check_format */
4106    { /* bfd_check_format */        _bfd_dummy_target,
4107      _bfd_dummy_target,        coff_object_p,
4108      coff_object_p,        _bfd_xcoff_archive_p,
4109      _bfd_xcoff_archive_p,        CORE_FILE_P
4110      CORE_FILE_P      },
   },  
4111    
4112    { /* bfd_set_format */      { /* bfd_set_format */
4113      bfd_false,        bfd_false,
4114      coff_mkobject,        coff_mkobject,
4115      _bfd_generic_mkarchive,        _bfd_generic_mkarchive,
4116      bfd_false        bfd_false
4117    },      },
4118    
4119        {/* bfd_write_contents */
4120          bfd_false,
4121          coff_write_object_contents,
4122          _bfd_xcoff_write_archive_contents,
4123          bfd_false
4124        },
4125    
4126    {/* bfd_write_contents */      /* Generic */
4127        bfd_true,
4128        bfd_true,
4129        coff_new_section_hook,
4130        _bfd_generic_get_section_contents,
4131        _bfd_generic_get_section_contents_in_window,
4132    
4133        /* Copy */
4134        _bfd_xcoff_copy_private_bfd_data,
4135        ((bfd_boolean (*) (bfd *, bfd *)) bfd_true),
4136        ((bfd_boolean (*) (bfd *, asection *, bfd *, asection *)) bfd_true),
4137        ((bfd_boolean (*) (bfd *, asymbol *, bfd *, asymbol *)) bfd_true),
4138        ((bfd_boolean (*) (bfd *, bfd *)) bfd_true),
4139        ((bfd_boolean (*) (bfd *, flagword)) bfd_true),
4140        ((bfd_boolean (*) (bfd *, void * )) bfd_true),
4141    
4142        /* Core */
4143        coff_core_file_failing_command,
4144        coff_core_file_failing_signal,
4145        coff_core_file_matches_executable_p,
4146    
4147        /* Archive */
4148        _bfd_xcoff_slurp_armap,
4149      bfd_false,      bfd_false,
4150      coff_write_object_contents,      ((bfd_boolean (*) (bfd *, char **, bfd_size_type *, const char **)) bfd_false),
4151      _bfd_xcoff_write_archive_contents,      bfd_dont_truncate_arname,
4152      bfd_false      _bfd_xcoff_write_armap,
4153    },      _bfd_xcoff_read_ar_hdr,
4154        _bfd_xcoff_openr_next_archived_file,
4155    /* Generic */      _bfd_generic_get_elt_at_index,
4156    bfd_true,                          /* _close_and_cleanup */      _bfd_xcoff_stat_arch_elt,
4157    bfd_true,                          /* _bfd_free_cached_info */      bfd_true,
4158    coff_new_section_hook,             /* _new_section_hook */  
4159    _bfd_generic_get_section_contents, /* _bfd_get_section_contents */      /* Symbols */
4160                                       /* _bfd_get_section_contents_in_window */      coff_get_symtab_upper_bound,
4161    _bfd_generic_get_section_contents_in_window,      coff_canonicalize_symtab,
4162        coff_make_empty_symbol,
4163    /* Copy */      coff_print_symbol,
4164    _bfd_xcoff_copy_private_bfd_data, /* _bfd_copy_private_bfd */      coff_get_symbol_info,
4165                                      /* _bfd_merge_private_bfd_data */      _bfd_xcoff_is_local_label_name,
4166    ((boolean (*) (bfd *, bfd *)) bfd_true),      coff_bfd_is_target_special_symbol,
4167                                      /* _bfd_copy_pivate_section_data */      coff_get_lineno,
4168    ((boolean (*) (bfd *, asection *, bfd *, asection *)) bfd_true),      coff_find_nearest_line,
4169                                      /* _bfd_copy_private_symbol_data */      coff_bfd_make_debug_symbol,
4170    ((boolean (*) (bfd *, asymbol *, bfd *, asymbol *)) bfd_true),      _bfd_generic_read_minisymbols,
4171    ((boolean (*) (bfd *, flagword)) bfd_true), /* _bfd_set_private_flags */      _bfd_generic_minisymbol_to_symbol,
4172    ((boolean (*) (bfd *, void * )) bfd_true),  /* _bfd_print_private_bfd_data */  
4173        /* Reloc */
4174    /* Core */      coff_get_reloc_upper_bound,
4175    coff_core_file_failing_command,    /* _core_file_failing_command */      coff_canonicalize_reloc,
4176    coff_core_file_failing_signal,     /* _core_file_failing_signal */      _bfd_xcoff_reloc_type_lookup,
4177                                            /* _core_file_matches_executable_p */  
4178    coff_core_file_matches_executable_p,      /* Write */
4179        coff_set_arch_mach,
4180    /* Archive */      coff_set_section_contents,
4181    _bfd_xcoff_slurp_armap,                  /* _slurp_armap */  
4182                                             /* XCOFF archives do not have      /* Link */
4183                                                anything which corresponds to      _bfd_xcoff_sizeof_headers,
4184                                                an extended name table.  */      bfd_generic_get_relocated_section_contents,
4185    bfd_false,                               /* _slurp_extended_name_table */      bfd_generic_relax_section,
4186                                             /* _construct_extended_name_table */      _bfd_xcoff_bfd_link_hash_table_create,
4187    ((boolean (*) (bfd *, char **, bfd_size_type *, const char **)) bfd_false),      _bfd_generic_link_hash_table_free,
4188    bfd_dont_truncate_arname,                /* _truncate_arname */      _bfd_xcoff_bfd_link_add_symbols,
4189    _bfd_xcoff_write_armap,                  /* _write_armap */      _bfd_generic_link_just_syms,
4190    _bfd_xcoff_read_ar_hdr,                  /* _read_ar_hdr */      _bfd_xcoff_bfd_final_link,
4191    _bfd_xcoff_openr_next_archived_file,     /* _openr_next_archived_file */      _bfd_generic_link_split_section,
4192    _bfd_generic_get_elt_at_index,           /* _get_elt_at_index */      bfd_generic_gc_sections,
4193    _bfd_xcoff_stat_arch_elt,                /* _generic_stat_arch_elt */      bfd_generic_merge_sections,
4194                                             /* XCOFF archives do not have      bfd_generic_is_group_section,
4195                                                a timestamp.  */      bfd_generic_discard_group,
4196    bfd_true,                                /* _update_armap_timestamp */      _bfd_generic_section_already_linked,
4197    
4198    /* Symbols */      /* Dynamic */
4199    coff_get_symtab_upper_bound,             /* _get_symtab_upper_bound */      _bfd_xcoff_get_dynamic_symtab_upper_bound,
4200    coff_get_symtab,                         /* _get_symtab */      _bfd_xcoff_canonicalize_dynamic_symtab,
4201    coff_make_empty_symbol,                  /* _make_empty_symbol */      _bfd_nodynamic_get_synthetic_symtab,
4202    coff_print_symbol,                       /* _print_symbol */      _bfd_xcoff_get_dynamic_reloc_upper_bound,
4203    coff_get_symbol_info,                    /* _get_symbol_info */      _bfd_xcoff_canonicalize_dynamic_reloc,
   _bfd_xcoff_is_local_label_name,          /* _bfd_is_local_label_name */  
   coff_get_lineno,                         /* _get_lineno */  
   coff_find_nearest_line,                  /* _find_nearest_line */  
   coff_bfd_make_debug_symbol,              /* _bfd_make_debug_symbol */  
   _bfd_generic_read_minisymbols,           /* _read_minisymbols */  
   _bfd_generic_minisymbol_to_symbol,       /* _minsymbol_to_symbol */  
   
   /* Reloc */  
   coff_get_reloc_upper_bound,              /* _get_reloc_upper_bound */  
   coff_canonicalize_reloc,                 /* _cononicalize_reloc */  
   _bfd_xcoff_reloc_type_lookup,            /* _bfd_reloc_type_lookup */  
   
   /* Write */  
   coff_set_arch_mach,                      /* _set_arch_mach */  
   coff_set_section_contents,               /* _set_section_contents */  
   
   /* Link */  
   _bfd_xcoff_sizeof_headers,               /* _sizeof_headers */  
                                       /* _bfd_get_relocated_section_contents */  
   bfd_generic_get_relocated_section_contents,  
   bfd_generic_relax_section,               /* _bfd_relax_section */  
   _bfd_xcoff_bfd_link_hash_table_create,   /* _bfd_link_hash_table_create */  
   _bfd_generic_link_hash_table_free,       /* _bfd_link_hash_table_free */  
   _bfd_xcoff_bfd_link_add_symbols,         /* _bfd_link_add_symbols */  
   _bfd_generic_link_just_syms,             /* _bfd_link_just_syms */  
   _bfd_xcoff_bfd_final_link,               /* _bfd_final_link */  
   _bfd_generic_link_split_section,         /* _bfd_link_split_section */  
   bfd_generic_gc_sections,                 /* _bfd_gc_sections */  
   bfd_generic_merge_sections,              /* _bfd_merge_sections */  
   bfd_generic_discard_group,               /* _bfd_discard_group */  
   
   /* Dynamic */  
                                           /* _get_dynamic_symtab_upper_bound */  
   _bfd_xcoff_get_dynamic_symtab_upper_bound,  
   _bfd_xcoff_canonicalize_dynamic_symtab,  /* _cononicalize_dynamic_symtab */  
   _bfd_xcoff_get_dynamic_reloc_upper_bound,/* _get_dynamic_reloc_upper_bound */  
   _bfd_xcoff_canonicalize_dynamic_reloc,   /* _cononicalize_dynamic_reloc */  
4204    
4205    /* Opposite endian version, none exists */      /* Opposite endian version, none exists */
4206    NULL,      NULL,
4207    
4208    /* back end data */      (void *) &bfd_xcoff_backend_data,
4209    (void *) &bfd_xcoff_backend_data,    };
 };  
4210    
4211  /*  /* xcoff-powermac target
4212   * xcoff-powermac target     Old target.
4213   * Old target.     Only difference between this target and the rs6000 target is the
4214   * Only difference between this target and the rs6000 target is the     the default architecture and machine type used in coffcode.h
4215   * the default architecture and machine type used in coffcode.h  
4216   *     PowerPC Macs use the same magic numbers as RS/6000
4217   * PowerPC Macs use the same magic numbers as RS/6000     (because that's how they were bootstrapped originally),
4218   * (because that's how they were bootstrapped originally),     but they are always PowerPC architecture.  */
  * but they are always PowerPC architecture.  
  */  
4219  static const struct xcoff_backend_data_rec bfd_pmac_xcoff_backend_data =  static const struct xcoff_backend_data_rec bfd_pmac_xcoff_backend_data =
4220  {    {
4221    { /* COFF backend, defined in libcoff.h */      { /* COFF backend, defined in libcoff.h.  */
4222      _bfd_xcoff_swap_aux_in,           /* _bfd_coff_swap_aux_in */        _bfd_xcoff_swap_aux_in,
4223      _bfd_xcoff_swap_sym_in,           /* _bfd_coff_swap_sym_in */        _bfd_xcoff_swap_sym_in,
4224      coff_swap_lineno_in,              /* _bfd_coff_swap_lineno_in */        coff_swap_lineno_in,
4225      _bfd_xcoff_swap_aux_out,          /* _bfd_swap_aux_out */        _bfd_xcoff_swap_aux_out,
4226      _bfd_xcoff_swap_sym_out,          /* _bfd_swap_sym_out */        _bfd_xcoff_swap_sym_out,
4227      coff_swap_lineno_out,             /* _bfd_swap_lineno_out */        coff_swap_lineno_out,
4228      xcoff_swap_reloc_out,             /* _bfd_swap_reloc_out */        xcoff_swap_reloc_out,
4229      coff_swap_filehdr_out,            /* _bfd_swap_filehdr_out */        coff_swap_filehdr_out,
4230      coff_swap_aouthdr_out,            /* _bfd_swap_aouthdr_out */        coff_swap_aouthdr_out,
4231      coff_swap_scnhdr_out,             /* _bfd_swap_scnhdr_out */        coff_swap_scnhdr_out,
4232      FILHSZ,                           /* _bfd_filhsz */        FILHSZ,
4233      AOUTSZ,                           /* _bfd_aoutsz */        AOUTSZ,
4234      SCNHSZ,                           /* _bfd_scnhsz */        SCNHSZ,
4235      SYMESZ,                           /* _bfd_symesz */        SYMESZ,
4236      AUXESZ,                           /* _bfd_auxesz */        AUXESZ,
4237      RELSZ,                            /* _bfd_relsz */        RELSZ,
4238      LINESZ,                           /* _bfd_linesz */        LINESZ,
4239      FILNMLEN,                         /* _bfd_filnmlen */        FILNMLEN,
4240      true,                             /* _bfd_coff_long_filenames */        TRUE,                     /* _bfd_coff_long_filenames */
4241      false,                            /* _bfd_coff_long_section_names */        FALSE,                    /* _bfd_coff_long_section_names */
4242      (3),                        /* _bfd_coff_default_section_alignment_power */        3,                        /* _bfd_coff_default_section_alignment_power */
4243      false,                            /* _bfd_coff_force_symnames_in_strings */        FALSE,                    /* _bfd_coff_force_symnames_in_strings */
4244      2,                               /* _bfd_coff_debug_string_prefix_length */        2,                        /* _bfd_coff_debug_string_prefix_length */
4245      coff_swap_filehdr_in,             /* _bfd_coff_swap_filehdr_in */        coff_swap_filehdr_in,
4246      coff_swap_aouthdr_in,             /* _bfd_swap_aouthdr_in */        coff_swap_aouthdr_in,
4247      coff_swap_scnhdr_in,              /* _bfd_swap_scnhdr_in */        coff_swap_scnhdr_in,
4248      xcoff_swap_reloc_in,              /* _bfd_reloc_in */        xcoff_swap_reloc_in,
4249      coff_bad_format_hook,             /* _bfd_bad_format_hook */        coff_bad_format_hook,
4250      coff_set_arch_mach_hook,          /* _bfd_set_arch_mach_hook */        coff_set_arch_mach_hook,
4251      coff_mkobject_hook,               /* _bfd_mkobject_hook */        coff_mkobject_hook,
4252      styp_to_sec_flags,                /* _bfd_syp_to_sec_flags */        styp_to_sec_flags,
4253      coff_set_alignment_hook,          /* _bfd_set_alignment_hook */        coff_set_alignment_hook,
4254      coff_slurp_symbol_table,          /* _bfd_coff_slurp_symbol_table */        coff_slurp_symbol_table,
4255      symname_in_debug_hook,            /* _coff_symname_in_debug_hook */        symname_in_debug_hook,
4256      coff_pointerize_aux_hook,         /* _bfd_coff_pointerize_aux_hook */        coff_pointerize_aux_hook,
4257      coff_print_aux,                   /* bfd_coff_print_aux */        coff_print_aux,
4258      dummy_reloc16_extra_cases,        /* _bfd_coff_reloc16_extra_cases */        dummy_reloc16_extra_cases,
4259      dummy_reloc16_estimate,           /* _bfd_coff_reloc16_estimate */        dummy_reloc16_estimate,
4260      NULL,                             /* bfd_coff_sym_is_global */        NULL,                     /* bfd_coff_sym_is_global */
4261                                   /* _bfd_coff_compute_section_file_positions */        coff_compute_section_file_positions,
4262      coff_compute_section_file_positions,        NULL,                     /* _bfd_coff_start_final_link */
4263      NULL,                             /* _bfd_coff_start_final_link */        xcoff_ppc_relocate_section,
4264      xcoff_ppc_relocate_section,       /* _bfd_coff_relocate_section */        coff_rtype_to_howto,
4265      coff_rtype_to_howto,              /* _bfd_coff_rtype_to_howto */        NULL,                     /* _bfd_coff_adjust_symndx */
4266      NULL,                             /* _bfd_coff_addust_symndx */        _bfd_generic_link_add_one_symbol,
4267      _bfd_generic_link_add_one_symbol, /* _bfd_coff_add_one_symbol */        coff_link_output_has_begun,
4268      coff_link_output_has_begun,       /* _bfd_coff_link_output_has_begun */        coff_final_link_postscript
4269      coff_final_link_postscript        /* _bfd_coff_final_link_postscript */      },
4270    },  
4271        0x01DF,                     /* magic number */
4272    0x01DF,                             /* magic number */      bfd_arch_powerpc,
4273    bfd_arch_powerpc,                   /* architecture */      bfd_mach_ppc,
4274    bfd_mach_ppc,                       /* machine */  
4275        /* Function pointers to xcoff specific swap routines.  */
4276    /* function pointers to xcoff specific swap routines */      xcoff_swap_ldhdr_in,
4277    xcoff_swap_ldhdr_in,                /* _xcoff_swap_ldhdr_in */      xcoff_swap_ldhdr_out,
4278    xcoff_swap_ldhdr_out,               /* _xcoff_swap_ldhdr_out */      xcoff_swap_ldsym_in,
4279    xcoff_swap_ldsym_in,                /* _xcoff_swap_ldsym_in */      xcoff_swap_ldsym_out,
4280    xcoff_swap_ldsym_out,               /* _xcoff_swap_ldsym_out */      xcoff_swap_ldrel_in,
4281    xcoff_swap_ldrel_in,                /* _xcoff_swap_ldrel_in */      xcoff_swap_ldrel_out,
4282    xcoff_swap_ldrel_out,               /* _xcoff_swap_ldrel_out */  
4283        /* Sizes.  */
4284    /* sizes */      LDHDRSZ,
4285    LDHDRSZ,                            /* _xcoff_ldhdrsz */      LDSYMSZ,
4286    LDSYMSZ,                            /* _xcoff_ldsymsz */      LDRELSZ,
4287    LDRELSZ,                            /* _xcoff_ldrelsz */      12,                         /* _xcoff_function_descriptor_size */
4288    12,                                 /* _xcoff_function_descriptor_size */      SMALL_AOUTSZ,
4289    SMALL_AOUTSZ,                       /* _xcoff_small_aout_header_size */  
4290        /* Versions.  */
4291    /* versions */      1,                          /* _xcoff_ldhdr_version */
4292    1,                                    /* _xcoff_ldhdr_version */  
4293        _bfd_xcoff_put_symbol_name,
4294    /* xcoff vs xcoff64 putting symbol names */      _bfd_xcoff_put_ldsymbol_name,
4295    _bfd_xcoff_put_symbol_name,          /* _xcoff_put_symbol_name */      &xcoff_dynamic_reloc,
4296    _bfd_xcoff_put_ldsymbol_name,          /* _xcoff_put_ldsymbol_name */      xcoff_create_csect_from_smclas,
4297    
4298    &xcoff_dynamic_reloc,                  /* dynamic reloc howto */      /* Lineno and reloc count overflow.  */
4299        xcoff_is_lineno_count_overflow,
4300    xcoff_create_csect_from_smclas,      /* _xcoff_create_csect_from_smclas */      xcoff_is_reloc_count_overflow,
4301    
4302    /* lineno and reloc count overflow */      xcoff_loader_symbol_offset,
4303    xcoff_is_lineno_count_overflow,      xcoff_loader_reloc_offset,
   xcoff_is_reloc_count_overflow,  
   
   xcoff_loader_symbol_offset,  
   xcoff_loader_reloc_offset,  
   
   /* glink */  
   &xcoff_glink_code[0],  
   (36),           /* _xcoff_glink_size */  
   
   /* rtinit */  
   0,           /* _xcoff_rtinit_size */  
   xcoff_generate_rtinit,  /* _xcoff_generate_rtinit */  
 };  
4304    
4305  /* The transfer vector that leads the outside world to all of the above. */      /* glink.  */
4306        &xcoff_glink_code[0],
4307        36,                         /* _xcoff_glink_size */
4308    
4309        /* rtinit */
4310        0,                          /* _xcoff_rtinit_size */
4311        xcoff_generate_rtinit,
4312      };
4313    
4314    /* The transfer vector that leads the outside world to all of the above.  */
4315  const bfd_target pmac_xcoff_vec =  const bfd_target pmac_xcoff_vec =
4316  {    {
4317    "xcoff-powermac",      "xcoff-powermac",
4318    bfd_target_xcoff_flavour,      bfd_target_xcoff_flavour,
4319    BFD_ENDIAN_BIG,               /* data byte order is big */      BFD_ENDIAN_BIG,             /* data byte order is big */
4320    BFD_ENDIAN_BIG,               /* header byte order is big */      BFD_ENDIAN_BIG,             /* header byte order is big */
4321    
4322    (HAS_RELOC | EXEC_P |         /* object flags */      (HAS_RELOC | EXEC_P | HAS_LINENO | HAS_DEBUG | DYNAMIC
4323     HAS_LINENO | HAS_DEBUG | DYNAMIC |       | HAS_SYMS | HAS_LOCALS | WP_TEXT),
4324     HAS_SYMS | HAS_LOCALS | WP_TEXT),  
4325        SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC | SEC_CODE | SEC_DATA,
4326    (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */      0,                          /* leading char */
4327    0,                            /* leading char */      '/',                        /* ar_pad_char */
4328    '/',                          /* ar_pad_char */      15,                         /* ar_max_namelen */
4329    15,                           /* ar_max_namelen??? FIXMEmgo */  
4330        /* data */
4331                        /* data */      bfd_getb64,
4332    bfd_getb64,         /* bfd_getx64 */      bfd_getb_signed_64,
4333    bfd_getb_signed_64, /* bfd_getx_signed_64 */      bfd_putb64,
4334    bfd_putb64,         /* bfd_putx64 */      bfd_getb32,
4335    bfd_getb32,         /* bfd_getx32 */      bfd_getb_signed_32,
4336    bfd_getb_signed_32, /* bfd_getx_signed_32 */      bfd_putb32,
4337    bfd_putb32,         /* bfd_putx32 */      bfd_getb16,
4338    bfd_getb16,         /* bfd_getx16 */      bfd_getb_signed_16,
4339    bfd_getb_signed_16, /* bfd_getx_signed_16 */      bfd_putb16,
4340    bfd_putb16,         /* bfd_putx16 */  
4341        /* hdrs */
4342                        /* hdrs */      bfd_getb64,
4343    bfd_getb64,         /* bfd_h_getx64 */      bfd_getb_signed_64,
4344    bfd_getb_signed_64, /* bfd_h_getx_signed_64 */      bfd_putb64,
4345    bfd_putb64,         /* bfd_h_putx64 */      bfd_getb32,
4346    bfd_getb32,         /* bfd_h_getx32 */      bfd_getb_signed_32,
4347    bfd_getb_signed_32, /* bfd_h_getx_signed_32 */      bfd_putb32,
4348    bfd_putb32,         /* bfd_h_putx32 */      bfd_getb16,
4349    bfd_getb16,         /* bfd_h_getx16 */      bfd_getb_signed_16,
4350    bfd_getb_signed_16, /* bfd_h_getx_signed_16 */      bfd_putb16,
4351    bfd_putb16,         /* bfd_h_putx16 */  
4352        { /* bfd_check_format */
4353    { /* bfd_check_format */        _bfd_dummy_target,
4354      _bfd_dummy_target,        coff_object_p,
4355      coff_object_p,        _bfd_xcoff_archive_p,
4356      _bfd_xcoff_archive_p,        CORE_FILE_P
4357      CORE_FILE_P      },
   },  
4358    
4359    { /* bfd_set_format */      { /* bfd_set_format */
4360      bfd_false,        bfd_false,
4361      coff_mkobject,        coff_mkobject,
4362      _bfd_generic_mkarchive,        _bfd_generic_mkarchive,
4363      bfd_false        bfd_false
4364    },      },
4365    
4366    {/* bfd_write_contents */      {/* bfd_write_contents */
4367          bfd_false,
4368          coff_write_object_contents,
4369          _bfd_xcoff_write_archive_contents,
4370          bfd_false
4371        },
4372    
4373        /* Generic */
4374        bfd_true,
4375        bfd_true,
4376        coff_new_section_hook,
4377        _bfd_generic_get_section_contents,
4378        _bfd_generic_get_section_contents_in_window,
4379    
4380        /* Copy */
4381        _bfd_xcoff_copy_private_bfd_data,
4382        ((bfd_boolean (*) (bfd *, bfd *)) bfd_true),
4383        ((bfd_boolean (*) (bfd *, asection *, bfd *, asection *)) bfd_true),
4384        ((bfd_boolean (*) (bfd *, asymbol *, bfd *, asymbol *)) bfd_true),
4385        ((bfd_boolean (*) (bfd *, bfd *)) bfd_true),
4386        ((bfd_boolean (*) (bfd *, flagword)) bfd_true),
4387        ((bfd_boolean (*) (bfd *, void * )) bfd_true),
4388    
4389        /* Core */
4390        coff_core_file_failing_command,
4391        coff_core_file_failing_signal,
4392        coff_core_file_matches_executable_p,
4393    
4394        /* Archive */
4395        _bfd_xcoff_slurp_armap,
4396      bfd_false,      bfd_false,
4397      coff_write_object_contents,      ((bfd_boolean (*) (bfd *, char **, bfd_size_type *, const char **)) bfd_false),
4398      _bfd_xcoff_write_archive_contents,      bfd_dont_truncate_arname,
4399      bfd_false      _bfd_xcoff_write_armap,
4400    },      _bfd_xcoff_read_ar_hdr,
4401        _bfd_xcoff_openr_next_archived_file,
4402    /* Generic */      _bfd_generic_get_elt_at_index,
4403    bfd_true,                          /* _close_and_cleanup */      _bfd_xcoff_stat_arch_elt,
4404    bfd_true,                          /* _bfd_free_cached_info */      bfd_true,
4405    coff_new_section_hook,             /* _new_section_hook */  
4406    _bfd_generic_get_section_contents, /* _bfd_get_section_contents */      /* Symbols */
4407                                       /* _bfd_get_section_contents_in_window */      coff_get_symtab_upper_bound,
4408    _bfd_generic_get_section_contents_in_window,      coff_canonicalize_symtab,
4409        coff_make_empty_symbol,
4410    /* Copy */      coff_print_symbol,
4411    _bfd_xcoff_copy_private_bfd_data, /* _bfd_copy_private_bfd */      coff_get_symbol_info,
4412                                      /* _bfd_merge_private_bfd_data */      _bfd_xcoff_is_local_label_name,
4413    ((boolean (*) (bfd *, bfd *)) bfd_true),      coff_bfd_is_target_special_symbol,
4414                                      /* _bfd_copy_pivate_section_data */      coff_get_lineno,
4415    ((boolean (*) (bfd *, asection *, bfd *, asection *)) bfd_true),      coff_find_nearest_line,
4416                                      /* _bfd_copy_private_symbol_data */      coff_bfd_make_debug_symbol,
4417    ((boolean (*) (bfd *, asymbol *, bfd *, asymbol *)) bfd_true),      _bfd_generic_read_minisymbols,
4418    ((boolean (*) (bfd *, flagword)) bfd_true), /* _bfd_set_private_flags */      _bfd_generic_minisymbol_to_symbol,
4419    ((boolean (*) (bfd *, void * )) bfd_true),  /* _bfd_print_private_bfd_data */  
4420        /* Reloc */
4421    /* Core */      coff_get_reloc_upper_bound,
4422    coff_core_file_failing_command,    /* _core_file_failing_command */      coff_canonicalize_reloc,
4423    coff_core_file_failing_signal,     /* _core_file_failing_signal */      _bfd_xcoff_reloc_type_lookup,
4424                                            /* _core_file_matches_executable_p */  
4425    coff_core_file_matches_executable_p,      /* Write */
4426        coff_set_arch_mach,
4427    /* Archive */      coff_set_section_contents,
4428    _bfd_xcoff_slurp_armap,                  /* _slurp_armap */  
4429                                             /* XCOFF archives do not have      /* Link */
4430                                                anything which corresponds to      _bfd_xcoff_sizeof_headers,
4431                                                an extended name table.  */      bfd_generic_get_relocated_section_contents,
4432    bfd_false,                               /* _slurp_extended_name_table */      bfd_generic_relax_section,
4433                                             /* _construct_extended_name_table */      _bfd_xcoff_bfd_link_hash_table_create,
4434    ((boolean (*) (bfd *, char **, bfd_size_type *, const char **)) bfd_false),      _bfd_generic_link_hash_table_free,
4435    bfd_dont_truncate_arname,                /* _truncate_arname */      _bfd_xcoff_bfd_link_add_symbols,
4436    _bfd_xcoff_write_armap,                  /* _write_armap */      _bfd_generic_link_just_syms,
4437    _bfd_xcoff_read_ar_hdr,                  /* _read_ar_hdr */      _bfd_xcoff_bfd_final_link,
4438    _bfd_xcoff_openr_next_archived_file,     /* _openr_next_archived_file */      _bfd_generic_link_split_section,
4439    _bfd_generic_get_elt_at_index,           /* _get_elt_at_index */      bfd_generic_gc_sections,
4440    _bfd_xcoff_stat_arch_elt,                /* _generic_stat_arch_elt */      bfd_generic_merge_sections,
4441                                             /* XCOFF archives do not have      bfd_generic_is_group_section,
4442                                                a timestamp.  */      bfd_generic_discard_group,
4443    bfd_true,                                /* _update_armap_timestamp */      _bfd_generic_section_already_linked,
4444    
4445    /* Symbols */      /* Dynamic */
4446    coff_get_symtab_upper_bound,             /* _get_symtab_upper_bound */      _bfd_xcoff_get_dynamic_symtab_upper_bound,
4447    coff_get_symtab,                         /* _get_symtab */      _bfd_xcoff_canonicalize_dynamic_symtab,
4448    coff_make_empty_symbol,                  /* _make_empty_symbol */      _bfd_nodynamic_get_synthetic_symtab,
4449    coff_print_symbol,                       /* _print_symbol */      _bfd_xcoff_get_dynamic_reloc_upper_bound,
4450    coff_get_symbol_info,                    /* _get_symbol_info */      _bfd_xcoff_canonicalize_dynamic_reloc,
   _bfd_xcoff_is_local_label_name,          /* _bfd_is_local_label_name */  
   coff_get_lineno,                         /* _get_lineno */  
   coff_find_nearest_line,                  /* _find_nearest_line */  
   coff_bfd_make_debug_symbol,              /* _bfd_make_debug_symbol */  
   _bfd_generic_read_minisymbols,           /* _read_minisymbols */  
   _bfd_generic_minisymbol_to_symbol,       /* _minsymbol_to_symbol */  
   
   /* Reloc */  
   coff_get_reloc_upper_bound,              /* _get_reloc_upper_bound */  
   coff_canonicalize_reloc,                 /* _cononicalize_reloc */  
   _bfd_xcoff_reloc_type_lookup,            /* _bfd_reloc_type_lookup */  
   
   /* Write */  
   coff_set_arch_mach,                      /* _set_arch_mach */  
   coff_set_section_contents,               /* _set_section_contents */  
   
   /* Link */  
   _bfd_xcoff_sizeof_headers,               /* _sizeof_headers */  
                                       /* _bfd_get_relocated_section_contents */  
   bfd_generic_get_relocated_section_contents,  
   bfd_generic_relax_section,               /* _bfd_relax_section */  
   _bfd_xcoff_bfd_link_hash_table_create,   /* _bfd_link_hash_table_create */  
   _bfd_generic_link_hash_table_free,       /* _bfd_link_hash_table_free */  
   _bfd_xcoff_bfd_link_add_symbols,         /* _bfd_link_add_symbols */  
   _bfd_generic_link_just_syms,             /* _bfd_link_just_syms */  
   _bfd_xcoff_bfd_final_link,               /* _bfd_final_link */  
   _bfd_generic_link_split_section,         /* _bfd_link_split_section */  
   bfd_generic_gc_sections,                 /* _bfd_gc_sections */  
   bfd_generic_merge_sections,              /* _bfd_merge_sections */  
   bfd_generic_discard_group,               /* _bfd_discard_group */  
   
   /* Dynamic */  
                                           /* _get_dynamic_symtab_upper_bound */  
   _bfd_xcoff_get_dynamic_symtab_upper_bound,  
   _bfd_xcoff_canonicalize_dynamic_symtab,  /* _cononicalize_dynamic_symtab */  
   _bfd_xcoff_get_dynamic_reloc_upper_bound,/* _get_dynamic_reloc_upper_bound */  
   _bfd_xcoff_canonicalize_dynamic_reloc,   /* _cononicalize_dynamic_reloc */  
4451    
4452    /* Opposite endian version, none exists */      /* Opposite endian version, none exists */
4453    NULL,      NULL,
4454    
4455    /* back end data */      (void *) &bfd_pmac_xcoff_backend_data,
4456    (void *) &bfd_pmac_xcoff_backend_data,    };
 };  

Legend:
Removed from v.1.1.1.1  
changed lines
  Added in v.1.1.1.1.20.1

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26