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]

eh_frame_hdr with no sorted fde table


The table indexing FDEs in eh_frame_hdr is rather critical to good
exception handling performance.  Particularly so since glibc doesn't
itself create a sorted table for shared libs having .eh_frame_hdr, as
it does for libs that use the older eh registration scheme (glibc
bug?).  This makes ld warn if the .eh_frame_hdr table won't be created
for some reason.  I was tempted to make it an error rather than a
warning.  What do you think, Jakub?

bfd/
	* elf-eh-frame.c (_bfd_elf_discard_section_eh_frame): Warn if
	eh_frame_hdr table won't be created.
ld/testsuite/
	* ld-linkonce/x.s: Use .gcc_except_table instead of .eh_frame
	to test that entry for deleted function is zeroed.  Add a
	somewhat closer to normal .eh_frame to test that fde for
	deleted function is removed.
	* ld-linkonce/y.s: Likewise.
	* ld-linkonce/zeroeh.ld: Place .gcc_except_table too.
	* ld-linkonce/zeroehl32.d: Update.

Index: bfd/elf-eh-frame.c
===================================================================
RCS file: /cvs/src/src/bfd/elf-eh-frame.c,v
retrieving revision 1.54
diff -u -p -r1.54 elf-eh-frame.c
--- bfd/elf-eh-frame.c	4 Jan 2007 13:30:39 -0000	1.54
+++ bfd/elf-eh-frame.c	24 Apr 2007 03:41:54 -0000
@@ -786,6 +786,9 @@ _bfd_elf_discard_section_eh_frame
 		     don't create the binary search table,
 		     since it is affected by runtime relocations.  */
 		  hdr_info->table = FALSE;
+		  (*info->callbacks->einfo)
+		    (_("%P: fde encoding in %B(%A) prevents .eh_frame_hdr"
+		       " table being created.\n"), abfd, sec);
 		}
 	      ecie->usage_count++;
 	      hdr_info->fde_count++;
@@ -934,6 +937,9 @@ _bfd_elf_discard_section_eh_frame
   return offset != sec->rawsize;
 
 free_no_table:
+  (*info->callbacks->einfo)
+    (_("%P: error in %B(%A); no .eh_frame_hdr table will be created.\n"),
+     abfd, sec);
   if (ehbuf)
     free (ehbuf);
   if (sec_info)
Index: ld/testsuite/ld-linkonce/x.s
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-linkonce/x.s,v
retrieving revision 1.1
diff -u -p -r1.1 x.s
--- ld/testsuite/ld-linkonce/x.s	29 Sep 2001 13:01:16 -0000	1.1
+++ ld/testsuite/ld-linkonce/x.s	24 Apr 2007 03:42:20 -0000
@@ -1,8 +1,7 @@
 ;# Main file, x.s, with the program (_start) referring to two
 ;# linkonce functions fn and fn2.  The functions fn and fn2 are
 ;# supposed to be equivalent of C++ template instantiations; the
-;# main file instantiates fn.  There's the equivalent of an FDE
-;# entry in .eh_frame, referring to fn via a local label.
+;# main file instantiates fn.
 
  .text
  .global _start
@@ -20,7 +19,29 @@ fn:
 .Lb:
  .size fn,.Lb-.La
 
- .section .eh_frame,"aw",@progbits
+ .section .gcc_except_table,"aw",@progbits
  .long 2
  .long .La
  .long .Lb-.La
+
+ .section .eh_frame,"aw",@progbits
+.Lframe1:
+ .long .LECIE1-.LSCIE1
+.LSCIE1:
+ .long 0x0
+ .byte 0x1
+ .byte 0
+ .uleb128 0x1
+ .sleb128 -4
+ .byte 0
+ .p2align 2
+.LECIE1:
+
+.LSFDE1:
+ .long .LEFDE1-.LASFDE1
+.LASFDE1:
+ .long .LASFDE1-.Lframe1
+ .long .La
+ .long .Lb-.La
+ .p2align 2
+.LEFDE1:
Index: ld/testsuite/ld-linkonce/y.s
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-linkonce/y.s,v
retrieving revision 1.1
diff -u -p -r1.1 y.s
--- ld/testsuite/ld-linkonce/y.s	29 Sep 2001 13:01:16 -0000	1.1
+++ ld/testsuite/ld-linkonce/y.s	24 Apr 2007 03:42:20 -0000
@@ -2,7 +2,7 @@
 ;# that this version of fn has different code, as if compiled
 ;# with different optimization flags than the one in x.s (not
 ;# important for this test, though).  The reference from
-;# .eh_frame to the linkonce-excluded fn2 must be zero, or g++
+;# .gcc_except_table to the linkonce-excluded fn2 must be zero, or g++
 ;# EH will not work.
 
  .section .gnu.linkonce.t.fn2,"ax",@progbits
@@ -23,7 +23,7 @@ fn:
 .Lf:
  .size fn,.Lf-.Le
 
- .section .eh_frame,"aw",@progbits
+ .section .gcc_except_table,"aw",@progbits
  .long 7
  .long .Lc
  .long .Ld-.Lc
@@ -31,3 +31,34 @@ fn:
  .long 0x6066
  .long .Le
  .long .Lf-.Le
+
+ .section .eh_frame,"aw",@progbits
+.Lframe1:
+ .long .LECIE1-.LSCIE1
+.LSCIE1:
+ .long 0x0
+ .byte 0x1
+ .byte 0
+ .uleb128 0x1
+ .sleb128 -4
+ .byte 0
+ .p2align 2
+.LECIE1:
+
+.LSFDE1:
+ .long .LEFDE1-.LASFDE1
+.LASFDE1:
+ .long .LASFDE1-.Lframe1
+ .long .Lc
+ .long .Ld-.Lc
+ .p2align 2
+.LEFDE1:
+
+.LSFDE2:
+ .long .LEFDE2-.LASFDE2
+.LASFDE2:
+ .long .LASFDE2-.Lframe1
+ .long .Le
+ .long .Lf-.Le
+ .p2align 2
+.LEFDE2:
Index: ld/testsuite/ld-linkonce/zeroeh.ld
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-linkonce/zeroeh.ld,v
retrieving revision 1.1
diff -u -p -r1.1 zeroeh.ld
--- ld/testsuite/ld-linkonce/zeroeh.ld	29 Sep 2001 13:01:17 -0000	1.1
+++ ld/testsuite/ld-linkonce/zeroeh.ld	24 Apr 2007 03:42:20 -0000
@@ -1,4 +1,5 @@
 SECTIONS {
  .text 0xa00 : { *(.text); *(.gnu.linkonce.t.*) }
- .eh_frame 0x2000 : { *(.eh_frame) }
+ .gcc_except_table 0x2000 : { *(.gcc_except_table) }
+ .eh_frame 0x4000 : { *(.eh_frame) }
 }
Index: ld/testsuite/ld-linkonce/zeroehl32.d
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-linkonce/zeroehl32.d,v
retrieving revision 1.3
diff -u -p -r1.3 zeroehl32.d
--- ld/testsuite/ld-linkonce/zeroehl32.d	12 Oct 2002 15:40:13 -0000	1.3
+++ ld/testsuite/ld-linkonce/zeroehl32.d	24 Apr 2007 03:42:20 -0000
@@ -11,8 +11,11 @@
 Contents of section \.text:
  0a00 080a0000 100a0000 01000000 02000000  .*
  0a10 03000000                             .*
-Contents of section \.eh_frame:
+Contents of section \.gcc_except_table:
  2000 02000000 080a0000 08000000 07000000  .*
  2010 100a0000 04000000 66600000 00000000  .*
  2020 04000000                             .*
-#pass
+Contents of section \.eh_frame:
+ 4000 0c000000 00000000 0100017c 00000000  .*
+ 4010 0c000000 14000000 080a0000 08000000  .*
+ 4020 0c000000 24000000 100a0000 04000000  .*

-- 
Alan Modra
IBM OzLabs - Linux Technology Centre


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