daily update
[deliverable/binutils-gdb.git] / bfd / elf64-sparc.c
index 6fd24f9f9572ee2b44f2b8088ee6b223fb89eece..50b0cd58cc6ecfa500ce48f822e07c81c1f6ffde 100644 (file)
@@ -921,8 +921,8 @@ sparc64_elf_build_plt (output_bfd, contents, nentries)
          entry = contents + i*PLT_ENTRY_SIZE + j*4*6;
          ptr = contents + i*PLT_ENTRY_SIZE + block*4*6 + j*8;
 
-         /* ldx [%o7 + ptr - entry+4], %g1 */
-         ldx = 0xc25be000 | ((ptr - entry+4) & 0x1fff);
+         /* ldx [%o7 + ptr - (entry+4)], %g1 */
+         ldx = 0xc25be000 | ((ptr - (entry+4)) & 0x1fff);
 
          /* mov %o7,%g5
             call .+8
@@ -1786,7 +1786,7 @@ sparc64_elf_size_dynamic_sections (output_bfd, info)
 
       int reg;
       struct sparc64_elf_app_reg * app_regs;
-      struct bfd_strtab_hash *dynstr;
+      struct elf_strtab_hash *dynstr;
       struct elf_link_hash_table *eht = elf_hash_table (info);
 
       if (!info->shared)
@@ -1840,7 +1840,7 @@ sparc64_elf_size_dynamic_sections (output_bfd, info)
            entry->isym.st_size = 0;
            if (*app_regs [reg].name != '\0')
              entry->isym.st_name
-               = _bfd_stringtab_add (dynstr, app_regs[reg].name, true, false);
+               = _bfd_elf_strtab_add (dynstr, app_regs[reg].name, false);
            else
              entry->isym.st_name = 0;
            entry->isym.st_other = 0;
@@ -1969,9 +1969,7 @@ sparc64_elf_relocate_section (output_bfd, info, input_bfd, input_section,
        {
          sym = local_syms + r_symndx;
          sec = local_sections[r_symndx];
-         relocation = (sec->output_section->vma
-                       + sec->output_offset
-                       + sym->st_value);
+         relocation = _bfd_elf_rela_local_sym (output_bfd, sym, sec, rel);
        }
       else
        {
@@ -2055,7 +2053,15 @@ sparc64_elf_relocate_section (output_bfd, info, input_bfd, input_section,
                  if (info->shared
                      && ((!info->symbolic && h->dynindx != -1)
                          || !(h->elf_link_hash_flags
-                              & ELF_LINK_HASH_DEF_REGULAR)))
+                              & ELF_LINK_HASH_DEF_REGULAR))
+                     && ((input_section->flags & SEC_ALLOC) != 0
+                         /* DWARF will emit R_SPARC_{32,64} relocations in
+                            its sections against symbols defined externally
+                            in shared libraries.  We can't do anything
+                            with them here.  */
+                         || ((input_section->flags & SEC_DEBUGGING) != 0
+                             && (h->elf_link_hash_flags
+                                 & ELF_LINK_HASH_DEF_DYNAMIC) != 0)))
                    skip_it = true;
                  break;
                }
@@ -2103,7 +2109,7 @@ sparc64_elf_relocate_section (output_bfd, info, input_bfd, input_section,
 
       /* When generating a shared object, these relocations are copied
         into the output file to be resolved at run time.  */
-      if (info->shared && (input_section->flags & SEC_ALLOC))
+      if (info->shared && r_symndx != 0 && (input_section->flags & SEC_ALLOC))
        {
          switch (r_type)
            {
@@ -2178,21 +2184,11 @@ sparc64_elf_relocate_section (output_bfd, info, input_bfd, input_section,
 
                skip = false;
 
-               if (elf_section_data (input_section)->stab_info == NULL)
-                 outrel.r_offset = rel->r_offset;
-               else
-                 {
-                   bfd_vma off;
-
-                   off = (_bfd_stab_section_offset
-                          (output_bfd, &elf_hash_table (info)->stab_info,
-                           input_section,
-                           &elf_section_data (input_section)->stab_info,
-                           rel->r_offset));
-                   if (off == MINUS_ONE)
-                     skip = true;
-                   outrel.r_offset = off;
-                 }
+               outrel.r_offset =
+                 _bfd_elf_section_offset (output_bfd, info, input_section,
+                                          rel->r_offset);
+               if (outrel.r_offset == (bfd_vma) -1)
+                 skip = true;
 
                outrel.r_offset += (input_section->output_section->vma
                                    + input_section->output_offset);
@@ -2627,6 +2623,16 @@ sparc64_elf_relocate_section (output_bfd, info, input_bfd, input_section,
          {
            const char *name;
 
+           /* The Solaris native linker silently disregards
+              overflows.  We don't, but this breaks stabs debugging
+              info, whose relocations are only 32-bits wide.  Ignore
+              overflows in this case.  */
+           if (r_type == R_SPARC_32
+               && (input_section->flags & SEC_DEBUGGING) != 0
+               && strcmp (bfd_section_name (input_bfd, input_section),
+                          ".stab") == 0)
+             break;
+
            if (h != NULL)
              {
                if (h->root.type == bfd_link_hash_undefweak
This page took 0.025521 seconds and 4 git commands to generate.