2001-10-05 H.J. Lu <hjl@gnu.org>
[deliverable/binutils-gdb.git] / bfd / elf64-x86-64.c
index 24eb9f76a0b2fe4612ed60dff3bfe3b9669f05cd..321542165c1fba68b2d4166f00b6e184dcaaf928 100644 (file)
@@ -153,7 +153,8 @@ static boolean elf64_x86_64_finish_dynamic_symbol
           Elf_Internal_Sym *sym));
 static boolean elf64_x86_64_finish_dynamic_sections
   PARAMS ((bfd *, struct bfd_link_info *));
-static enum elf_reloc_type_class elf64_x86_64_reloc_type_class PARAMS ((int));
+static enum elf_reloc_type_class elf64_x86_64_reloc_type_class
+  PARAMS ((const Elf_Internal_Rela *));
 
 /* Given a BFD reloc type, return a HOWTO structure.  */
 static reloc_howto_type *
@@ -166,8 +167,7 @@ elf64_x86_64_reloc_type_lookup (abfd, code)
        i++)
     {
       if (x86_64_reloc_map[i].bfd_reloc_val == code)
-       return &x86_64_elf_howto_table[(int)
-                                      x86_64_reloc_map[i].elf_reloc_val];
+       return &x86_64_elf_howto_table[i];
     }
   return 0;
 }
@@ -441,10 +441,8 @@ elf64_x86_64_check_relocs (abfd, info, sec, relocs)
 
          if (h != NULL)
            {
-             if (h->got.refcount == -1)
+             if (h->got.refcount == 0)
                {
-                 h->got.refcount = 1;
-
                  /* Make sure this symbol is output as a dynamic symbol.  */
                  if (h->dynindx == -1)
                    {
@@ -455,8 +453,7 @@ elf64_x86_64_check_relocs (abfd, info, sec, relocs)
                  sgot->_raw_size += GOT_ENTRY_SIZE;
                  srelgot->_raw_size += sizeof (Elf64_External_Rela);
                }
-             else
-               h->got.refcount += 1;
+             h->got.refcount += 1;
            }
          else
            {
@@ -468,16 +465,13 @@ elf64_x86_64_check_relocs (abfd, info, sec, relocs)
                  size = symtab_hdr->sh_info;
                  size *= sizeof (bfd_signed_vma);
                  local_got_refcounts = ((bfd_signed_vma *)
-                                        bfd_alloc (abfd, size));
+                                        bfd_zalloc (abfd, size));
                  if (local_got_refcounts == NULL)
                    return false;
                  elf_local_got_refcounts (abfd) = local_got_refcounts;
-                 memset (local_got_refcounts, -1, (size_t) size);
                }
-             if (local_got_refcounts[r_symndx] == -1)
+             if (local_got_refcounts[r_symndx] == 0)
                {
-                 local_got_refcounts[r_symndx] = 1;
-
                  sgot->_raw_size += GOT_ENTRY_SIZE;
                  if (info->shared)
                    {
@@ -487,8 +481,7 @@ elf64_x86_64_check_relocs (abfd, info, sec, relocs)
                      srelgot->_raw_size += sizeof (Elf64_External_Rela);
                    }
                }
-             else
-               local_got_refcounts[r_symndx] += 1;
+             local_got_refcounts[r_symndx] += 1;
            }
          break;
 
@@ -506,10 +499,7 @@ elf64_x86_64_check_relocs (abfd, info, sec, relocs)
            continue;
 
          h->elf_link_hash_flags |= ELF_LINK_HASH_NEEDS_PLT;
-         if (h->plt.refcount == -1)
-           h->plt.refcount = 1;
-         else
-           h->plt.refcount += 1;
+         h->plt.refcount += 1;
          break;
 
        case R_X86_64_8:
@@ -1289,7 +1279,7 @@ elf64_x86_64_relocate_section (output_bfd, info, input_bfd, input_section,
                {
                  (*_bfd_error_handler)
                    (_("%s: warning: unresolvable relocation against symbol `%s' from %s section"),
-                    bfd_get_filename (input_bfd), h->root.root.string,
+                    bfd_archive_filename (input_bfd), h->root.root.string,
                     bfd_get_section_name (input_bfd, input_section));
                  relocation = 0;
                }
@@ -1300,7 +1290,9 @@ elf64_x86_64_relocate_section (output_bfd, info, input_bfd, input_section,
            }
          else if (h->root.type == bfd_link_hash_undefweak)
            relocation = 0;
-         else if (info->shared && !info->symbolic && !info->no_undefined
+         else if (info->shared
+                  && (!info->symbolic || info->allow_shlib_undefined)
+                  && !info->no_undefined
                   && ELF_ST_VISIBILITY (h->other) == STV_DEFAULT)
            relocation = 0;
          else
@@ -1934,10 +1926,10 @@ elf64_x86_64_finish_dynamic_sections (output_bfd, info)
 }
 
 static enum elf_reloc_type_class
-elf64_x86_64_reloc_type_class (type)
-     int type;
+elf64_x86_64_reloc_type_class (rela)
+     const Elf_Internal_Rela *rela;
 {
-  switch (type)
+  switch ((int) ELF64_R_TYPE (rela->r_info))
     {
     case R_X86_64_RELATIVE:
       return reloc_class_relative;
@@ -1957,6 +1949,7 @@ elf64_x86_64_reloc_type_class (type)
 #define ELF_MAXPAGESIZE                            0x100000
 
 #define elf_backend_can_gc_sections        1
+#define elf_backend_can_refcount           1
 #define elf_backend_want_got_plt           1
 #define elf_backend_plt_readonly           1
 #define elf_backend_want_plt_sym           0
This page took 0.025986 seconds and 4 git commands to generate.