2005-04-27 H.J. Lu <hongjiu.lu@intel.com>
authorH.J. Lu <hjl.tools@gmail.com>
Wed, 27 Apr 2005 20:16:08 +0000 (20:16 +0000)
committerH.J. Lu <hjl.tools@gmail.com>
Wed, 27 Apr 2005 20:16:08 +0000 (20:16 +0000)
* 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.

bfd/ChangeLog
bfd/elf-bfd.h
bfd/elf.c
bfd/elf32-ppc.c
bfd/elf64-ppc.c
bfd/elfcode.h
bfd/elflink.c
bfd/elfxx-ia64.c

index 2e70d771a140d8af85b4fdf7764d340b749be72d..c22ee92d45b8b8e41af2565f298e0f68d9be3abb 100644 (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
index e8cd8e0fa2672c019149f5828cb0ffaf2026ce26..606e13cd294777650d2fe22176dc4e22d4fb0d06 100644 (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 *);
index a768171bcf2f01f079921e06080b3b609def15da..ba66cd48f317ba0e817f05c0448ab814aea7dfb4 100644 (file)
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -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.  */
index 02b1e487e07357360aa37a088569fdd3fce63e65..53412c9d6ef048fb9ce384937e110210d3d929c9 100644 (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)
index a7cbf1633c6d10101cc012cf25d6abbedb262057..040c0375f95663fdb3b4b678cf360f2a3336b06b 100644 (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);
index fd0dacad5c6679f654cfad5b4fd1bfa0c61a6270..a750b1a0bb4611f964b0189c515bbc7e1e6479d8 100644 (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;
 
index c41fef4bcb86a5ec5354a7c910232ddd0c4b2f05..a1c02325d1fd19f5943b7bd57213684afe22bf31 100644 (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
index 01e4d9f3aa1c565da19a1a5e3a409a890e7190c7..de5793cac51da463c0a34d703a98fb71d3b805dc 100644 (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)
              {