This is the mail archive of the 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] allow suppression of fde encoding warning

While working on a new toolchain port (Altera Nios II), I was seeing diagnostics like

ld: fde encoding in /tmp/cceh1oVS.o(.eh_frame) prevents .eh_frame_hdr table being created.

on some test cases compiled with -fpie.

My understanding of this warning is as follows.

As an optimization, GNU ld tries to precompute lookup tables for some exception handling information ("fde" == "Frame Description Entry") at link time. This warning is saying that it can't do so when generating a position-independent executable because the eh data contains absolute relocations. Since these tables are only an optimization, it's not a fatal error; the relocations will be fully resolved at runtime and the eh library is supposed to DTRT in the absence of the linker-generated tables.

Google turned up a few references to this problem on other targets that indicated that the "right" solution is for GCC to emit section-relative references in the FDE data. But, not all architectures support such a thing in the ABI (and, in particular, the Nios II ABI doesn't have an appropriate relocation for this purpose). So, it seems like we should be able to turn the warning off on architectures where the optimization cannot possibly work.

I've come up with the attached patch to add infrastructure to do this. OK to commit?

(Another possible solution is just getting rid of the warning entirely. It seems like an implementation detail unlikely to be of interest to 99.9% of ordinary users.)


2013-01-19  Sandra Loosemore  <>

	* elf-bfd.h (struct elf_backend_data): Add want_fde_table field.
	* elfxx-target.h (elf_backend_want_fde_table): Define.
	(elfNN_bed): Initialize want_fde_table field.
	* elf-eh-frame.c (_bfd_elf_discard_section_eh_frame): Don't
	warn unless want_fde_table field indicates the optimization is
	supposed to be supported by the target.
Index: bfd/elf-bfd.h
RCS file: /cvs/src/src/bfd/elf-bfd.h,v
retrieving revision 1.355
diff -u -p -r1.355 elf-bfd.h
--- bfd/elf-bfd.h	13 Jan 2013 12:32:10 -0000	1.355
+++ bfd/elf-bfd.h	19 Jan 2013 19:52:56 -0000
@@ -1350,6 +1350,12 @@ struct elf_backend_data
      other file in the link needs to have a .note.GNU-stack section
      for a PT_GNU_STACK segment to be created.  */
   unsigned default_execstack : 1;
+  /* True if the target is expected to support link-time FDE table
+     optimization.  Typically this requires relocations to support
+     section-relative addressing so that the FDE data can be constructed
+     without absolute relocations.  */
+  unsigned want_fde_table : 1;
 /* Information about reloc sections associated with a bfd_elf_section_data
Index: bfd/elf-eh-frame.c
RCS file: /cvs/src/src/bfd/elf-eh-frame.c,v
retrieving revision 1.90
diff -u -p -r1.90 elf-eh-frame.c
--- bfd/elf-eh-frame.c	25 May 2012 01:12:19 -0000	1.90
+++ bfd/elf-eh-frame.c	19 Jan 2013 19:52:56 -0000
@@ -1185,9 +1185,10 @@ _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);
+		if (get_elf_backend_data (sec->owner)->want_fde_table)
+		  (*info->callbacks->einfo)
+		    (_("%P: fde encoding in %B(%A) prevents .eh_frame_hdr"
+		       " table being created.\n"), abfd, sec);
 	    ent->removed = 0;
Index: bfd/elfxx-target.h
RCS file: /cvs/src/src/bfd/elfxx-target.h,v
retrieving revision 1.130
diff -u -p -r1.130 elfxx-target.h
--- bfd/elfxx-target.h	23 Oct 2012 09:33:54 -0000	1.130
+++ bfd/elfxx-target.h	19 Jan 2013 19:52:56 -0000
@@ -112,6 +112,9 @@
 #ifndef elf_backend_stack_align
 #define elf_backend_stack_align 16
+#ifndef elf_backend_want_fde_table
+#define elf_backend_want_fde_table 1
 #define bfd_elfNN_bfd_debug_info_start	bfd_void
 #define bfd_elfNN_bfd_debug_info_end	bfd_void
@@ -792,7 +795,8 @@ static struct elf_backend_data elfNN_bed
-  elf_backend_default_execstack
+  elf_backend_default_execstack,
+  elf_backend_want_fde_table
 /* Forward declaration for use when initialising alternative_target field.  */

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