This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

PR13254


Applied.

include/
	PR ld/13254
	* bfdlink.h (struct bfd_link_info): Add error_textrel.
bfd/
	PR ld/13254
	* elflink.c (bfd_elf_final_link): Emit error_textrel error.
ld/
	PR ld/13254
	* emultempl/elf32.em (gld${EMULATION_NAME}_handle_option): Add
	-z text, -z notext, -z textoff options for all targets having
	shared lib support.

Index: include/bfdlink.h
===================================================================
RCS file: /cvs/src/src/include/bfdlink.h,v
retrieving revision 1.92
diff -u -p -r1.92 bfdlink.h
--- include/bfdlink.h	16 Sep 2011 01:15:19 -0000	1.92
+++ include/bfdlink.h	8 Oct 2011 10:02:32 -0000
@@ -337,6 +337,9 @@ struct bfd_link_info
   /* TRUE if we should warn when adding a DT_TEXTREL to a shared object.  */
   unsigned int warn_shared_textrel: 1;
 
+  /* TRUE if we should error when adding a DT_TEXTREL.  */
+  unsigned int error_textrel: 1;
+
   /* TRUE if .hash section should be created.  */
   unsigned int emit_hash: 1;
 
Index: bfd/elflink.c
===================================================================
RCS file: /cvs/src/src/bfd/elflink.c,v
retrieving revision 1.424
diff -u -p -r1.424 elflink.c
--- bfd/elflink.c	8 Oct 2011 07:50:19 -0000	1.424
+++ bfd/elflink.c	8 Oct 2011 10:01:43 -0000
@@ -11164,7 +11164,8 @@ bfd_elf_final_link (bfd *abfd, struct bf
 	goto error_return;
 
       /* Check for DT_TEXTREL (late, in case the backend removes it).  */
-      if (info->warn_shared_textrel && info->shared)
+      if ((info->warn_shared_textrel && info->shared)
+	  || info->error_textrel)
 	{
 	  bfd_byte *dyncon, *dynconend;
 
@@ -11182,8 +11183,12 @@ bfd_elf_final_link (bfd *abfd, struct bf
 
 	      if (dyn.d_tag == DT_TEXTREL)
 		{
-		 info->callbacks->einfo
-		    (_("%P: warning: creating a DT_TEXTREL in a shared object.\n"));
+		  if (info->error_textrel)
+		    info->callbacks->einfo
+		      (_("%P%X: read-only segment has dynamic relocations.\n"));
+		  else
+		    info->callbacks->einfo
+		      (_("%P: warning: creating a DT_TEXTREL in a shared object.\n"));
 		  break;
 		}
 	    }
Index: ld/emultempl/elf32.em
===================================================================
RCS file: /cvs/src/src/ld/emultempl/elf32.em,v
retrieving revision 1.223
diff -u -p -r1.223 elf32.em
--- ld/emultempl/elf32.em	16 Sep 2011 01:15:19 -0000	1.223
+++ ld/emultempl/elf32.em	8 Oct 2011 10:02:34 -0000
@@ -2327,6 +2327,12 @@ fragment <<EOF
 	link_info.relro = TRUE;
       else if (strcmp (optarg, "norelro") == 0)
 	link_info.relro = FALSE;
+      else if (strcmp (optarg, "text") == 0)
+	link_info.error_textrel = TRUE;
+      else if (strcmp (optarg, "notext") == 0)
+	link_info.error_textrel = FALSE;
+      else if (strcmp (optarg, "textoff") == 0)
+	link_info.error_textrel = FALSE;
 EOF
 fi
 

-- 
Alan Modra
Australia Development Lab, IBM


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]