diff options
-rw-r--r-- | bfd/ChangeLog | 16 | ||||
-rw-r--r-- | bfd/elf-bfd.h | 2 | ||||
-rw-r--r-- | bfd/elf.c | 15 | ||||
-rw-r--r-- | bfd/elf32-ppc.c | 4 | ||||
-rw-r--r-- | bfd/elf64-ppc.c | 8 | ||||
-rw-r--r-- | bfd/elfcode.h | 2 | ||||
-rw-r--r-- | bfd/elflink.c | 4 | ||||
-rw-r--r-- | bfd/elfxx-ia64.c | 38 |
8 files changed, 56 insertions, 33 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 2e70d77..c22ee92 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,19 @@ +2005-04-27 H.J. Lu <hongjiu.lu@intel.com> + + * elf-bfd.h (bfd_elf_sym_name): Also take "asection *". + + * elf.c (bfd_elf_sym_name): Updated. + (group_signature): Likewise. + * elf32-ppc.c (ppc_elf_relocate_section): Likewise. + * elf64-ppc.c (ppc64_elf_edit_opd): Likewise. + (ppc64_elf_edit_toc): Likewise. + (ppc64_elf_relocate_section): Likewise. + * elfcode.h (elf_slurp_symbol_table): Likewise. + * elflink.c (elf_link_input_bfd): Likewise. + + * elfxx-ia64.c (elfNN_ia64_relocate_section): Call + bfd_elf_sym_name to get local symbol name when reporting errors. + 2005-04-27 Nick Clifton <nickc@redhat.com> * elflink.c (elf_link_input_bfd): Handle the case where a badly diff --git a/bfd/elf-bfd.h b/bfd/elf-bfd.h index e8cd8e0..606e13c 100644 --- a/bfd/elf-bfd.h +++ b/bfd/elf-bfd.h @@ -1372,7 +1372,7 @@ extern Elf_Internal_Sym *bfd_elf_get_elf_syms (bfd *, Elf_Internal_Shdr *, size_t, size_t, Elf_Internal_Sym *, void *, Elf_External_Sym_Shndx *); extern const char *bfd_elf_sym_name - (bfd *, Elf_Internal_Shdr *, Elf_Internal_Sym *); + (bfd *, Elf_Internal_Shdr *, Elf_Internal_Sym *, asection *); extern bfd_boolean _bfd_elf_copy_private_bfd_data (bfd *, bfd *); @@ -407,10 +407,13 @@ bfd_elf_get_elf_syms (bfd *ibfd, const char * bfd_elf_sym_name (bfd *abfd, Elf_Internal_Shdr *symtab_hdr, - Elf_Internal_Sym *isym) + Elf_Internal_Sym *isym, + asection *sym_sec) { + const char *name; unsigned int iname = isym->st_name; unsigned int shindex = symtab_hdr->sh_link; + if (iname == 0 && ELF_ST_TYPE (isym->st_info) == STT_SECTION /* Check for a bogus st_shndx to avoid crashing. */ && isym->st_shndx < elf_numsections (abfd) @@ -420,7 +423,13 @@ bfd_elf_sym_name (bfd *abfd, shindex = elf_elfheader (abfd)->e_shstrndx; } - return bfd_elf_string_from_elf_section (abfd, shindex, iname); + name = bfd_elf_string_from_elf_section (abfd, shindex, iname); + if (name == NULL) + name = "(null)"; + else if (sym_sec && *name == '\0') + name = bfd_section_name (abfd, sym_sec); + + return name; } /* Elf_Internal_Shdr->contents is an array of these for SHT_GROUP @@ -453,7 +462,7 @@ group_signature (bfd *abfd, Elf_Internal_Shdr *ghdr) &isym, esym, &eshndx) == NULL) return NULL; - return bfd_elf_sym_name (abfd, hdr, &isym); + return bfd_elf_sym_name (abfd, hdr, &isym, NULL); } /* Set next_in_group list pointer, and group name for NEWSECT. */ diff --git a/bfd/elf32-ppc.c b/bfd/elf32-ppc.c index 02b1e48..53412c9 100644 --- a/bfd/elf32-ppc.c +++ b/bfd/elf32-ppc.c @@ -4769,7 +4769,7 @@ ppc_elf_relocate_section (bfd *output_bfd, { sym = local_syms + r_symndx; sec = local_sections[r_symndx]; - sym_name = bfd_elf_sym_name (input_bfd, symtab_hdr, sym); + sym_name = bfd_elf_sym_name (input_bfd, symtab_hdr, sym, sec); relocation = _bfd_elf_rela_local_sym (output_bfd, sym, &sec, rel); } @@ -5802,8 +5802,6 @@ ppc_elf_relocate_section (bfd *output_bfd, if (r != bfd_reloc_ok) { - if (sym_name == NULL) - sym_name = "(null)"; if (r == bfd_reloc_overflow) { if (warned) diff --git a/bfd/elf64-ppc.c b/bfd/elf64-ppc.c index a7cbf16..040c037 100644 --- a/bfd/elf64-ppc.c +++ b/bfd/elf64-ppc.c @@ -6186,7 +6186,8 @@ ppc64_elf_edit_opd (bfd *obfd, struct bfd_link_info *info, if (h != NULL) sym_name = h->root.root.string; else - sym_name = bfd_elf_sym_name (ibfd, symtab_hdr, sym); + sym_name = bfd_elf_sym_name (ibfd, symtab_hdr, sym, + sym_sec); (*_bfd_error_handler) (_("%B: undefined sym `%s' in .opd section"), @@ -7221,7 +7222,8 @@ ppc64_elf_edit_toc (bfd *obfd ATTRIBUTE_UNUSED, struct bfd_link_info *info) { (*_bfd_error_handler) (_("%s defined in removed toc entry"), - bfd_elf_sym_name (ibfd, symtab_hdr, sym)); + bfd_elf_sym_name (ibfd, symtab_hdr, sym, + NULL)); sym->st_value = 0; sym->st_shndx = SHN_ABS; } @@ -9473,7 +9475,7 @@ ppc64_elf_relocate_section (bfd *output_bfd, sym = local_syms + r_symndx; sec = local_sections[r_symndx]; - sym_name = bfd_elf_sym_name (input_bfd, symtab_hdr, sym); + sym_name = bfd_elf_sym_name (input_bfd, symtab_hdr, sym, sec); sym_type = ELF64_ST_TYPE (sym->st_info); relocation = _bfd_elf_rela_local_sym (output_bfd, sym, &sec, rel); opd_adjust = get_opd_info (sec); diff --git a/bfd/elfcode.h b/bfd/elfcode.h index fd0daca..a750b1a 100644 --- a/bfd/elfcode.h +++ b/bfd/elfcode.h @@ -1069,7 +1069,7 @@ elf_slurp_symbol_table (bfd *abfd, asymbol **symptrs, bfd_boolean dynamic) memcpy (&sym->internal_elf_sym, isym, sizeof (Elf_Internal_Sym)); sym->symbol.the_bfd = abfd; - sym->symbol.name = bfd_elf_sym_name (abfd, hdr, isym); + sym->symbol.name = bfd_elf_sym_name (abfd, hdr, isym, NULL); sym->symbol.value = isym->st_value; diff --git a/bfd/elflink.c b/bfd/elflink.c index c41fef4..a1c0232 100644 --- a/bfd/elflink.c +++ b/bfd/elflink.c @@ -7051,7 +7051,9 @@ elf_link_input_bfd (struct elf_final_link_info *finfo, bfd *input_bfd) { Elf_Internal_Sym *sym = isymbuf + r_symndx; ps = &finfo->sections[r_symndx]; - sym_name = bfd_elf_sym_name (input_bfd, symtab_hdr, sym); + sym_name = bfd_elf_sym_name (input_bfd, + symtab_hdr, + sym, *ps); } /* Complain if the definition comes from a diff --git a/bfd/elfxx-ia64.c b/bfd/elfxx-ia64.c index 01e4d9f..de5793c 100644 --- a/bfd/elfxx-ia64.c +++ b/bfd/elfxx-ia64.c @@ -4014,7 +4014,9 @@ elfNN_ia64_relocate_section (output_bfd, info, input_bfd, input_section, (*_bfd_error_handler) (_("%B: non-pic code with imm relocation against dynamic symbol `%s'"), input_bfd, - h->root.root.string); + h ? h->root.root.string + : bfd_elf_sym_name (input_bfd, symtab_hdr, sym, + sym_sec)); ret_val = FALSE; continue; @@ -4078,7 +4080,10 @@ elfNN_ia64_relocate_section (output_bfd, info, input_bfd, input_section, { (*_bfd_error_handler) (_("%B: @gprel relocation against dynamic symbol %s"), - input_bfd, h->root.root.string); + input_bfd, + h ? h->root.root.string + : bfd_elf_sym_name (input_bfd, symtab_hdr, sym, + sym_sec)); ret_val = FALSE; continue; } @@ -4279,7 +4284,12 @@ elfNN_ia64_relocate_section (output_bfd, info, input_bfd, input_section, msg = _("%B: speculation fixup to dynamic symbol %s"); else msg = _("%B: @pcrel relocation against dynamic symbol %s"); - (*_bfd_error_handler) (msg, input_bfd, h->root.root.string); + (*_bfd_error_handler) (msg, input_bfd, + h ? h->root.root.string + : bfd_elf_sym_name (input_bfd, + symtab_hdr, + sym, + sym_sec)); ret_val = FALSE; continue; } @@ -4476,15 +4486,8 @@ elfNN_ia64_relocate_section (output_bfd, info, input_bfd, input_section, if (h) name = h->root.root.string; else - { - name = bfd_elf_string_from_elf_section (input_bfd, - symtab_hdr->sh_link, - sym->st_name); - if (name == NULL) - return FALSE; - if (*name == '\0') - name = bfd_section_name (input_bfd, input_section); - } + name = bfd_elf_sym_name (input_bfd, symtab_hdr, sym, + sym_sec); if (!(*info->callbacks->warning) (info, _("unsupported reloc"), name, input_bfd, input_section, rel->r_offset)) @@ -4503,15 +4506,8 @@ elfNN_ia64_relocate_section (output_bfd, info, input_bfd, input_section, if (h) name = h->root.root.string; else - { - name = bfd_elf_string_from_elf_section (input_bfd, - symtab_hdr->sh_link, - sym->st_name); - if (name == NULL) - return FALSE; - if (*name == '\0') - name = bfd_section_name (input_bfd, sym_sec); - } + name = bfd_elf_sym_name (input_bfd, symtab_hdr, sym, + sym_sec); switch (r_type) { |