Imported Upstream version 7.9
[platform/upstream/gdb.git] / bfd / coff-ppc.c
index cf173a2..237980d 100644 (file)
@@ -1,5 +1,5 @@
 /* BFD back-end for PowerPC Microsoft Portable Executable files.
-   Copyright (C) 1990-2014 Free Software Foundation, Inc.
+   Copyright (C) 1990-2015 Free Software Foundation, Inc.
 
    Original version pieced together by Kim Knuttila (krk@cygnus.com)
 
@@ -1073,10 +1073,11 @@ coff_ppc_relocate_section (bfd *output_bfd,
              {
                /* It is a file local symbol.  */
                int *local_toc_table;
-               const char *name;
+               char name[SYMNMLEN + 1];
 
                sym = syms + symndx;
-               name = sym->_n._n_name;
+               strncpy (name, sym->_n._n_name, SYMNMLEN);
+               name[SYMNMLEN] = '\0';
 
                local_toc_table = obj_coff_local_toc_table(input_bfd);
                our_toc_offset = local_toc_table[symndx];
@@ -1225,9 +1226,14 @@ coff_ppc_relocate_section (bfd *output_bfd,
        case IMAGE_REL_PPC_ABSOLUTE:
          {
            const char *my_name;
+           char buf[SYMNMLEN + 1];
 
            if (h == 0)
-             my_name = (syms+symndx)->_n._n_name;
+             {
+               strncpy (buf, (syms+symndx)->_n._n_name, SYMNMLEN);
+               buf[SYMNMLEN] = '\0';
+               my_name = buf;
+             }
            else
              my_name = h->root.root.root.string;
 
@@ -1288,11 +1294,8 @@ coff_ppc_relocate_section (bfd *output_bfd,
              }
 
            if (h == 0)
-             {
-               /* It is a file local symbol.  */
-               sym = syms + symndx;
-               name = sym->_n._n_name;
-             }
+             /* It is a file local symbol.  */
+             sym = syms + symndx;
            else
              {
                char *target = 0;
@@ -2149,7 +2152,7 @@ ppc_bfd_coff_final_link (bfd *abfd, struct bfd_link_info *info)
      the opportunity to clear the output_has_begun fields of all the
      input BFD's.  */
   max_sym_count = 0;
-  for (sub = info->input_bfds; sub != NULL; sub = sub->link_next)
+  for (sub = info->input_bfds; sub != NULL; sub = sub->link.next)
     {
       bfd_size_type sz;