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.
This commit is contained in:
H.J. Lu 2005-04-27 20:16:08 +00:00
parent dce669a1fd
commit 26c61ae50b
8 changed files with 56 additions and 33 deletions

View File

@ -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

View File

@ -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 *);

View File

@ -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. */

View File

@ -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)

View File

@ -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);

View File

@ -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;

View File

@ -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

View File

@ -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)
{