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]

Re: use crtstuff.c on alpha


> Date: Sat, 26 Jan 2002 20:26:32 -0800
> From: Richard Henderson <rth@redhat.com>

> Tested on alphaev6-linux, i686-linux, and cris-elf.

> 	* config/cris/cris.h (CRT_CALL_STATIC_FUNCTION): Rewrite old
> 	FORCE_INIT_SECTION_ALIGN hack.  Register __fini_start before
> 	calling constructors.
> 	* config/cris/linux.h (CRT_CALL_STATIC_FUNCTION): Undef.

This patch broke cris-elf.  Trivial programs didn't link anymore.
You moved the call to atexit from crtbegin to crtend.  Libraries
are linked in *before* crtend, so there's nothing left to
resolve atexit if crtend was the only user of atexit.

This fixes it.  Since "make all-gcc" now builds, I'm committing
it.  The C and C++ parts of the test-suite has completed with
no regressions compared to recently before both patches.

	* config/cris/cris.h (CRT_CALL_STATIC_FUNCTION): Change to emit
	atexit call in crtbegin, hooked in after call to frame_dummy;
	register EH before registering __fini__start.

Index: cris.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/cris/cris.h,v
retrieving revision 1.22
diff -p -c -r1.22 cris.h
*** cris.h	2002/01/27 04:18:08	1.22
--- cris.h	2002/01/28 13:07:57
*************** struct cum_args {int regs;};
*** 1450,1468 ****
  
  /* We pull a little trick to register the _fini function with atexit,
     after (presumably) registering the eh frame info, since we don't handle
!    _fini (a.k.a. ___fini_start) in crt0 or have a crti for "pure" ELF.  */
! #ifdef CRT_END
  # define CRT_CALL_STATIC_FUNCTION(SECTION_OP, FUNC)		\
  static void __attribute__((__used__))				\
  call_ ## FUNC (void)						\
  {								\
    asm (SECTION_OP);						\
!   if (__builtin_strcmp (#FUNC, "__do_global_ctors_aux") == 0)	\
     {								\
       extern void __fini__start (void);				\
       atexit (__fini__start);					\
     }								\
-   FUNC ();							\
    asm (TEXT_SECTION_ASM_OP);					\
  }
  #endif
--- 1450,1471 ----
  
  /* We pull a little trick to register the _fini function with atexit,
     after (presumably) registering the eh frame info, since we don't handle
!    _fini (a.k.a. ___fini_start) in crt0 or have a crti for "pure" ELF.  If
!    you change this, don't forget that you can't have library function
!    references (e.g. to atexit) in crtend.o, since those won't be resolved
!    to libraries; those are linked in *before* crtend.o.  */
! #ifdef CRT_BEGIN
  # define CRT_CALL_STATIC_FUNCTION(SECTION_OP, FUNC)		\
  static void __attribute__((__used__))				\
  call_ ## FUNC (void)						\
  {								\
    asm (SECTION_OP);						\
!   FUNC ();							\
!   if (__builtin_strcmp (#FUNC, "frame_dummy") == 0)		\
     {								\
       extern void __fini__start (void);				\
       atexit (__fini__start);					\
     }								\
    asm (TEXT_SECTION_ASM_OP);					\
  }
  #endif

brgds, H-P


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