bfd/
[binutils-gdb.git] / ld / plugin.c
index db31596cce6132e2eaf7be82ea7acb03a48c84b7..b285787694b724ad8ea5b23d3074afe2ec159635 100644 (file)
@@ -1,5 +1,5 @@
 /* Plugin control for the GNU linker.
-   Copyright 2010 Free Software Foundation, Inc.
+   Copyright 2010, 2011 Free Software Foundation, Inc.
 
    This file is part of the GNU Binutils.
 
@@ -237,6 +237,8 @@ plugin_get_ir_dummy_bfd (const char *name, bfd *srctemplate)
                     srctemplate);
   bfd_set_arch_info (abfd, bfd_get_arch_info (srctemplate));
   bfd_make_writable (abfd);
+  bfd_copy_private_bfd_data (srctemplate, abfd);
+  bfd_set_gp_size (abfd, bfd_get_gp_size (abfd));
   /* Create a minimal set of sections to own the symbols.  */
   sec = bfd_make_section_old_way (abfd, ".text");
   bfd_set_section_flags (abfd, sec,
@@ -511,7 +513,8 @@ get_symbols (const void *handle, int nsyms, struct ld_plugin_symbol *syms)
                                  : LDPR_PREVAILING_DEF);
          else if (is_ir_dummy_bfd (owner_sec->owner))
            syms[n].resolution = LDPR_RESOLVED_IR;
-         else if (owner_sec->owner->flags & DYNAMIC)
+         else if (owner_sec->owner != NULL
+                  && (owner_sec->owner->flags & DYNAMIC) != 0)
            syms[n].resolution =  LDPR_RESOLVED_DYN;
          else
            syms[n].resolution = LDPR_RESOLVED_EXEC;
@@ -582,9 +585,11 @@ message (int level, const char *format, ...)
     {
     case LDPL_INFO:
       vfinfo (stdout, format, args, FALSE);
+      putchar ('\n');
       break;
     case LDPL_WARNING:
       vfinfo (stdout, format, args, TRUE);
+      putchar ('\n');
       break;
     case LDPL_FATAL:
     case LDPL_ERROR:
@@ -593,13 +598,13 @@ message (int level, const char *format, ...)
          char *newfmt = ACONCAT ((level == LDPL_FATAL
                                   ? "%P%F: " : "%P%X: ",
                                   format, "\n", NULL));
+         fflush (stdout);
          vfinfo (stderr, newfmt, args, TRUE);
+         fflush (stderr);
        }
       break;
     }
 
-  putchar('\n');
-
   va_end (args);
   return LDPS_OK;
 }