ld -r breakage

Alan Modra alan@linuxcare.com.au
Mon Jun 12 02:45:00 GMT 2000


On Mon, 12 Jun 2000, Jakub Jelinek wrote:

> ld -r no longer preserves SEC_READONLY attribute for some sections.

I suspect it's this patch (presumably for correct -N operation)

2000-05-22  Igor Shevlyakov  <igor@windriver.com>

	* ldmain.c (main): When deciding if ".text" section should be
        read-only, don't forget to reset SEC_READONLY because it
        could be already set.

This will fix it

2000-06-12  Alan Modra  <alan@linuxcare.com.au>

	* ldmain.c (main): Only change .text SEC_READONLY for final link.

Index: ldmain.c
===================================================================
RCS file: /cvs/src/src/ld/ldmain.c,v
retrieving revision 1.7
diff -u -p -r1.7 ldmain.c
--- ldmain.c	2000/05/26 13:11:57	1.7
+++ ldmain.c	2000/06/12 09:40:03
@@ -349,17 +349,18 @@ main (argc, argv)
      symbols, and possibly multiple definitions */
 
   /* Look for a text section and switch the readonly attribute in it.  */
-  {
-    asection * found = bfd_get_section_by_name (output_bfd, ".text");
+  if (!link_info.relocateable)
+    {
+      asection * found = bfd_get_section_by_name (output_bfd, ".text");
     
-    if (found != (asection *) NULL)
-      {
-	if (config.text_read_only)
-	  found->flags |= SEC_READONLY;
-	else
-	  found->flags &= ~SEC_READONLY;
-      }
-  }
+      if (found != (asection *) NULL)
+	{
+	  if (config.text_read_only)
+	    found->flags |= SEC_READONLY;
+	  else
+	    found->flags &= ~SEC_READONLY;
+	}
+    }
 
   if (link_info.relocateable)
     output_bfd->flags &= ~EXEC_P;

-- 
Linuxcare.  Support for the Revolution.



More information about the Binutils mailing list