* elf64-ppc.c (ppc_add_stub): Replace strcpy/strncpy with memcpy.
[deliverable/binutils-gdb.git] / bfd / elf64-ppc.c
index 6b17b2b7c63b2d8d2fd553e5a9a22717d9d77a96..9d798efc083229baaf377e868f0b1f9b3805bb98 100644 (file)
@@ -62,7 +62,7 @@ static boolean ppc64_elf_set_private_flags
 static boolean ppc64_elf_merge_private_bfd_data
   PARAMS ((bfd *, bfd *));
 static boolean ppc64_elf_section_from_shdr
-  PARAMS ((bfd *, Elf64_Internal_Shdr *, char *));
+  PARAMS ((bfd *, Elf64_Internal_Shdr *, const char *));
 
 
 /* The name of the dynamic interpreter.  This is put in the .interp
@@ -1736,7 +1736,7 @@ ppc64_elf_merge_private_bfd_data (ibfd, obfd)
        elf_elfheader (obfd)->e_flags &= ~EF_PPC_RELOCATABLE_LIB;
 
       /* The output is -mrelocatable iff it can't be -mrelocatable-lib,
-         but each input file is either -mrelocatable or -mrelocatable-lib.  */
+        but each input file is either -mrelocatable or -mrelocatable-lib.  */
       if (! (elf_elfheader (obfd)->e_flags & EF_PPC_RELOCATABLE_LIB)
          && (new_flags & (EF_PPC_RELOCATABLE_LIB | EF_PPC_RELOCATABLE))
          && (old_flags & (EF_PPC_RELOCATABLE_LIB | EF_PPC_RELOCATABLE)))
@@ -1775,7 +1775,7 @@ static boolean
 ppc64_elf_section_from_shdr (abfd, hdr, name)
      bfd *abfd;
      Elf64_Internal_Shdr *hdr;
-     char *name;
+     const char *name;
 {
   asection *newsect;
   flagword flags;
@@ -2413,16 +2413,18 @@ ppc_add_stub (stub_name, section, htab)
       stub_sec = htab->stub_group[link_sec->id].stub_sec;
       if (stub_sec == NULL)
        {
+         size_t namelen;
          bfd_size_type len;
          char *s_name;
 
-         len = strlen (link_sec->name) + sizeof (STUB_SUFFIX);
+         namelen = strlen (link_sec->name);
+         len = namelen + sizeof (STUB_SUFFIX);
          s_name = bfd_alloc (htab->stub_bfd, len);
          if (s_name == NULL)
            return NULL;
 
-         strcpy (s_name, link_sec->name);
-         strcpy (s_name + len - sizeof (STUB_SUFFIX), STUB_SUFFIX);
+         memcpy (s_name, link_sec->name, namelen);
+         memcpy (s_name + namelen, STUB_SUFFIX, sizeof (STUB_SUFFIX));
          stub_sec = (*htab->add_stub_section) (s_name, link_sec);
          if (stub_sec == NULL)
            return NULL;
@@ -2708,14 +2710,14 @@ ppc64_elf_check_relocs (abfd, info, sec, relocs)
        case R_PPC64_PLT32:
        case R_PPC64_PLT64:
          /* This symbol requires a procedure linkage table entry.  We
-             actually build the entry in adjust_dynamic_symbol,
-             because this might be a case of linking PIC code without
-             linking in any dynamic objects, in which case we don't
-             need to generate a procedure linkage table after all.  */
+            actually build the entry in adjust_dynamic_symbol,
+            because this might be a case of linking PIC code without
+            linking in any dynamic objects, in which case we don't
+            need to generate a procedure linkage table after all.  */
          if (h == NULL)
            {
              /* It does not make sense to have a procedure linkage
-                 table entry for a local symbol.  */
+                table entry for a local symbol.  */
              bfd_set_error (bfd_error_bad_value);
              return false;
            }
@@ -4594,7 +4596,8 @@ get_local_syms (input_bfd, htab)
             isym = local_syms, shndx = shndx_buf;
           esym < end_sy;
           esym++, isym++, shndx = (shndx ? shndx + 1 : NULL))
-       bfd_elf64_swap_symbol_in (input_bfd, esym, shndx, isym);
+       bfd_elf64_swap_symbol_in (input_bfd, (const PTR) esym,
+                                 (const PTR) shndx, isym);
 
       /* Now we can free the external symbols.  */
       free (shndx_buf);
@@ -5613,12 +5616,17 @@ ppc64_elf_relocate_section (output_bfd, info, input_bfd, input_section,
                  relocate = true;
                  if (r_type == R_PPC64_ADDR64 || r_type == R_PPC64_TOC)
                    {
-                     if (is_opd && h != NULL && info->shared)
+                     if (is_opd && h != NULL)
                        {
                          /* Lie about opd entries.  This case occurs
                             when building shared libraries and we
                             reference a function in another shared
-                            lib.  In that case we won't use the opd
+                            lib.  The same thing happens for a weak
+                            definition in an application that's
+                            overridden by a strong definition in a
+                            shared lib.  (I believe this is a generic
+                            bug in binutils handling of weak syms.)
+                            In these cases we won't use the opd
                             entry in this lib;  We ought to edit the
                             opd section to remove unused entries.  */
                          unresolved_reloc = false;
@@ -5876,7 +5884,7 @@ ppc64_elf_finish_dynamic_symbol (output_bfd, info, h, sym)
       Elf64_External_Rela *loc;
 
       /* This symbol has an entry in the procedure linkage table.  Set
-         it up.  */
+        it up.  */
 
       if (htab->splt == NULL
          || htab->srelplt == NULL
@@ -5903,7 +5911,7 @@ ppc64_elf_finish_dynamic_symbol (output_bfd, info, h, sym)
       Elf64_External_Rela *loc;
 
       /* This symbol has an entry in the global offset table.  Set it
-         up.  */
+        up.  */
 
       if (htab->sgot == NULL || htab->srelgot == NULL)
        abort ();
This page took 0.030114 seconds and 4 git commands to generate.