Correctly set SEC_READONLY for .text section.
authorAlan Modra <amodra@gmail.com>
Thu, 15 Jun 2000 09:09:13 +0000 (09:09 +0000)
committerAlan Modra <amodra@gmail.com>
Thu, 15 Jun 2000 09:09:13 +0000 (09:09 +0000)
ld/ChangeLog
ld/ldmain.c

index 2331bd3..bcbc7e0 100644 (file)
@@ -1,3 +1,7 @@
+2000-06-15  Alan Modra  <alan@linuxcare.com.au>
+
+       * ldmain.c (main): Only change SEC_READONLY for final link.
+
 2000-06-13  H.J. Lu  <hjl@gnu.org>
 
        * configure: Regenerate.
@@ -10152,7 +10156,7 @@ Fri Oct 11 15:43:04 1991  Roland H. Pesch  (pesch at cygnus.com)
 Fri Oct 11 13:51:54 1991  Per Bothner  (bothner at cygnus.com)
 
        * ldmain.c (main): Make config.magic_demand_paged be true
-       by default.  Don't the WP_TEXT and D_PAGED flags of
+       by default.  Don't set the WP_TEXT and D_PAGED flags of
        output_bfd here; it's too late, so set it when output_bfd
        is created (in ldlang.c).  Also fix setting of EXEC_P flag
        * ldlang.c (ldlang_open_output):  Set output_bfd->flags here.
index 48f35ef..9cb55ed 100644 (file)
@@ -348,18 +348,19 @@ main (argc, argv)
   /* Print error messages for any missing symbols, for any warning
      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)
+    {
+      /* Look for a text section and switch the readonly attribute in it.  */
+      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;