* elf-m10300.c (_bfd_mn10300_elf_adjust_dynamic_symbol): Don't error
[platform/upstream/binutils.git] / bfd / elf64-x86-64.c
index 814736e..88c47f9 100644 (file)
@@ -1,6 +1,6 @@
 /* X86-64 specific support for ELF
    Copyright 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
-   2010, 2011
+   2010, 2011, 2012
    Free Software Foundation, Inc.
    Contributed by Jan Hubicka <jh@suse.cz>.
 
@@ -2166,13 +2166,6 @@ elf_x86_64_adjust_dynamic_symbol (struct bfd_link_info *info,
        }
     }
 
-  if (h->size == 0)
-    {
-      (*_bfd_error_handler) (_("dynamic variable `%s' is zero size"),
-                            h->root.root.string);
-      return TRUE;
-    }
-
   /* We must allocate the symbol in our .dynbss section, which will
      become part of the .bss section of the executable.         There will be
      an entry for this symbol in the .dynsym section.  The dynamic
@@ -2190,7 +2183,7 @@ elf_x86_64_adjust_dynamic_symbol (struct bfd_link_info *info,
   /* We must generate a R_X86_64_COPY reloc to tell the dynamic linker
      to copy the initial value out of the dynamic object and into the
      runtime process image.  */
-  if ((h->root.u.def.section->flags & SEC_ALLOC) != 0)
+  if ((h->root.u.def.section->flags & SEC_ALLOC) != 0 && h->size != 0)
     {
       const struct elf_backend_data *bed;
       bed = get_elf_backend_data (info->output_bfd);
@@ -3156,7 +3149,6 @@ elf_x86_64_relocate_section (bfd *output_bfd,
                {
                  Elf_Internal_Rela outrel;
                  asection *sreloc;
-                 bfd_boolean relocate;
 
                  /* Need a dynamic relocation to get the real function
                     address.  */
@@ -3176,15 +3168,15 @@ elf_x86_64_relocate_section (bfd *output_bfd,
                      || info->executable)
                    {
                      /* This symbol is resolved locally.  */
-                     outrel.r_info = htab->r_info (0, R_X86_64_RELATIVE);
-                     outrel.r_addend = relocation;
-                     relocate = FALSE;
+                     outrel.r_info = htab->r_info (0, R_X86_64_IRELATIVE);
+                     outrel.r_addend = (h->root.u.def.value
+                                        + h->root.u.def.section->output_section->vma
+                                        + h->root.u.def.section->output_offset);
                    }
                  else
                    {
                      outrel.r_info = htab->r_info (h->dynindx, r_type);
                      outrel.r_addend = 0;
-                     relocate = FALSE;
                    }
 
                  sreloc = htab->elf.irelifunc;
@@ -3195,8 +3187,7 @@ elf_x86_64_relocate_section (bfd *output_bfd,
                     we need to include the symbol value so that it
                     becomes an addend for the dynamic reloc.  For an
                     internal symbol, we have updated addend.  */
-                 if (! relocate)
-                   continue;
+                 continue;
                }
              /* FALLTHROUGH */
            case R_X86_64_PC32: