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]

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


On Thu, Apr 05, 2007 at 08:49:26AM -0700, H. J. Lu wrote:
> On Thu, Apr 05, 2007 at 06:37:35AM -0700, H. J. Lu wrote:
> > 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.
> > 
> > 
> 
> The fix is quite simple. We just need to use einfo callback instead
> of _bfd_error_handler for DT_TEXTREL warning. I will check it in
> as an obvious fix.
> 

This is the patch I am checking in. The old linker gives

bash-3.1$ make LD=ld
gcc -c -m32 -o 32.o foo.c
ld -shared -melf_i386 --warn-shared-textrel --fatal-warnings -o 32.so
32.o
ld: warning: creating a DT_TEXTREL in a shared object.
bash-3.1$ 

The new linker gives

bash-3.1$ make
gcc -c -m32 -o 32.o foo.c
./ld -shared -melf_i386 --warn-shared-textrel --fatal-warnings -o 32.so
32.o
./ld: warning: creating a DT_TEXTREL in a shared object.
make: *** [32.so] Error 1


H.J.
---
bfd/

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

	PR ld/4304
	* elflink.c (bfd_elf_final_link): Call einfo callback in
	bfd_link_info instead of _bfd_error_handler for DT_TEXTREL
	warning.

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-05 08:50:08.000000000 -0700
+++ binutils/bfd/elflink.c	2007-04-05 09:03:29.000000000 -0700
@@ -10028,8 +10028,8 @@ bfd_elf_final_link (bfd *abfd, struct bf
 
 	      if (dyn.d_tag == DT_TEXTREL)
 		{
-		  _bfd_error_handler
-		    (_("warning: creating a DT_TEXTREL in a shared object."));
+		 info->callbacks->einfo 
+		    (_("%P: warning: creating a DT_TEXTREL in a shared object.\n"));
 		  break;
 		}
 	    }
--- 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-05 08:50:08.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-05 08:50:08.000000000 -0700
+++ binutils/ld/testsuite/ld-i386/warn1.d	2007-04-05 09:07:12.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-05 08:50:08.000000000 -0700
+++ binutils/ld/testsuite/ld-i386/warn1.s	2007-04-05 08:50:08.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]