diff options
Diffstat (limited to 'binutils-2.22/bfd/coff-rs6000.c')
-rw-r--r-- | binutils-2.22/bfd/coff-rs6000.c | 154 |
1 files changed, 100 insertions, 54 deletions
diff --git a/binutils-2.22/bfd/coff-rs6000.c b/binutils-2.22/bfd/coff-rs6000.c index 5d9b5ae..9326b32 100644 --- a/binutils-2.22/bfd/coff-rs6000.c +++ b/binutils-2.22/bfd/coff-rs6000.c @@ -1,6 +1,6 @@ /* BFD back-end for IBM RS/6000 "XCOFF" files. Copyright 1990-1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, - 2008, 2009, 2010, 2011 + 2008, 2009, 2010, 2011, 2012 Free Software Foundation, Inc. Written by Metin G. Ozisik, Mimi Phuong-Thao Vo, and John Gilmore. Archive support from Damon A. Permezel. @@ -40,20 +40,20 @@ extern reloc_howto_type *_bfd_xcoff_reloc_type_lookup (bfd *, bfd_reloc_code_real_type); extern bfd_boolean _bfd_xcoff_slurp_armap (bfd *); extern const bfd_target *_bfd_xcoff_archive_p (bfd *); -extern PTR _bfd_xcoff_read_ar_hdr (bfd *); +extern void * _bfd_xcoff_read_ar_hdr (bfd *); extern bfd *_bfd_xcoff_openr_next_archived_file (bfd *, bfd *); extern int _bfd_xcoff_stat_arch_elt (bfd *, struct stat *); extern bfd_boolean _bfd_xcoff_write_armap (bfd *, unsigned int, struct orl *, unsigned int, int); extern bfd_boolean _bfd_xcoff_write_archive_contents (bfd *); extern int _bfd_xcoff_sizeof_headers (bfd *, struct bfd_link_info *); -extern void _bfd_xcoff_swap_sym_in (bfd *, PTR, PTR); -extern unsigned int _bfd_xcoff_swap_sym_out (bfd *, PTR, PTR); -extern void _bfd_xcoff_swap_aux_in (bfd *, PTR, int, int, int, int, PTR); +extern void _bfd_xcoff_swap_sym_in (bfd *, void *, void *); +extern unsigned int _bfd_xcoff_swap_sym_out (bfd *, void *, void *); +extern void _bfd_xcoff_swap_aux_in (bfd *, void *, int, int, int, int, void *); extern unsigned int _bfd_xcoff_swap_aux_out - (bfd *, PTR, int, int, int, int, PTR); -static void xcoff_swap_reloc_in (bfd *, PTR, PTR); -static unsigned int xcoff_swap_reloc_out (bfd *, PTR, PTR); + (bfd *, void *, int, int, int, int, void *); +static void xcoff_swap_reloc_in (bfd *, void *, void *); +static unsigned int xcoff_swap_reloc_out (bfd *, void *, void *); /* Forward declare xcoff_rtype2howto for coffcode.h macro. */ void xcoff_rtype2howto (arelent *, struct internal_reloc *); @@ -129,12 +129,12 @@ static bfd_boolean xcoff_write_armap_big (bfd *, unsigned int, struct orl *, unsigned int, int); static bfd_boolean xcoff_write_archive_contents_old (bfd *); static bfd_boolean xcoff_write_archive_contents_big (bfd *); -static void xcoff_swap_ldhdr_in (bfd *, const PTR, struct internal_ldhdr *); -static void xcoff_swap_ldhdr_out (bfd *, const struct internal_ldhdr *, PTR); -static void xcoff_swap_ldsym_in (bfd *, const PTR, struct internal_ldsym *); -static void xcoff_swap_ldsym_out (bfd *, const struct internal_ldsym *, PTR); -static void xcoff_swap_ldrel_in (bfd *, const PTR, struct internal_ldrel *); -static void xcoff_swap_ldrel_out (bfd *, const struct internal_ldrel *, PTR); +static void xcoff_swap_ldhdr_in (bfd *, const void *, struct internal_ldhdr *); +static void xcoff_swap_ldhdr_out (bfd *, const struct internal_ldhdr *, void *); +static void xcoff_swap_ldsym_in (bfd *, const void *, struct internal_ldsym *); +static void xcoff_swap_ldsym_out (bfd *, const struct internal_ldsym *, void *); +static void xcoff_swap_ldrel_in (bfd *, const void *, struct internal_ldrel *); +static void xcoff_swap_ldrel_out (bfd *, const struct internal_ldrel *, void *); static bfd_boolean xcoff_ppc_relocate_section (bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *, struct internal_reloc *, struct internal_syment *, asection **); @@ -405,9 +405,53 @@ _bfd_xcoff_is_local_label_name (bfd *abfd ATTRIBUTE_UNUSED, { return FALSE; } + +static const struct dwarf_debug_section xcoff_debug_sections[] = +{ + { ".dwabrev", NULL }, + { ".dwarnge", NULL }, + { NULL, NULL }, /* .debug_frame */ + { ".dwinfo", NULL }, + { ".dwline", NULL }, + { NULL, NULL }, /* .debug_loc */ + { NULL, NULL }, /* .debug_macinfo */ + { NULL, NULL }, /* .debug_macro */ + { ".dwpbnms", NULL }, + { ".dwpbtyp", NULL }, + { ".dwrnges", NULL }, + { NULL, NULL }, /* .debug_static_func */ + { NULL, NULL }, /* .debug_static_vars */ + { ".dwstr", NULL }, + { NULL, NULL }, /* .debug_types */ + /* GNU DWARF 1 extensions */ + { NULL, NULL }, /* .debug_sfnames */ + { NULL, NULL }, /* .debug_srcinfo */ + /* SGI/MIPS DWARF 2 extensions */ + { NULL, NULL }, /* .debug_funcnames */ + { NULL, NULL }, /* .debug_typenames */ + { NULL, NULL }, /* .debug_varnames */ + { NULL, NULL }, /* .debug_weaknames */ + { NULL, NULL }, +}; + +static bfd_boolean +xcoff_find_nearest_line (bfd *abfd, + asection *section, + asymbol **symbols, + bfd_vma offset, + const char **filename_ptr, + const char **functionname_ptr, + unsigned int *line_ptr) +{ + return coff_find_nearest_line_with_names (abfd, xcoff_debug_sections, + section, symbols, offset, + filename_ptr, functionname_ptr, + line_ptr); +} + void -_bfd_xcoff_swap_sym_in (bfd *abfd, PTR ext1, PTR in1) +_bfd_xcoff_swap_sym_in (bfd *abfd, void * ext1, void * in1) { SYMENT *ext = (SYMENT *)ext1; struct internal_syment * in = (struct internal_syment *)in1; @@ -430,7 +474,7 @@ _bfd_xcoff_swap_sym_in (bfd *abfd, PTR ext1, PTR in1) } unsigned int -_bfd_xcoff_swap_sym_out (bfd *abfd, PTR inp, PTR extp) +_bfd_xcoff_swap_sym_out (bfd *abfd, void * inp, void * extp) { struct internal_syment *in = (struct internal_syment *)inp; SYMENT *ext =(SYMENT *)extp; @@ -454,8 +498,8 @@ _bfd_xcoff_swap_sym_out (bfd *abfd, PTR inp, PTR extp) } void -_bfd_xcoff_swap_aux_in (bfd *abfd, PTR ext1, int type, int in_class, - int indx, int numaux, PTR in1) +_bfd_xcoff_swap_aux_in (bfd *abfd, void * ext1, int type, int in_class, + int indx, int numaux, void * in1) { AUXENT * ext = (AUXENT *)ext1; union internal_auxent *in = (union internal_auxent *)in1; @@ -564,15 +608,15 @@ _bfd_xcoff_swap_aux_in (bfd *abfd, PTR ext1, int type, int in_class, } unsigned int -_bfd_xcoff_swap_aux_out (bfd *abfd, PTR inp, int type, int in_class, +_bfd_xcoff_swap_aux_out (bfd *abfd, void * inp, int type, int in_class, int indx ATTRIBUTE_UNUSED, int numaux ATTRIBUTE_UNUSED, - PTR extp) + void * extp) { union internal_auxent *in = (union internal_auxent *)inp; AUXENT *ext = (AUXENT *)extp; - memset ((PTR)ext, 0, bfd_coff_auxesz (abfd)); + memset (ext, 0, bfd_coff_auxesz (abfd)); switch (in_class) { case C_FILE: @@ -1219,7 +1263,7 @@ _bfd_xcoff_slurp_armap (bfd *abfd) return FALSE; /* The symbol table starts with a normal archive header. */ - if (bfd_bread ((PTR) &hdr, (bfd_size_type) SIZEOF_AR_HDR, abfd) + if (bfd_bread (&hdr, (bfd_size_type) SIZEOF_AR_HDR, abfd) != SIZEOF_AR_HDR) return FALSE; @@ -1235,7 +1279,7 @@ _bfd_xcoff_slurp_armap (bfd *abfd) contents = (bfd_byte *) bfd_alloc (abfd, sz); if (contents == NULL) return FALSE; - if (bfd_bread ((PTR) contents, sz, abfd) != sz) + if (bfd_bread (contents, sz, abfd) != sz) return FALSE; /* The symbol table starts with a four byte count. */ @@ -1274,7 +1318,7 @@ _bfd_xcoff_slurp_armap (bfd *abfd) return FALSE; /* The symbol table starts with a normal archive header. */ - if (bfd_bread ((PTR) &hdr, (bfd_size_type) SIZEOF_AR_HDR_BIG, abfd) + if (bfd_bread (&hdr, (bfd_size_type) SIZEOF_AR_HDR_BIG, abfd) != SIZEOF_AR_HDR_BIG) return FALSE; @@ -1293,7 +1337,7 @@ _bfd_xcoff_slurp_armap (bfd *abfd) contents = (bfd_byte *) bfd_alloc (abfd, sz); if (contents == NULL) return FALSE; - if (bfd_bread ((PTR) contents, sz, abfd) != sz) + if (bfd_bread (contents, sz, abfd) != sz) return FALSE; /* The symbol table starts with an eight byte count. */ @@ -1346,7 +1390,7 @@ _bfd_xcoff_archive_p (bfd *abfd) char magic[SXCOFFARMAG]; bfd_size_type amt = SXCOFFARMAG; - if (bfd_bread ((PTR) magic, amt, abfd) != amt) + if (bfd_bread (magic, amt, abfd) != amt) { if (bfd_get_error () != bfd_error_system_call) bfd_set_error (bfd_error_wrong_format); @@ -1385,7 +1429,7 @@ _bfd_xcoff_archive_p (bfd *abfd) /* Now read the rest of the file header. */ amt = SIZEOF_AR_FILE_HDR - SXCOFFARMAG; - if (bfd_bread ((PTR) &hdr.memoff, amt, abfd) != amt) + if (bfd_bread (&hdr.memoff, amt, abfd) != amt) { if (bfd_get_error () != bfd_error_system_call) bfd_set_error (bfd_error_wrong_format); @@ -1412,7 +1456,7 @@ _bfd_xcoff_archive_p (bfd *abfd) /* Now read the rest of the file header. */ amt = SIZEOF_AR_FILE_HDR_BIG - SXCOFFARMAG; - if (bfd_bread ((PTR) &hdr.memoff, amt, abfd) != amt) + if (bfd_bread (&hdr.memoff, amt, abfd) != amt) { if (bfd_get_error () != bfd_error_system_call) bfd_set_error (bfd_error_wrong_format); @@ -1445,7 +1489,7 @@ _bfd_xcoff_archive_p (bfd *abfd) /* Read the archive header in an XCOFF archive. */ -PTR +void * _bfd_xcoff_read_ar_hdr (bfd *abfd) { bfd_size_type namlen; @@ -1461,7 +1505,7 @@ _bfd_xcoff_read_ar_hdr (bfd *abfd) struct xcoff_ar_hdr hdr; struct xcoff_ar_hdr *hdrp; - if (bfd_bread ((PTR) &hdr, (bfd_size_type) SIZEOF_AR_HDR, abfd) + if (bfd_bread (&hdr, (bfd_size_type) SIZEOF_AR_HDR, abfd) != SIZEOF_AR_HDR) { free (ret); @@ -1493,7 +1537,7 @@ _bfd_xcoff_read_ar_hdr (bfd *abfd) struct xcoff_ar_hdr_big hdr; struct xcoff_ar_hdr_big *hdrp; - if (bfd_bread ((PTR) &hdr, (bfd_size_type) SIZEOF_AR_HDR_BIG, abfd) + if (bfd_bread (&hdr, (bfd_size_type) SIZEOF_AR_HDR_BIG, abfd) != SIZEOF_AR_HDR_BIG) { free (ret); @@ -1528,7 +1572,7 @@ _bfd_xcoff_read_ar_hdr (bfd *abfd) if (bfd_seek (abfd, (file_ptr) ((namlen & 1) + SXCOFFARFMAG), SEEK_CUR) != 0) return NULL; - return (PTR) ret; + return ret; } /* Open the next element in an XCOFF archive. */ @@ -1669,7 +1713,7 @@ xcoff_write_armap_old (bfd *abfd, unsigned int elength ATTRIBUTE_UNUSED, if (*p == '\0') *p = ' '; - if (bfd_bwrite ((PTR) &hdr, (bfd_size_type) SIZEOF_AR_HDR, abfd) + if (bfd_bwrite (&hdr, (bfd_size_type) SIZEOF_AR_HDR, abfd) != SIZEOF_AR_HDR || (bfd_bwrite (XCOFFARFMAG, (bfd_size_type) SXCOFFARFMAG, abfd) != SXCOFFARFMAG)) @@ -2186,20 +2230,20 @@ xcoff_write_archive_contents_old (bfd *abfd) if (*p == '\0') *p = ' '; - if ((bfd_bwrite ((PTR) &ahdr, (bfd_size_type) SIZEOF_AR_HDR, abfd) + if ((bfd_bwrite (&ahdr, (bfd_size_type) SIZEOF_AR_HDR, abfd) != SIZEOF_AR_HDR) - || (bfd_bwrite ((PTR) XCOFFARFMAG, (bfd_size_type) SXCOFFARFMAG, abfd) + || (bfd_bwrite (XCOFFARFMAG, (bfd_size_type) SXCOFFARFMAG, abfd) != SXCOFFARFMAG)) return FALSE; sprintf (decbuf, "%-12ld", (long) count); - if (bfd_bwrite ((PTR) decbuf, (bfd_size_type) XCOFFARMAG_ELEMENT_SIZE, abfd) + if (bfd_bwrite (decbuf, (bfd_size_type) XCOFFARMAG_ELEMENT_SIZE, abfd) != XCOFFARMAG_ELEMENT_SIZE) return FALSE; for (i = 0; i < (size_t) count; i++) { sprintf (decbuf, "%-12ld", (long) offsets[i]); - if (bfd_bwrite ((PTR) decbuf, (bfd_size_type) XCOFFARMAG_ELEMENT_SIZE, + if (bfd_bwrite (decbuf, (bfd_size_type) XCOFFARMAG_ELEMENT_SIZE, abfd) != XCOFFARMAG_ELEMENT_SIZE) return FALSE; } @@ -2210,7 +2254,7 @@ xcoff_write_archive_contents_old (bfd *abfd) name = normalize_filename (sub); namlen = strlen (name); - if (bfd_bwrite ((PTR) name, namlen + 1, abfd) != namlen + 1) + if (bfd_bwrite (name, namlen + 1, abfd) != namlen + 1) return FALSE; } @@ -2224,7 +2268,7 @@ xcoff_write_archive_contents_old (bfd *abfd) { BFD_ASSERT (nextoff == bfd_tell (abfd)); sprintf (fhdr.symoff, "%ld", (long) nextoff); - bfd_ardata (abfd)->tdata = (PTR) &fhdr; + bfd_ardata (abfd)->tdata = &fhdr; if (! _bfd_compute_and_write_armap (abfd, 0)) return FALSE; } @@ -2237,7 +2281,7 @@ xcoff_write_archive_contents_old (bfd *abfd) *p = ' '; if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0 - || (bfd_bwrite ((PTR) &fhdr, (bfd_size_type) SIZEOF_AR_FILE_HDR, abfd) + || (bfd_bwrite (&fhdr, (bfd_size_type) SIZEOF_AR_FILE_HDR, abfd) != SIZEOF_AR_FILE_HDR)) return FALSE; @@ -2465,7 +2509,7 @@ xcoff_write_archive_contents_big (bfd *abfd) /* Save nextoff in fhdr.symoff so the armap routine can use it. */ PRINT20 (fhdr.symoff, nextoff); - bfd_ardata (abfd)->tdata = (PTR) &fhdr; + bfd_ardata (abfd)->tdata = &fhdr; if (! _bfd_compute_and_write_armap (abfd, 0)) return FALSE; } @@ -2473,7 +2517,7 @@ xcoff_write_archive_contents_big (bfd *abfd) /* Write out the archive file header. */ if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0 - || (bfd_bwrite ((PTR) &fhdr, (bfd_size_type) SIZEOF_AR_FILE_HDR_BIG, + || (bfd_bwrite (&fhdr, (bfd_size_type) SIZEOF_AR_FILE_HDR_BIG, abfd) != SIZEOF_AR_FILE_HDR_BIG)) return FALSE; @@ -2515,7 +2559,7 @@ _bfd_xcoff_sizeof_headers (bfd *abfd, /* Swap in the ldhdr structure. */ static void -xcoff_swap_ldhdr_in (bfd *abfd, const PTR s, struct internal_ldhdr *dst) +xcoff_swap_ldhdr_in (bfd *abfd, const void * s, struct internal_ldhdr *dst) { const struct external_ldhdr *src = (const struct external_ldhdr *) s; @@ -2532,7 +2576,7 @@ xcoff_swap_ldhdr_in (bfd *abfd, const PTR s, struct internal_ldhdr *dst) /* Swap out the ldhdr structure. */ static void -xcoff_swap_ldhdr_out (bfd *abfd, const struct internal_ldhdr *src, PTR d) +xcoff_swap_ldhdr_out (bfd *abfd, const struct internal_ldhdr *src, void * d) { struct external_ldhdr *dst = (struct external_ldhdr *) d; @@ -2549,7 +2593,7 @@ xcoff_swap_ldhdr_out (bfd *abfd, const struct internal_ldhdr *src, PTR d) /* Swap in the ldsym structure. */ static void -xcoff_swap_ldsym_in (bfd *abfd, const PTR s, struct internal_ldsym *dst) +xcoff_swap_ldsym_in (bfd *abfd, const void * s, struct internal_ldsym *dst) { const struct external_ldsym *src = (const struct external_ldsym *) s; @@ -2570,7 +2614,7 @@ xcoff_swap_ldsym_in (bfd *abfd, const PTR s, struct internal_ldsym *dst) /* Swap out the ldsym structure. */ static void -xcoff_swap_ldsym_out (bfd *abfd, const struct internal_ldsym *src, PTR d) +xcoff_swap_ldsym_out (bfd *abfd, const struct internal_ldsym *src, void * d) { struct external_ldsym *dst = (struct external_ldsym *) d; @@ -2591,7 +2635,7 @@ xcoff_swap_ldsym_out (bfd *abfd, const struct internal_ldsym *src, PTR d) } static void -xcoff_swap_reloc_in (bfd *abfd, PTR s, PTR d) +xcoff_swap_reloc_in (bfd *abfd, void * s, void * d) { struct external_reloc *src = (struct external_reloc *) s; struct internal_reloc *dst = (struct internal_reloc *) d; @@ -2605,7 +2649,7 @@ xcoff_swap_reloc_in (bfd *abfd, PTR s, PTR d) } static unsigned int -xcoff_swap_reloc_out (bfd *abfd, PTR s, PTR d) +xcoff_swap_reloc_out (bfd *abfd, void * s, void * d) { struct internal_reloc *src = (struct internal_reloc *) s; struct external_reloc *dst = (struct external_reloc *) d; @@ -2621,7 +2665,7 @@ xcoff_swap_reloc_out (bfd *abfd, PTR s, PTR d) /* Swap in the ldrel structure. */ static void -xcoff_swap_ldrel_in (bfd *abfd, const PTR s, struct internal_ldrel *dst) +xcoff_swap_ldrel_in (bfd *abfd, const void * s, struct internal_ldrel *dst) { const struct external_ldrel *src = (const struct external_ldrel *) s; @@ -2634,7 +2678,7 @@ xcoff_swap_ldrel_in (bfd *abfd, const PTR s, struct internal_ldrel *dst) /* Swap out the ldrel structure. */ static void -xcoff_swap_ldrel_out (bfd *abfd, const struct internal_ldrel *src, PTR d) +xcoff_swap_ldrel_out (bfd *abfd, const struct internal_ldrel *src, void * d) { struct external_ldrel *dst = (struct external_ldrel *) d; @@ -4073,7 +4117,8 @@ const bfd_target rs6000coff_vec = _bfd_xcoff_is_local_label_name, coff_bfd_is_target_special_symbol, coff_get_lineno, - coff_find_nearest_line, + xcoff_find_nearest_line, + _bfd_generic_find_nearest_line_discriminator, _bfd_generic_find_line, coff_find_inliner_info, coff_bfd_make_debug_symbol, @@ -4119,7 +4164,7 @@ const bfd_target rs6000coff_vec = /* Opposite endian version, none exists */ NULL, - (void *) &bfd_xcoff_backend_data, + & bfd_xcoff_backend_data, }; /* xcoff-powermac target @@ -4328,7 +4373,8 @@ const bfd_target pmac_xcoff_vec = _bfd_xcoff_is_local_label_name, coff_bfd_is_target_special_symbol, coff_get_lineno, - coff_find_nearest_line, + xcoff_find_nearest_line, + _bfd_generic_find_nearest_line_discriminator, _bfd_generic_find_line, coff_find_inliner_info, coff_bfd_make_debug_symbol, @@ -4374,5 +4420,5 @@ const bfd_target pmac_xcoff_vec = /* Opposite endian version, none exists */ NULL, - (void *) &bfd_pmac_xcoff_backend_data, + & bfd_pmac_xcoff_backend_data, }; |