Only give FDE encoding warnings if --eh-frame-hdr was specified.

Message ID d4e0b81e-7746-352d-7fd1-85eaf9848031@codesourcery.com
State New
Headers show
Series
  • Only give FDE encoding warnings if --eh-frame-hdr was specified.
Related show

Commit Message

Sandra Loosemore Dec. 3, 2019, 4:18 a.m.
This is an updated version of a patch I previously posted N years ago. 
It was approved back then, but for some reason I neglected to commit it 
at the time, and then forgot about it.  :-(

https://sourceware.org/ml/binutils/2013-01/msg00333.html

The problem I'm trying to fix is that nios2 doesn't have appropriate 
relocations to support --eh-frame-hdr in conjunction with -fpie or 
-fPIE, and these warnings about the FDE encoding presently appear even 
when --eh-frame-hdr is not enabled.

The new patch is the same fix as the old one, just updated for bit rot. 
Unless I hear some objection or hit some other snag, I plan to commit it 
(along with the associated GCC specs patch to disable passing 
--eh-frame-hdr with PIE) in a couple days, when I've completed testing. 
This time for sure!  ;-)

-Sandra

Comments

Alan Modra Dec. 6, 2019, 7:27 a.m. | #1
For mips*-linux targets, fixes the following fails.
FAIL: MIPS eh-frame 1, n32
FAIL: MIPS eh-frame 1, n64
FAIL: MIPS eh-frame 2, n32
FAIL: MIPS eh-frame 2, n64

	* testsuite/ld-mips-elf/eh-frame1-n32.d: Pass --eh-frame-hdr to ld.
	* testsuite/ld-mips-elf/eh-frame1-n64.d: Likewise.
	* testsuite/ld-mips-elf/eh-frame2-n32.d: Likewise.
	* testsuite/ld-mips-elf/eh-frame2-n64.d: Likewise.

diff --git a/ld/testsuite/ld-mips-elf/eh-frame1-n32.d b/ld/testsuite/ld-mips-elf/eh-frame1-n32.d
index 9e1a0d633a..547739179a 100644
--- a/ld/testsuite/ld-mips-elf/eh-frame1-n32.d
+++ b/ld/testsuite/ld-mips-elf/eh-frame1-n32.d
@@ -3,7 +3,7 @@
 #source: eh-frame1.s
 #as: --defsym alignment=2 --defsym fill=0x40
 #readelf: --relocs -wf
-#ld: -shared -Teh-frame1.ld
+#ld: -shared --eh-frame-hdr -Teh-frame1.ld
 #warning: FDE encoding in.*prevents \.eh_frame_hdr table being created.
 
 Relocation section '\.rel\.dyn' .*:
diff --git a/ld/testsuite/ld-mips-elf/eh-frame1-n64.d b/ld/testsuite/ld-mips-elf/eh-frame1-n64.d
index b1b7d9d31d..a6d4f92519 100644
--- a/ld/testsuite/ld-mips-elf/eh-frame1-n64.d
+++ b/ld/testsuite/ld-mips-elf/eh-frame1-n64.d
@@ -3,7 +3,7 @@
 #source: eh-frame1.s
 #as: --defsym alignment=3 --defsym fill=0x40
 #readelf: --relocs -wf
-#ld: -shared -Teh-frame1.ld
+#ld: -shared --eh-frame-hdr -Teh-frame1.ld
 #warning: FDE encoding in.*prevents \.eh_frame_hdr table being created.
 
 Relocation section '\.rel\.dyn' .*:
diff --git a/ld/testsuite/ld-mips-elf/eh-frame2-n32.d b/ld/testsuite/ld-mips-elf/eh-frame2-n32.d
index 556ef6cf59..d7def348dd 100644
--- a/ld/testsuite/ld-mips-elf/eh-frame2-n32.d
+++ b/ld/testsuite/ld-mips-elf/eh-frame2-n32.d
@@ -3,7 +3,7 @@
 #source: eh-frame1.s
 #as: --defsym alignment=2 --defsym fill=0
 #readelf: --relocs -wf
-#ld: -shared -Teh-frame1.ld
+#ld: -shared --eh-frame-hdr -Teh-frame1.ld
 #warning: FDE encoding in.*prevents \.eh_frame_hdr table being created.
 
 Relocation section '\.rel\.dyn' .*:
diff --git a/ld/testsuite/ld-mips-elf/eh-frame2-n64.d b/ld/testsuite/ld-mips-elf/eh-frame2-n64.d
index b43664f19c..300b41e782 100644
--- a/ld/testsuite/ld-mips-elf/eh-frame2-n64.d
+++ b/ld/testsuite/ld-mips-elf/eh-frame2-n64.d
@@ -3,7 +3,7 @@
 #source: eh-frame1.s
 #as: --defsym alignment=3 --defsym fill=0
 #readelf: --relocs -wf
-#ld: -shared -Teh-frame1.ld
+#ld: -shared --eh-frame-hdr -Teh-frame1.ld
 #warning: FDE encoding in.*prevents \.eh_frame_hdr table being created.
 
 Relocation section '\.rel\.dyn' .*:

-- 
Alan Modra
Australia Development Lab, IBM

Patch

commit 550485f5df467b668f1551ab6701d2e53f21734c
Author: Sandra Loosemore <sandra@codesourcery.com>
Date:   Mon Dec 2 19:54:39 2019 -0800

    Only give FDE encoding warnings if --eh-frame-hdr was specified.
    
    2019-12-02  Sandra Loosemore  <sandra@codesourcery.com>
    
    	Only give FDE encoding warnings if --eh-frame-hdr was specified.
    
    	bfd/
    	* elf-eh-frame.c (_bfd_elf_discard_section_eh_frame): Make
    	FDE encoding warning conditional.

diff --git a/ChangeLog b/ChangeLog
index 8c60466..6ded878 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@ 
+2019-12-02  Sandra Loosemore  <sandra@codesourcery.com>
+
+	Only give FDE encoding warnings if --eh-frame-hdr was specified.
+
+	* elf-eh-frame.c (_bfd_elf_discard_section_eh_frame): Make
+	FDE encoding warning conditional.
+
 2019-10-17  Sergio Durigan Junior  <sergiodj@redhat.com>
 
 	* src-release.sh (GDB_SUPPORT_DIRS): Add libctf.
diff --git a/bfd/elf-eh-frame.c b/bfd/elf-eh-frame.c
index c2cb77b..b622ffc 100644
--- a/bfd/elf-eh-frame.c
+++ b/bfd/elf-eh-frame.c
@@ -1532,19 +1532,23 @@  _bfd_elf_discard_section_eh_frame
 		   don't create the binary search table,
 		   since it is affected by runtime relocations.  */
 		hdr_info->u.dwarf.table = FALSE;
-		if (num_warnings_issued < 10)
+		/* Only warn if --eh-frame-hdr was specified.  */
+		if (info->eh_frame_hdr_type != 0)
 		  {
-		    _bfd_error_handler
-		      /* xgettext:c-format */
-		      (_("FDE encoding in %pB(%pA) prevents .eh_frame_hdr"
-			 " table being created"), abfd, sec);
-		    num_warnings_issued ++;
-		  }
-		else if (num_warnings_issued == 10)
-		  {
-		    _bfd_error_handler
-		      (_("further warnings about FDE encoding preventing .eh_frame_hdr generation dropped"));
-		    num_warnings_issued ++;
+		    if (num_warnings_issued < 10)
+		      {
+			_bfd_error_handler
+			  /* xgettext:c-format */
+			  (_("FDE encoding in %pB(%pA) prevents .eh_frame_hdr"
+			     " table being created"), abfd, sec);
+			num_warnings_issued ++;
+		      }
+		    else if (num_warnings_issued == 10)
+		      {
+			_bfd_error_handler
+			  (_("further warnings about FDE encoding preventing .eh_frame_hdr generation dropped"));
+			num_warnings_issued ++;
+		      }
 		  }
 	      }
 	    ent->removed = 0;