X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=bfd%2Fcoff-rs6000.c;h=17c6907a3c56cc62b4667997109780e9df5e392b;hb=6bba1048d63e0476b94b9934527defd81c590a13;hp=8ba305c7740be73e87dfcaff242d2e4660eb80dd;hpb=1049f94e8e1a9eae86a694d2dca94a6194f763b1;p=deliverable%2Fbinutils-gdb.git diff --git a/bfd/coff-rs6000.c b/bfd/coff-rs6000.c index 8ba305c774..17c6907a3c 100644 --- a/bfd/coff-rs6000.c +++ b/bfd/coff-rs6000.c @@ -1,33 +1,29 @@ /* BFD back-end for IBM RS/6000 "XCOFF" files. - Copyright 1990-1999, 2000, 2001, 2002, 2003 - Free Software Foundation, Inc. - FIXME: Can someone provide a transliteration of this name into ASCII? - Using the following chars caused a compiler warning on HIUX (so I replaced - them with octal escapes), and isn't useful without an understanding of what - character set it is. - Written by Metin G. Ozisik, Mimi Ph\373\364ng-Th\345o V\365, - and John Gilmore. + Copyright 1990-1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, + 2008 Free Software Foundation, Inc. + Written by Metin G. Ozisik, Mimi Phuong-Thao Vo, and John Gilmore. Archive support from Damon A. Permezel. Contributed by IBM Corporation and Cygnus Support. -This file is part of BFD, the Binary File Descriptor library. + This file is part of BFD, the Binary File Descriptor library. -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, + MA 02110-1301, USA. */ -#include "bfd.h" #include "sysdep.h" +#include "bfd.h" #include "bfdlink.h" #include "libbfd.h" #include "coff/internal.h" @@ -59,7 +55,7 @@ extern bfd_boolean _bfd_xcoff_write_armap extern bfd_boolean _bfd_xcoff_write_archive_contents PARAMS ((bfd *)); extern int _bfd_xcoff_sizeof_headers - PARAMS ((bfd *, bfd_boolean)); + PARAMS ((bfd *, struct bfd_link_info *)); extern void _bfd_xcoff_swap_sym_in PARAMS ((bfd *, PTR, PTR)); extern unsigned int _bfd_xcoff_swap_sym_out @@ -98,6 +94,7 @@ void xcoff_rtype2howto #define coff_bfd_copy_private_bfd_data _bfd_xcoff_copy_private_bfd_data #define coff_bfd_is_local_label_name _bfd_xcoff_is_local_label_name #define coff_bfd_reloc_type_lookup _bfd_xcoff_reloc_type_lookup +#define coff_bfd_reloc_name_lookup _bfd_xcoff_reloc_name_lookup #ifdef AIX_CORE extern const bfd_target * rs6000coff_core_p PARAMS ((bfd *abfd)); @@ -131,6 +128,10 @@ extern int rs6000coff_core_file_failing_signal #define coff_swap_reloc_out xcoff_swap_reloc_out #define NO_COFF_RELOCS +#ifndef bfd_pe_print_pdata +#define bfd_pe_print_pdata NULL +#endif + #include "coffcode.h" /* The main body of code is in coffcode.h. */ @@ -180,7 +181,7 @@ static bfd_boolean do_pad static bfd_boolean do_copy PARAMS ((bfd *, bfd *)); static bfd_boolean do_shared_object_padding - PARAMS ((bfd *, bfd *, ufile_ptr *, int)); + PARAMS ((bfd *, bfd *, file_ptr *, int)); /* Relocation functions */ static bfd_boolean xcoff_reloc_type_br @@ -1006,7 +1007,7 @@ xcoff_rtype2howto (relent, internal) /* Default howto layout works most of the time */ relent->howto = &xcoff_howto_table[internal->r_type]; - /* Special case some 16 bit reoloc */ + /* Special case some 16 bit reloc */ if (15 == (internal->r_size & 0x1f)) { if (R_BA == internal->r_type) @@ -1051,6 +1052,21 @@ _bfd_xcoff_reloc_type_lookup (abfd, code) } } +static reloc_howto_type * +_bfd_xcoff_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED, + const char *r_name) +{ + unsigned int i; + + for (i = 0; + i < sizeof (xcoff_howto_table) / sizeof (xcoff_howto_table[0]); + i++) + if (xcoff_howto_table[i].name != NULL + && strcasecmp (xcoff_howto_table[i].name, r_name) == 0) + return &xcoff_howto_table[i]; + + return NULL; +} /* XCOFF archive support. The original version of this code was by Damon A. Permezel. It was enhanced to permit cross support, and @@ -1294,10 +1310,12 @@ _bfd_xcoff_archive_p (abfd) if (bfd_ardata (abfd) == (struct artdata *) NULL) goto error_ret_restore; - bfd_ardata (abfd)->cache = NULL; - bfd_ardata (abfd)->archive_head = NULL; - bfd_ardata (abfd)->symdefs = NULL; - bfd_ardata (abfd)->extended_names = NULL; + /* Cleared by bfd_zalloc above. + bfd_ardata (abfd)->cache = NULL; + bfd_ardata (abfd)->archive_head = NULL; + bfd_ardata (abfd)->symdefs = NULL; + bfd_ardata (abfd)->extended_names = NULL; + bfd_ardata (abfd)->extended_names_size = 0; */ /* Now handle the two formats. */ if (magic[1] != 'b') @@ -1575,7 +1593,6 @@ normalize_filename (abfd) /* Write out an XCOFF armap. */ -/*ARGSUSED*/ static bfd_boolean xcoff_write_armap_old (abfd, elength, map, orl_count, stridx) bfd *abfd; @@ -1637,7 +1654,7 @@ xcoff_write_armap_old (abfd, elength, map, orl_count, stridx) + SXCOFFARFMAG + arelt_size (sub)); fileoff = (fileoff + 1) &~ 1; - sub = sub->next; + sub = sub->archive_next; } for (i = 0; i < orl_count; i++) @@ -1743,7 +1760,7 @@ static bfd_boolean do_shared_object_padding (out_bfd, in_bfd, offset, ar_header_size) bfd *out_bfd; bfd *in_bfd; - ufile_ptr *offset; + file_ptr *offset; int ar_header_size; { if (bfd_check_format (in_bfd, bfd_object) @@ -1780,7 +1797,7 @@ xcoff_write_armap_big (abfd, elength, map, orl_count, stridx) const bfd_arch_info_type *arch_info = NULL; bfd *current_bfd; size_t string_length; - ufile_ptr nextoff, prevoff; + file_ptr nextoff, prevoff; /* First, we look through the symbols and work out which are from 32-bit objects and which from 64-bit ones. */ @@ -1808,7 +1825,7 @@ xcoff_write_armap_big (abfd, elength, map, orl_count, stridx) } i++; } - current_bfd = current_bfd->next; + current_bfd = current_bfd->archive_next; if (current_bfd != NULL) arch_info = bfd_get_arch_info (current_bfd); } @@ -1850,8 +1867,8 @@ xcoff_write_armap_big (abfd, elength, map, orl_count, stridx) if (sym_32) { struct xcoff_ar_hdr_big *hdr; - bfd_byte *symbol_table; - bfd_byte *st; + char *symbol_table; + char *st; file_ptr fileoff; bfd_vma symbol_table_size = @@ -1861,8 +1878,7 @@ xcoff_write_armap_big (abfd, elength, map, orl_count, stridx) + 8 * sym_32 + str_32 + (str_32 & 1); - symbol_table = NULL; - symbol_table = (bfd_byte *) bfd_zmalloc (symbol_table_size); + symbol_table = bfd_zmalloc (symbol_table_size); if (symbol_table == NULL) return FALSE; @@ -1913,7 +1929,7 @@ xcoff_write_armap_big (abfd, elength, map, orl_count, stridx) + SXCOFFARFMAG + arelt_size (current_bfd)); fileoff += fileoff & 1; - current_bfd = current_bfd->next; + current_bfd = current_bfd->archive_next; if (current_bfd != NULL) arch_info = bfd_get_arch_info (current_bfd); } @@ -1934,7 +1950,7 @@ xcoff_write_armap_big (abfd, elength, map, orl_count, stridx) } i++; } - current_bfd = current_bfd->next; + current_bfd = current_bfd->archive_next; if (current_bfd != NULL) arch_info = bfd_get_arch_info (current_bfd); } @@ -1942,7 +1958,6 @@ xcoff_write_armap_big (abfd, elength, map, orl_count, stridx) bfd_bwrite (symbol_table, symbol_table_size, abfd); free (symbol_table); - symbol_table = NULL; prevoff = nextoff; nextoff = nextoff + symbol_table_size; @@ -1953,8 +1968,8 @@ xcoff_write_armap_big (abfd, elength, map, orl_count, stridx) if (sym_64) { struct xcoff_ar_hdr_big *hdr; - bfd_byte *symbol_table; - bfd_byte *st; + char *symbol_table; + char *st; file_ptr fileoff; bfd_vma symbol_table_size = @@ -1964,8 +1979,7 @@ xcoff_write_armap_big (abfd, elength, map, orl_count, stridx) + 8 * sym_64 + str_64 + (str_64 & 1); - symbol_table = NULL; - symbol_table = (bfd_byte *) bfd_zmalloc (symbol_table_size); + symbol_table = bfd_zmalloc (symbol_table_size); if (symbol_table == NULL) return FALSE; @@ -2011,7 +2025,7 @@ xcoff_write_armap_big (abfd, elength, map, orl_count, stridx) + SXCOFFARFMAG + arelt_size (current_bfd)); fileoff += fileoff & 1; - current_bfd = current_bfd->next; + current_bfd = current_bfd->archive_next; if (current_bfd != NULL) arch_info = bfd_get_arch_info (current_bfd); } @@ -2032,7 +2046,7 @@ xcoff_write_armap_big (abfd, elength, map, orl_count, stridx) } i++; } - current_bfd = current_bfd->next; + current_bfd = current_bfd->archive_next; if (current_bfd != NULL) arch_info = bfd_get_arch_info (current_bfd); } @@ -2040,7 +2054,6 @@ xcoff_write_armap_big (abfd, elength, map, orl_count, stridx) bfd_bwrite (symbol_table, symbol_table_size, abfd); free (symbol_table); - symbol_table = NULL; PRINT20 (fhdr->symoff64, nextoff); } @@ -2077,7 +2090,7 @@ xcoff_write_archive_contents_old (abfd) file_ptr *offsets; bfd_boolean makemap; bfd_boolean hasobjects; - ufile_ptr prevoff, nextoff; + file_ptr prevoff, nextoff; bfd *sub; size_t i; struct xcoff_ar_hdr ahdr; @@ -2086,13 +2099,13 @@ xcoff_write_archive_contents_old (abfd) char decbuf[XCOFFARMAG_ELEMENT_SIZE + 1]; memset (&fhdr, 0, sizeof fhdr); - strncpy (fhdr.magic, XCOFFARMAG, SXCOFFARMAG); + (void) strncpy (fhdr.magic, XCOFFARMAG, SXCOFFARMAG); sprintf (fhdr.firstmemoff, "%d", SIZEOF_AR_FILE_HDR); sprintf (fhdr.freeoff, "%d", 0); count = 0; total_namlen = 0; - for (sub = abfd->archive_head; sub != NULL; sub = sub->next) + for (sub = abfd->archive_head; sub != NULL; sub = sub->archive_next) { ++count; total_namlen += strlen (normalize_filename (sub)) + 1; @@ -2108,7 +2121,9 @@ xcoff_write_archive_contents_old (abfd) hasobjects = FALSE; prevoff = 0; nextoff = SIZEOF_AR_FILE_HDR; - for (sub = abfd->archive_head, i = 0; sub != NULL; sub = sub->next, i++) + for (sub = abfd->archive_head, i = 0; + sub != NULL; + sub = sub->archive_next, i++) { const char *name; bfd_size_type namlen; @@ -2256,7 +2271,7 @@ xcoff_write_archive_contents_old (abfd) abfd) != XCOFFARMAG_ELEMENT_SIZE) return FALSE; } - for (sub = abfd->archive_head; sub != NULL; sub = sub->next) + for (sub = abfd->archive_head; sub != NULL; sub = sub->archive_next) { const char *name; bfd_size_type namlen; @@ -2307,12 +2322,12 @@ xcoff_write_archive_contents_big (abfd) file_ptr *offsets; bfd_boolean makemap; bfd_boolean hasobjects; - ufile_ptr prevoff, nextoff; + file_ptr prevoff, nextoff; bfd *current_bfd; size_t i; struct xcoff_ar_hdr_big *hdr, ahdr; bfd_size_type size; - bfd_byte *member_table, *mt; + char *member_table, *mt; bfd_vma member_table_size; memset (&fhdr, 0, SIZEOF_AR_FILE_HDR_BIG); @@ -2326,7 +2341,7 @@ xcoff_write_archive_contents_big (abfd) hasobjects = FALSE; for (current_bfd = abfd->archive_head, count = 0, total_namlen = 0; current_bfd != NULL; - current_bfd = current_bfd->next, count++) + current_bfd = current_bfd->archive_next, count++) { total_namlen += strlen (normalize_filename (current_bfd)) + 1; @@ -2348,7 +2363,7 @@ xcoff_write_archive_contents_big (abfd) nextoff = SIZEOF_AR_FILE_HDR_BIG; for (current_bfd = abfd->archive_head, i = 0; current_bfd != NULL; - current_bfd = current_bfd->next, i++) + current_bfd = current_bfd->archive_next, i++) { const char *name; bfd_size_type namlen; @@ -2477,8 +2492,7 @@ xcoff_write_archive_contents_big (abfd) + total_namlen); member_table_size += member_table_size & 1; - member_table = NULL; - member_table = (bfd_byte *) bfd_zmalloc (member_table_size); + member_table = bfd_zmalloc (member_table_size); if (member_table == NULL) return FALSE; @@ -2516,8 +2530,9 @@ xcoff_write_archive_contents_big (abfd) offsets = NULL; } - for (current_bfd = abfd->archive_head; current_bfd != NULL; - current_bfd = current_bfd->next) + for (current_bfd = abfd->archive_head; + current_bfd != NULL; + current_bfd = current_bfd->archive_next) { const char *name; size_t namlen; @@ -2531,7 +2546,6 @@ xcoff_write_archive_contents_big (abfd) return FALSE; free (member_table); - member_table = NULL; PRINT20 (fhdr.memoff, nextoff); @@ -2578,9 +2592,8 @@ _bfd_xcoff_write_archive_contents (abfd) always uses an a.out header. */ int -_bfd_xcoff_sizeof_headers (abfd, reloc) - bfd *abfd; - bfd_boolean reloc ATTRIBUTE_UNUSED; +_bfd_xcoff_sizeof_headers (bfd *abfd, + struct bfd_link_info *info ATTRIBUTE_UNUSED) { int size; @@ -2949,8 +2962,7 @@ xcoff_reloc_type_br (input_bfd, input_section, output_bfd, rel, sym, howto, cror. */ if (NULL != h && bfd_link_hash_defined == h->root.type - && (rel->r_vaddr - input_section->vma + 8 - <= input_section->_cooked_size)) + && rel->r_vaddr - input_section->vma + 8 <= input_section->size) { bfd_byte *pnext; unsigned long next; @@ -3450,7 +3462,7 @@ xcoff_ppc_relocate_section (output_bfd, info, input_bfd, address = rel->r_vaddr - input_section->vma; location = contents + address; - if (address > input_section->_raw_size) + if (address > input_section->size) abort (); /* Get the value we are going to relocate. */ @@ -3483,7 +3495,7 @@ xcoff_ppc_relocate_section (output_bfd, info, input_bfd, } else if (h != NULL) { - name = h->root.root.string; + name = NULL; } else { @@ -3494,8 +3506,9 @@ xcoff_ppc_relocate_section (output_bfd, info, input_bfd, sprintf (reloc_type_name, "0x%02x", rel->r_type); if (! ((*info->callbacks->reloc_overflow) - (info, name, reloc_type_name, (bfd_vma) 0, input_bfd, - input_section, rel->r_vaddr - input_section->vma))) + (info, (h ? &h->root : NULL), name, reloc_type_name, + (bfd_vma) 0, input_bfd, input_section, + rel->r_vaddr - input_section->vma))) return FALSE; } @@ -3531,7 +3544,7 @@ _bfd_xcoff_put_ldsymbol_name (abfd, ldinfo, ldsym, name) if (ldinfo->string_size + len + 3 > ldinfo->string_alc) { bfd_size_type newalc; - bfd_byte *newstrings; + char *newstrings; newalc = ldinfo->string_alc * 2; if (newalc == 0) @@ -3539,8 +3552,7 @@ _bfd_xcoff_put_ldsymbol_name (abfd, ldinfo, ldsym, name) while (ldinfo->string_size + len + 3 > newalc) newalc *= 2; - newstrings = ((bfd_byte *) - bfd_realloc ((PTR) ldinfo->strings, newalc)); + newstrings = bfd_realloc (ldinfo->strings, newalc); if (newstrings == NULL) { ldinfo->failed = TRUE; @@ -3613,8 +3625,8 @@ xcoff_create_csect_from_smclas (abfd, aux, symbol_name) else { (*_bfd_error_handler) - (_("%s: symbol `%s' has unrecognized smclas %d"), - bfd_archive_filename (abfd), symbol_name, aux->x_csect.x_smclas); + (_("%B: symbol `%s' has unrecognized smclas %d"), + abfd, symbol_name, aux->x_csect.x_smclas); bfd_set_error (bfd_error_bad_value); } @@ -4026,7 +4038,8 @@ static const struct xcoff_backend_data_rec bfd_xcoff_backend_data = NULL, /* _bfd_coff_adjust_symndx */ _bfd_generic_link_add_one_symbol, coff_link_output_has_begun, - coff_final_link_postscript + coff_final_link_postscript, + NULL /* print_pdata. */ }, 0x01DF, /* magic number */ @@ -4141,8 +4154,10 @@ const bfd_target rs6000coff_vec = /* Copy */ _bfd_xcoff_copy_private_bfd_data, ((bfd_boolean (*) (bfd *, bfd *)) bfd_true), + _bfd_generic_init_private_section_data, ((bfd_boolean (*) (bfd *, asection *, bfd *, asection *)) bfd_true), ((bfd_boolean (*) (bfd *, asymbol *, bfd *, asymbol *)) bfd_true), + ((bfd_boolean (*) (bfd *, bfd *)) bfd_true), ((bfd_boolean (*) (bfd *, flagword)) bfd_true), ((bfd_boolean (*) (bfd *, void * )) bfd_true), @@ -4165,13 +4180,16 @@ const bfd_target rs6000coff_vec = /* Symbols */ coff_get_symtab_upper_bound, - coff_get_symtab, + coff_canonicalize_symtab, coff_make_empty_symbol, coff_print_symbol, coff_get_symbol_info, _bfd_xcoff_is_local_label_name, + coff_bfd_is_target_special_symbol, coff_get_lineno, coff_find_nearest_line, + _bfd_generic_find_line, + coff_find_inliner_info, coff_bfd_make_debug_symbol, _bfd_generic_read_minisymbols, _bfd_generic_minisymbol_to_symbol, @@ -4180,6 +4198,7 @@ const bfd_target rs6000coff_vec = coff_get_reloc_upper_bound, coff_canonicalize_reloc, _bfd_xcoff_reloc_type_lookup, + _bfd_xcoff_reloc_name_lookup, /* Write */ coff_set_arch_mach, @@ -4197,11 +4216,14 @@ const bfd_target rs6000coff_vec = _bfd_generic_link_split_section, bfd_generic_gc_sections, bfd_generic_merge_sections, + bfd_generic_is_group_section, bfd_generic_discard_group, + _bfd_generic_section_already_linked, /* Dynamic */ _bfd_xcoff_get_dynamic_symtab_upper_bound, _bfd_xcoff_canonicalize_dynamic_symtab, + _bfd_nodynamic_get_synthetic_symtab, _bfd_xcoff_get_dynamic_reloc_upper_bound, _bfd_xcoff_canonicalize_dynamic_reloc, @@ -4268,7 +4290,8 @@ static const struct xcoff_backend_data_rec bfd_pmac_xcoff_backend_data = NULL, /* _bfd_coff_adjust_symndx */ _bfd_generic_link_add_one_symbol, coff_link_output_has_begun, - coff_final_link_postscript + coff_final_link_postscript, + NULL /* print_pdata. */ }, 0x01DF, /* magic number */ @@ -4383,8 +4406,10 @@ const bfd_target pmac_xcoff_vec = /* Copy */ _bfd_xcoff_copy_private_bfd_data, ((bfd_boolean (*) (bfd *, bfd *)) bfd_true), + _bfd_generic_init_private_section_data, ((bfd_boolean (*) (bfd *, asection *, bfd *, asection *)) bfd_true), ((bfd_boolean (*) (bfd *, asymbol *, bfd *, asymbol *)) bfd_true), + ((bfd_boolean (*) (bfd *, bfd *)) bfd_true), ((bfd_boolean (*) (bfd *, flagword)) bfd_true), ((bfd_boolean (*) (bfd *, void * )) bfd_true), @@ -4407,13 +4432,16 @@ const bfd_target pmac_xcoff_vec = /* Symbols */ coff_get_symtab_upper_bound, - coff_get_symtab, + coff_canonicalize_symtab, coff_make_empty_symbol, coff_print_symbol, coff_get_symbol_info, _bfd_xcoff_is_local_label_name, + coff_bfd_is_target_special_symbol, coff_get_lineno, coff_find_nearest_line, + _bfd_generic_find_line, + coff_find_inliner_info, coff_bfd_make_debug_symbol, _bfd_generic_read_minisymbols, _bfd_generic_minisymbol_to_symbol, @@ -4422,6 +4450,7 @@ const bfd_target pmac_xcoff_vec = coff_get_reloc_upper_bound, coff_canonicalize_reloc, _bfd_xcoff_reloc_type_lookup, + _bfd_xcoff_reloc_name_lookup, /* Write */ coff_set_arch_mach, @@ -4439,11 +4468,14 @@ const bfd_target pmac_xcoff_vec = _bfd_generic_link_split_section, bfd_generic_gc_sections, bfd_generic_merge_sections, + bfd_generic_is_group_section, bfd_generic_discard_group, + _bfd_generic_section_already_linked, /* Dynamic */ _bfd_xcoff_get_dynamic_symtab_upper_bound, _bfd_xcoff_canonicalize_dynamic_symtab, + _bfd_nodynamic_get_synthetic_symtab, _bfd_xcoff_get_dynamic_reloc_upper_bound, _bfd_xcoff_canonicalize_dynamic_reloc,