Don't let mips-elf provide __CTOR_LIST__ in libgcc

Jonathan Larmour
Wed Mar 1 06:14:00 GMT 2000

Hi Gavin,

I was told to send this straight to you rather than gcc-patches. It was
originally sent in January so it had aged enough for me to resend it :-).


-----Original Message------

The rationale behind this change is that either __CTOR_LIST__ should come
from crtbegin.o or the user will provide it. There is no need to rely on
libgcc to provide it.

If left as-is, then it becomes impossible for people who define
__CTOR_LIST__ in linker scripts rather than by magic .o files at the start
of the link line to get the list right. The reason is that two null entries
get placed somewhere in the middle of the __CTOR_LIST__ depending on where
the first reference to __CTOR_LIST__ in the linked .o files came from.


Red Hat, 35 Cambridge Place, Cambridge, UK. CB2 1NS   Tel: +44 (1223) 728762
"I used to have an open mind but || Get yer free open source RTOS's here...
 my brains kept falling out."    ||
Help fight spam!  These opinions are all my own fault
Tue Jan 25 14:41:45 2000  Jonathan Larmour  <>
        * config/mips/elf.h (CTOR_LISTS_DEFINED_EXTERNALLY): Define because
        __CTOR_LIST__ always comes from either crtbegin.o or equivalent, or
        directly from the user if they chose to override it
Index: config/mips/elf.h
RCS file: /cvs/cvsfiles/devo/gcc/config/mips/elf.h,v
retrieving revision
diff -u -5 -p -r1.24.16.3 elf.h
--- elf.h	1999/12/07 14:04:59
+++ elf.h	2000/01/25 14:50:06
@@ -288,10 +288,15 @@ do {									   \
    via the SHF_WRITE attribute.)  */
 #define CTORS_SECTION_ASM_OP    "\t.section\t.ctors,\"aw\""
 #define DTORS_SECTION_ASM_OP    "\t.section\t.dtors,\"aw\""
+/* There's no point providing a default definition of __CTOR_LIST__
+   since people are expected either to use crtbegin.o, or an equivalent,
+   or provide their own definition.  */
 /* A list of other sections which the compiler might be "in" at any
    given time.  */
 #define EXTRA_SECTIONS in_sdata, in_sbss, in_rdata, in_ctors, in_dtors
@@ -375,13 +380,10 @@ void FN ()                              
 #ifdef IN_LIBGCC2
 /* We must also declare them 'extern' for libgcc.a, or they will
    be referenced as if they were in .sdata.  */
 extern unsigned char __attribute__((section(".eh_frame"))) 
-extern void (* __attribute__((section(".ctors"))) __CTOR_LIST__[])();
-extern void (* __attribute__((section(".dtors"))) __DTOR_LIST__[])();
 /* Don't set the target flags, this is done by the linker script */
 #undef LIB_SPEC
 #define LIB_SPEC ""

More information about the Gcc-patches mailing list