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]

PATCH: PR ld/4304: ld --fatal-warnings doesn't work


There is no way for bfd to pass if warning is generated to linker. This
patch adds a warned field to bfd_link_info so that bfd can set it
for linker to check.


H.J.
---
bfd/

2007-04-05  H.J. Lu  <hongjiu.lu@intel.com>

	PR ld/4304
	* elflink.c (bfd_elf_final_link): Set the warned field in
	bfd_link_info to TRUE after issuing a warning for DT_TEXTREL.

include/

2007-04-05  H.J. Lu  <hongjiu.lu@intel.com>

	PR ld/4304
	* bfdlink.h (bfd_elf_final_link): Add warned.

ld/

2007-04-05  H.J. Lu  <hongjiu.lu@intel.com>

	PR ld/4304
	* ldmain.c (main): Initialize link_info.warned to FALSE.  Set
	config.make_executable to FALSE if both link_info.warned
	and config.fatal_warnings are TRUE.

ld/testsuite/

2007-04-05  H.J. Lu  <hongjiu.lu@intel.com>

	PR ld/4304
	* ld-i386/i386.exp: Run "warn1".

	* ld-i386/warn1.d: New file.
	* ld-i386/warn1.s: Likewise.

--- binutils/bfd/elflink.c.warn	2007-04-04 22:48:41.000000000 -0700
+++ binutils/bfd/elflink.c	2007-04-04 23:21:48.000000000 -0700
@@ -10030,6 +10030,7 @@ bfd_elf_final_link (bfd *abfd, struct bf
 		{
 		  _bfd_error_handler
 		    (_("warning: creating a DT_TEXTREL in a shared object."));
+		  info->warned = TRUE;
 		  break;
 		}
 	    }
--- binutils/include/bfdlink.h.warn	2007-04-04 22:48:41.000000000 -0700
+++ binutils/include/bfdlink.h	2007-04-05 06:36:17.000000000 -0700
@@ -323,6 +323,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 warning messages are generated.  */
+  unsigned int warned: 1;
+
   /* TRUE if unreferenced sections should be removed.  */
   unsigned int gc_sections: 1;
 
--- binutils/ld/ldmain.c.warn	2007-04-04 22:48:41.000000000 -0700
+++ binutils/ld/ldmain.c	2007-04-04 22:48:41.000000000 -0700
@@ -325,6 +325,7 @@ main (int argc, char **argv)
   link_info.flags_1 = 0;
   link_info.relax_pass = 1;
   link_info.warn_shared_textrel = FALSE;
+  link_info.warned = FALSE;
   link_info.gc_sections = FALSE;
   link_info.print_gc_sections = FALSE;
   link_info.dynamic = FALSE;
@@ -576,6 +577,9 @@ main (int argc, char **argv)
 
   lang_finish ();
 
+  if (link_info.warned && config.fatal_warnings)
+    config.make_executable = FALSE;
+
   /* Even if we're producing relocatable output, some non-fatal errors should
      be reported in the exit status.  (What non-fatal errors, if any, do we
      want to ignore for relocatable output?)  */
--- binutils/ld/testsuite/ld-i386/i386.exp.warn	2007-03-22 08:55:15.000000000 -0700
+++ binutils/ld/testsuite/ld-i386/i386.exp	2007-04-04 23:16:07.000000000 -0700
@@ -115,3 +115,4 @@ run_dump_test "pcrel8"
 run_dump_test "pcrel16"
 run_dump_test "pcrel16abs"
 run_dump_test "alloc"
+run_dump_test "warn1"
--- binutils/ld/testsuite/ld-i386/warn1.d.warn	2007-04-04 23:16:26.000000000 -0700
+++ binutils/ld/testsuite/ld-i386/warn1.d	2007-04-05 06:28:57.000000000 -0700
@@ -0,0 +1,4 @@
+#name: --warn-shared-textrel --fatal-warnings
+#as: --32
+#ld: -shared -melf_i386 --warn-shared-textrel --fatal-warnings
+#error: .*warning: creating a DT_TEXTREL in a shared object
--- binutils/ld/testsuite/ld-i386/warn1.s.warn	2007-04-04 23:16:15.000000000 -0700
+++ binutils/ld/testsuite/ld-i386/warn1.s	2007-04-04 23:15:23.000000000 -0700
@@ -0,0 +1,5 @@
+	.text
+	.globl foo
+	.type	foo, @function
+foo:
+	movl	bar, %eax


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