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

Question about codes in libgcc/crtstuff.c


The brief structure of libgcc/crtstuff.c is as follows:

#ifdef CRT_BEGIN
…
#elif defined(CRT_END)
...
#  ifdef OBJECT_FORMAT_ELF
…
#  else

static void
__do_global_ctors_aux (void)	/* prologue goes in .text section */
{
  asm (__LIBGCC_INIT_SECTION_ASM_OP__);
  DO_GLOBAL_CTORS_BODY;
  atexit (__do_global_dtors);
}				/* epilogue and body go in .init section */

FORCE_CODE_SECTION_ALIGN
asm (__LIBGCC_TEXT_SECTION_ASM_OP__);

#endif  // OBJECT_FORMAT_ELF

#else // !CRT_BEGIN && !CRT_END
…
#endif

The __do_global_ctors_aux function shown above is static and without “used” attribute which result in optimizing out when compiled with optimization. This currently causes my port failed.
My understanding is that this function is supposed to be split into two parts: a prologue in .text section and the rest part in .init section. Meanwhile there is another symmetric function with the same name which is also split into two parts: an prologue in .init section and the rest part in .text section, which result in two identical copies of this function, one in .init section and the other in .text section. 
Or is there any other purpose of this code?

Lei


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