This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC 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: Avoid link failures on arm-eabi with newlib


If newlib is configured with --enable-io-long-long, the arm-eabi
compilers will fail to link "hello, world".  The problem is that we
use "-lgcc -lc -lgcc" to link.  The call to printf (in libc) pulls in
udivmoddi4 (in libgcc) which is built with -fexceptions, and therefore
pulls in the EH routines (in libgcc), which pulls in abort (in libc) --
but we've already finished with libc at that point.

I think the most robust way to fix this is to use --start-group
... --end-group.  Even GNU/Linux does that when using -static.  (In
fact, I'd almost argue that the default in gcc.c ought to be to use
--start-group and --end-group around libgcc and libc; it's more
robust, even if it does result in perhaps somewhat slower link times.)

OK for csl-arm-branch and mainline?

--
Mark Mitchell
CodeSourcery, LLC
mark@codesourcery.com

2005-10-01  Mark Mitchell  <mark@codesourcery.com>

	* config/arm/unknown-elf.h (LINK_GCC_C_SEQUENCE_SPEC): Define
	using --start-group and --end-group.

Index: gcc/config/arm/unknown-elf.h
===================================================================
RCS file: /home/gcc/repos/gcc/gcc/gcc/config/arm/unknown-elf.h,v
retrieving revision 1.32.10.3
diff -c -5 -p -r1.32.10.3 unknown-elf.h
*** gcc/config/arm/unknown-elf.h	18 Nov 2004 15:57:36 -0000	1.32.10.3
--- gcc/config/arm/unknown-elf.h	1 Oct 2005 03:24:56 -0000
***************
*** 87,91 ****
--- 87,97 ----
  
  #ifndef SUBTARGET_CPU_DEFAULT
  #define SUBTARGET_CPU_DEFAULT 		TARGET_CPU_arm7tdmi
  #endif
  
+ /* The libgcc udivmod functions may throw exceptions.  If newlib is
+    configured to support long longs in I/O, then printf will depend on
+    udivmoddi4, which will depend on the exception unwind routines,
+    which will depend on abort, which is defined in libc.  */ 
+ #undef LINK_GCC_C_SEQUENCE_SPEC
+ #define LINK_GCC_C_SEQUENCE_SPEC "--start-group %G %L --end-group"


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