]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
ld: Fix LTO for MinGW targets
authorKwok Cheung Yeung <kcy@codesourcery.com>
Thu, 10 Dec 2015 16:11:07 +0000 (16:11 +0000)
committerKwok Cheung Yeung <kcy@codesourcery.com>
Mon, 11 Jan 2016 13:50:17 +0000 (13:50 +0000)
When creating a dummy BFD for an IR file, the output BFD is used as
a template for the new BFD, when it needs to be the input BFD passed
into the function when not dealing with a BFD plugin.

On most targets this is not an issue as the input and output formats
are the same anyway, but on MinGW targets, there are two variant
formats used (pe-i386/pe-x86-64 and pei-i386/pei-x86-64) which are
similar but not interchangeable here.

PR ld/18199
* plugin.c (plugin_get_ir_dummy_bfd): Use srctemplate as the
template when calling bfd_create if it does not use the BFD
plugin target vector.

(Cherry-picked from commit 4a07dc81356ed8728e204e9aabeb256703c59aef)

ld/ChangeLog
ld/plugin.c

index 63ae72a0324d31c07e5556e80d9effd0b09aec81..cc7474dd61f0c52c3182369ecf8c6908251b8ccb 100644 (file)
@@ -1,3 +1,10 @@
+2016-01-11  Kwok Cheung Yeung  <kcy@codesourcery.com>
+
+       PR ld/18199
+       * plugin.c (plugin_get_ir_dummy_bfd): Use srctemplate as the
+       template when calling bfd_create if it does not use the BFD
+       plugin target vector.
+
 2015-12-10  Alan Modra  <amodra@gmail.com>
 
        Apply from master.
index 8e53255ecd485dc59e4be392deecc54bb85e7bfc..b0e2a5f7a70764a0c359d35e1ae86b3504be9f62 100644 (file)
@@ -295,16 +295,18 @@ static bfd *
 plugin_get_ir_dummy_bfd (const char *name, bfd *srctemplate)
 {
   bfd *abfd;
+  bfd_boolean bfd_plugin_target;
 
   bfd_use_reserved_id = 1;
+  bfd_plugin_target = bfd_plugin_target_p (srctemplate->xvec);
   abfd = bfd_create (concat (name, IRONLY_SUFFIX, (const char *) NULL),
-                    link_info.output_bfd);
+                    bfd_plugin_target ? link_info.output_bfd : srctemplate);
   if (abfd != NULL)
     {
       abfd->flags |= BFD_LINKER_CREATED | BFD_PLUGIN;
       if (!bfd_make_writable (abfd))
        goto report_error;
-      if (! bfd_plugin_target_p (srctemplate->xvec))
+      if (!bfd_plugin_target)
        {
          bfd_set_arch_info (abfd, bfd_get_arch_info (srctemplate));
          bfd_set_gp_size (abfd, bfd_get_gp_size (srctemplate));