[PATCH] Hardening of __do_global_dtors_aux

Rask Ingemann Lambertsen rask@sygehus.dk
Thu May 10 08:13:00 GMT 2007


On Thu, May 03, 2007 at 05:00:03AM -0400, Jakub Jelinek wrote:
> 
> 2007-05-03  Ulrich Drepper  <drepper@redhat.com>
> 	    Jakub Jelinek  <jakub@redhat.com>
> 
> 	* crtstuff.c (HIDDEN_DTOR_LIST_END): New macro.
> 	(__do_global_dtors_aux): Use more paranoid loop to run
> 	destructors if HIDDEN_DTOR_LIST_END.
> 	(__DTOR_END__): Export as a hidden symbol when HIDDEN_DTOR_LIST_END.

   Powerpc-eabisim is broken at the moment: libgfortran, boehm-gc, libffi
and who knows what fails to configure. From libffi/cofigure.log:

configure:2261: checking for C compiler default output file name
configure:2264: /home/rask/build/gcc-ppc/./gcc/xgcc -B/home/rask/build/gcc-ppc/./gcc/ -nostdinc -B/home/rask/build/gcc-ppc/powerpc-eabisim/newlib/ -isystem /home/rask/build/gcc-ppc/powerpc-eabisim/newlib/targ-include -isystem /n/08/rask/src/gcc/newlib/libc/include -B/usr/local/powerpc-eabisim/bin/ -B/usr/local/powerpc-eabisim/lib/ -isystem /usr/local/powerpc-eabisim/include -isystem /usr/local/powerpc-eabisim/sys-include -L/home/rask/build/gcc-ppc/./ld -O2 -g -O2    conftest.c  >&5
/home/rask/build/gcc-ppc/./gcc/ecrtn.o:(.dtors+0x0): multiple definition of `__DTOR_END__'
/home/rask/build/gcc-ppc/./gcc/crtend.o:(.dtors+0x0): first defined here
collect2: ld returned 1 exit status

sh-3.00$ nm ecrtn.o
00000000 D __CTOR_END__
00000000 D __DTOR_END__
00000000 D __EH_FRAME_END__
00000000 D __EXCEPT_END__
00000000 D __FIXUP_END__
00000000 D __GOT1_END__
00000000 D __GOT2_END__
00000000 D __GOT_END__
00000000 S __SBSS2_END__
00000000 S __SBSS_END__
00000000 G __SDATA2_END__
00000000 G __SDATA_END__

sh-3.00$ nm crtend.o
00000050 t call___do_global_ctors_aux
00000000 d __CTOR_END__
00000000 t __do_global_ctors_aux
00000000 D __DTOR_END__
00000000 r __FRAME_END__
00000000 d __JCR_END__

   If I go back to revision 124443 of crtstuff.c, this part works:

configure:2261: checking for C compiler default output file name
configure:2264: /home/rask/build/gcc-ppc/./gcc/xgcc -B/home/rask/build/gcc-ppc/./gcc/ -nostdinc -B/home/rask/build/gcc-ppc/powerpc-eabisim/newlib/ -isystem /home/rask/build/gcc-ppc/powerpc-eabisim/newlib/targ-include -isystem /n/08/rask/src/gcc/newlib/libc/include -B/usr/local/powerpc-eabisim/bin/ -B/usr/local/powerpc-eabisim/lib/ -isystem /usr/local/powerpc-eabisim/include -isystem /usr/local/powerpc-eabisim/sys-include -L/home/rask/build/gcc-ppc/./ld -O2 -g -O2    conftest.c  >&5
configure:2267: $? = 0
configure:2313: result: a.out

$ nm ecrtn.o
00000000 D __CTOR_END__
00000000 D __DTOR_END__
00000000 D __EH_FRAME_END__
00000000 D __EXCEPT_END__
00000000 D __FIXUP_END__
00000000 D __GOT1_END__
00000000 D __GOT2_END__
00000000 D __GOT_END__
00000000 S __SBSS2_END__
00000000 S __SBSS_END__
00000000 G __SDATA2_END__
00000000 G __SDATA_END__
$ nm crtend.o
00000050 t call___do_global_ctors_aux
00000000 d __CTOR_END__
00000000 t __do_global_ctors_aux
00000000 d __DTOR_END__
00000000 r __FRAME_END__
00000000 d __JCR_END__

   Notice s/D/d/ for __DTOR_END_ in crtend.o.

   It then proceeds to tell me: "libffi has not been ported to
powerpc-unknown-eabisim." No thanks to the configure script for wasting my
time. :-(

   Note that I still can't get libgfortran to configure without
--disable-multilib and can't get libjava and boehm-gc to configure at all.

> --- gcc/crtstuff.c.jj	2007-01-24 22:24:21.000000000 +0100
> +++ gcc/crtstuff.c	2007-05-03 10:40:29.000000000 +0200
[snip]

> @@ -471,6 +493,17 @@ STATIC func_ptr __CTOR_END__[1]
>  
>  #ifdef DTOR_LIST_END
>  DTOR_LIST_END;
> +#elif defined(HIDDEN_DTOR_LIST_END)
> +#ifdef DTORS_SECTION_ASM_OP
> +asm (DTORS_SECTION_ASM_OP);
> +#endif
> +func_ptr __DTOR_END__[1]

   I'm guessing this should be

STATIC func_ptr __DTOR_END__[1]

but your guess is surely better than mine.

-- 
Rask Ingemann Lambertsen



More information about the Gcc-patches mailing list