[committed, PATCH] Don't set link_info.executable for "ld -r"

H.J. Lu hongjiu.lu@intel.com
Wed Jul 29 16:15:00 GMT 2015


It is odd to set link_info.executable for "ld -r".  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.
Other formats may need similar updates.

H.J.
--
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 | 8 ++++++++
 bfd/elflink.c | 7 +++----
 ld/ChangeLog  | 5 +++++
 ld/lexsup.c   | 2 +-
 4 files changed, 17 insertions(+), 5 deletions(-)

diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index fd17ed6..e3339d0 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -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
diff --git a/bfd/elflink.c b/bfd/elflink.c
index ccb7ba2..fc1fd08 100644
--- a/bfd/elflink.c
+++ b/bfd/elflink.c
@@ -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
diff --git a/ld/ChangeLog b/ld/ChangeLog
index 3f53f13..d1b819b 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -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.
diff --git a/ld/lexsup.c b/ld/lexsup.c
index b884d9a..0aa67f5 100644
--- a/ld/lexsup.c
+++ b/ld/lexsup.c
@@ -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
-- 
2.4.3



More information about the Binutils mailing list