This is the mail archive of the 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]

Re: [PATCH] Hardening of __do_global_dtors_aux

On Thu, May 10, 2007 at 10:13:21AM +0200, Rask Ingemann Lambertsen wrote:
>    Powerpc-eabisim is broken at the moment: libgfortran, boehm-gc, libffi
> and who knows what fails to configure. From libffi/cofigure.log:

What ppc eabi is doing is ugly at best, using __DTOR_END__ for 2 different
things (in crtend*.o for the address of the final NULL in .dtors section
and in ecrtn.o for the end of .dtors section (i.e. crtend*.o's
__DTOR_END__+1 == ecrtn.o's __DTOR_END__) and relying on static in

There are multiple ways to fix this up.
1) change config/rs6000/*-cn.asm and config/rs6000/eabi.asm, replace
   __DTOR_END__ there with some name
2) make sure HIDDEN_DTOR_LIST_END is not defined for ppc-eabi*
3) rename __DTOR_END__ in crtstuff.c if HIDDEN_DTOR_LIST_END
   is defined (say to __DTOR_LAST__).

I'd prefer anything but 3), since 3) would create inconsistency
between various ports - what is in some ports called __DTOR_END__
would be __DTOR_LAST__ in others.  We have this inconsistency ATM
just with all ports but ppc-eabi* vs. ppc-eabi*.

>    I'm guessing this should be
> STATIC func_ptr __DTOR_END__[1]
> but your guess is surely better than mine.

That's not possible, as crtbegin*.o when HIDDEN_DTOR_LIST_END
is defined references it.

Attached is a patch for option 2).

2007-05-10  Jakub Jelinek  <>

	* crtstuff.c (HIDDEN_DTOR_LIST_END): Don't define
	HIDDEN_DTOR_LIST_END on powerpc-*-eabi*.

--- gcc/crtstuff.c.jj	2007-05-04 21:19:54.000000000 +0200
+++ gcc/crtstuff.c	2007-05-10 11:12:09.000000000 +0200
@@ -106,8 +106,15 @@ call_ ## FUNC (void)					\
+/* If defined, __DTOR_END__ is exported hidden symbol and
+   __do_global_dtors_aux can't be tricked into calling a function
+   through pointer not from .dtors section.
+   This can't be used on ppc-eabi*, as there __DTOR_END__ is used
+   for the end of crtstuff.c's __DTOR_END__ object and therefore
+   __DTOR_END__ here must be static.  */
 #if !defined(DTOR_LIST_END) && defined(OBJECT_FORMAT_ELF) \
-    && defined(HAVE_GAS_HIDDEN) && !defined(FINI_ARRAY_SECTION_ASM_OP)
+    && defined(HAVE_GAS_HIDDEN) && !defined(FINI_ARRAY_SECTION_ASM_OP) \ 
+    && (!defined(__powerpc__) || !defined(__embedded__))


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