Don't set link_info.executable for "ld -r"
authorH.J. Lu <hjl.tools@gmail.com>
Wed, 29 Jul 2015 16:11:15 +0000 (09:11 -0700)
committerH.J. Lu <hjl.tools@gmail.com>
Wed, 29 Jul 2015 16:14:05 +0000 (09:14 -0700)
This patch changes "ld -r" not to set link_info.executable.  It
removes !info->relocatable check for info->executable and adds it
for !info->executable in elflink.c.

bfd/

* elflink.c (elf_link_add_object_symbols): Remove
!info->relocatable check for info->executable.  Add
!info->relocatable check for !info->executable.
(elf_link_output_extsym): Remove
!info->relocatable check for info->executable.

ld/

* lexsup.c (parse_args): Don't set link_info.executable to
TRUE for link_info.relocatable.

bfd/ChangeLog
bfd/elflink.c
ld/ChangeLog
ld/lexsup.c

index fd17ed6ed881f1798d97669a3e72694f7f41a7cc..e3339d0ba41918cc0de56ebbd57d083b24bae78b 100644 (file)
@@ -1,3 +1,11 @@
+2015-07-29  H.J. Lu  <hongjiu.lu@intel.com>
+
+       * elflink.c (elf_link_add_object_symbols): Remove
+       !info->relocatable check for info->executable.  Add
+       !info->relocatable check for !info->executable.
+       (elf_link_output_extsym): Remove
+       !info->relocatable check for info->executable.
+
 2015-07-29  Hans-Peter Nilsson  <hp@bitrange.com>
 
        * mmo.c (mmo_write_symbols_and_terminator): Skip symbol-type
index ccb7ba23a34dead7c313db1793e5b3c534f737af..fc1fd087bb7258ab46380fe09a99dedf71aa68d5 100644 (file)
@@ -3488,7 +3488,7 @@ elf_link_add_object_symbols (bfd *abfd, struct bfd_link_info *info)
                  FALSE, bed->collect, NULL)))
            goto error_return;
 
-         if (!info->relocatable && info->executable)
+         if (info->executable)
            {
              /* Clobber the section size so that the warning does
                 not get copied into the output file.  */
@@ -4257,7 +4257,7 @@ error_free_dyn:
              /* If the indirect symbol has been forced local, don't
                 make the real symbol dynamic.  */
              if ((h == hi || !hi->forced_local)
-                 && (! info->executable
+                 && ((! info->executable && ! info->relocatable)
                      || h->def_dynamic
                      || h->ref_dynamic))
                dynsym = TRUE;
@@ -8957,8 +8957,7 @@ elf_link_output_extsym (struct bfd_hash_entry *bh, void *data)
 
   /* We should also warn if a forced local symbol is referenced from
      shared libraries.  */
-  if (!flinfo->info->relocatable
-      && flinfo->info->executable
+  if (flinfo->info->executable
       && h->forced_local
       && h->ref_dynamic
       && h->def_regular
index 3f53f13ec3de9fd0a47087dc41d865a1e68b8de8..d1b819bc12816112e5c693bb17b01ca97ab128e8 100644 (file)
@@ -1,3 +1,8 @@
+2015-07-29  H.J. Lu  <hongjiu.lu@intel.com>
+
+       * lexsup.c (parse_args): Don't set link_info.executable to
+       TRUE for link_info.relocatable.
+
 2015-07-27  H.J. Lu  <hongjiu.lu@intel.com>
 
        * configure: Regenerated.
index b884d9a77f84224728955a806ffe9605eb86ac33..0aa67f532b97b5bf0b2650167191ab6e2c8962c2 100644 (file)
@@ -1578,7 +1578,7 @@ parse_args (unsigned argc, char **argv)
        einfo (_("%P%F: -f may not be used without -shared\n"));
     }
 
-  if (! link_info.shared || link_info.pie)
+  if ((! link_info.shared && ! link_info.relocatable) || link_info.pie)
     link_info.executable = TRUE;
 
   /* Treat ld -r -s as ld -r -S -x (i.e., strip all local symbols).  I