* config/tc-s390.c (md_parse_option): Set s390_arch_size to 32
[deliverable/binutils-gdb.git] / bfd / elf32-ppc.c
index 1745ef575dce7eed2a65a66988c76ebab4198530..56df535f038c25c01bc76092076e388d17e52673 100644 (file)
@@ -31,7 +31,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
 #include "elf-bfd.h"
 #include "elf/ppc.h"
 
-#define USE_RELA               /* we want RELA relocations, not REL */
+/* RELA relocations are used here.  */
 
 static reloc_howto_type *ppc_elf_reloc_type_lookup
   PARAMS ((bfd *abfd, bfd_reloc_code_real_type code));
@@ -2743,11 +2743,11 @@ ppc_elf_finish_dynamic_symbol (output_bfd, info, h, sym)
       else
        {
          BFD_ASSERT ((h->got.offset & 1) == 0);
-         bfd_put_32 (output_bfd, (bfd_vma) 0, sgot->contents + h->got.offset);
          rela.r_info = ELF32_R_INFO (h->dynindx, R_PPC_GLOB_DAT);
          rela.r_addend = 0;
        }
 
+      bfd_put_32 (output_bfd, (bfd_vma) 0, sgot->contents + h->got.offset);
       bfd_elf32_swap_reloca_out (output_bfd, &rela,
                                 ((Elf32_External_Rela *) srela->contents
                                  + srela->reloc_count));
@@ -3287,13 +3287,19 @@ ppc_elf_relocate_section (output_bfd, info, input_bfd, input_section,
                                          + sreloc->reloc_count));
              ++sreloc->reloc_count;
 
-             /* This reloc will be computed at runtime, so there's no
-                 need to do anything now, unless this is a RELATIVE
-                 reloc in an unallocated section.  */
-             if (skip != -1
-                 || (input_section->flags & SEC_ALLOC) != 0
-                 || ELF32_R_TYPE (outrel.r_info) != R_PPC_RELATIVE)
+             if (skip == -1)
                continue;
+
+             /* This reloc will be computed at runtime.  We clear the memory
+                so that it contains predictable value.  */
+             if (! skip
+                 && ((input_section->flags & SEC_ALLOC) != 0
+                     || ELF32_R_TYPE (outrel.r_info) != R_PPC_RELATIVE))
+               {
+                 relocation = howto->pc_relative ? outrel.r_offset : 0;
+                 addend = 0;
+                 break;
+               }
            }
 
          /* Arithmetic adjust relocations that aren't going into a
@@ -3390,7 +3396,6 @@ ppc_elf_relocate_section (output_bfd, info, input_bfd, input_section,
                off &= ~1;
              else
                {
-                 bfd_put_32 (output_bfd, relocation, sgot->contents + off);
 
                  if (info->shared)
                    {
@@ -3412,8 +3417,10 @@ ppc_elf_relocate_section (output_bfd, info, input_bfd, input_section,
                                                   srelgot->contents)
                                                  + srelgot->reloc_count));
                      ++srelgot->reloc_count;
+                     relocation = 0;
                    }
 
+                 bfd_put_32 (output_bfd, relocation, sgot->contents + off);
                  local_got_offsets[r_symndx] |= 1;
                }
 
@@ -3476,8 +3483,10 @@ ppc_elf_relocate_section (output_bfd, info, input_bfd, input_section,
 
            BFD_ASSERT (sec != (asection *) 0);
            name = bfd_get_section_name (abfd, sec->output_section);
-           if (strcmp (name, ".sdata") != 0
-               && strcmp (name, ".sbss") != 0)
+           if (! ((strncmp (name, ".sdata", 6) == 0
+                   && (name[6] == 0 || name[6] == '.'))
+                  || (strncmp (name, ".sbss", 5) == 0
+                      && (name[5] == 0 || name[5] == '.'))))
              {
                (*_bfd_error_handler) (_("%s: The target (%s) of a %s relocation is in the wrong output section (%s)"),
                                       bfd_archive_filename (input_bfd),
@@ -3498,7 +3507,8 @@ ppc_elf_relocate_section (output_bfd, info, input_bfd, input_section,
 
            BFD_ASSERT (sec != (asection *) 0);
            name = bfd_get_section_name (abfd, sec->output_section);
-           if (strcmp (name, ".sdata2") != 0 && strcmp (name, ".sbss2") != 0)
+           if (! (strncmp (name, ".sdata2", 7) == 0
+                  || strncmp (name, ".sbss2", 6) == 0))
              {
                (*_bfd_error_handler) (_("%s: The target (%s) of a %s relocation is in the wrong output section (%s)"),
                                       bfd_archive_filename (input_bfd),
@@ -3525,7 +3535,10 @@ ppc_elf_relocate_section (output_bfd, info, input_bfd, input_section,
 
            BFD_ASSERT (sec != (asection *) 0);
            name = bfd_get_section_name (abfd, sec->output_section);
-           if (strcmp (name, ".sdata") == 0 || strcmp (name, ".sbss") == 0)
+           if (((strncmp (name, ".sdata", 6) == 0      
+                 && (name[6] == 0 || name[6] == '.'))
+                || (strncmp (name, ".sbss", 5) == 0
+                    && (name[5] == 0 || name[5] == '.'))))
              {
                reg = 13;
                addend -= (sdata->sym_hash->root.u.def.value
@@ -3533,8 +3546,8 @@ ppc_elf_relocate_section (output_bfd, info, input_bfd, input_section,
                           + sdata->sym_hash->root.u.def.section->output_offset);
              }
 
-           else if (strcmp (name, ".sdata2") == 0
-                    || strcmp (name, ".sbss2") == 0)
+           else if (strncmp (name, ".sdata2", 7) == 0
+                    || strncmp (name, ".sbss2", 6) == 0)
              {
                reg = 2;
                addend -= (sdata2->sym_hash->root.u.def.value
@@ -3837,3 +3850,24 @@ ppc_elf_grok_psinfo (abfd, note)
 #define elf_backend_reloc_type_class           ppc_elf_reloc_type_class
 
 #include "elf32-target.h"
+
+/* QNX support.  */
+#include "elf32-qnx.h"
+
+#undef TARGET_LITTLE_SYM 
+#define        TARGET_LITTLE_SYM               bfd_elf32_powerpcleqnx_vec
+#undef TARGET_LITTLE_NAME
+#define        TARGET_LITTLE_NAME              "elf32-powerpcle-nto"
+#undef TARGET_BIG_SYM
+#define        TARGET_BIG_SYM                  bfd_elf32_powerpcqnx_vec
+#undef TARGET_BIG_NAME
+#define        TARGET_BIG_NAME                 "elf32-powerpc-nto"
+
+#define        elf32_bed                       elf32_ppc_qnx_bed
+
+#include "elf32-target.h"
+
+#undef elf_backend_set_nonloadable_filepos
+#undef elf_backend_is_contained_by_filepos
+#undef elf_backend_copy_private_bfd_data_p
+#undef elf32_bed
This page took 0.025077 seconds and 4 git commands to generate.