The constructors of application are placed in an array __CTOR_LIST__[].
__CTOR_LIST__[0] is the number of the destructors or -1 which means the
number of the destructors are not specified. __CTOR_END__ marks the end
of the array. __CTOR_END__[0] is 0. crtstuff.c sets __CTOR_LIST__[0] to
-1 and __CTOR_END__[0] to 0. But elf2flt.ld.in did the same thing again,
except that the symbols it provides are global. You could see two set of
defined __CTOR_LIST__/__CTOR_END__ in the resulted application.
num of ctors, -1, constructors, 0, 0
^ ^ ^ ^
__CTOR_LIST__ __CTOR_LIST__ __CTOR_END__ __CTOR_END__
The outer pair are generated by elf2flt.ld.in. The inner pair are
provided by crtstuff.c. Same is destructor array.
I discovered this when I was testing gcc-4.3, which is different with
gcc-4.1 in execution of destructors.
Please review and commit it if it's OK.
Jie
--- elf2flt.ld.orig 2007-08-30 23:15:07.000000000 +0800
+++ elf2flt.ld 2007-08-30 23:16:49.000000000 +0800
@@ -89,8 +89,6 @@
PROVIDE(_SDA2_BASE_ = _ssro + (_ssro_size / 2));
. = ALIGN(4) ;
- __CTOR_LIST__ = .;
- LONG((__CTOR_END__ - __CTOR_LIST__) / 4 - 2)
SINGLE_LINK: /* gcc uses crtbegin.o to find the start of
SINGLE_LINK: the constructors, so we make sure it is
SINGLE_LINK: first. Because this is a wildcard, it
@@ -108,16 +106,10 @@
SINGLE_LINK: KEEP (*(EXCLUDE_FILE (*crtend*.o ) .ctors))
SINGLE_LINK: KEEP (*(SORT(.ctors.*)))
KEEP (*(.ctors))
- LONG(0)
- __CTOR_END__ = .;
- __DTOR_LIST__ = .;
- LONG((__DTOR_END__ - __DTOR_LIST__) / 4 - 2)
SINGLE_LINK: KEEP (*crtbegin*.o(.dtors))
SINGLE_LINK: KEEP (*(EXCLUDE_FILE (*crtend*.o ) .dtors))
SINGLE_LINK: KEEP (*(SORT(.dtors.*)))
KEEP (*(.dtors))
- LONG(0)
- __DTOR_END__ = .;
PROVIDE (__preinit_array_start = .);
KEEP (*(.preinit_array))
_______________________________________________
uClinux-dev mailing list
[email protected]
http://mailman.uclinux.org/mailman/listinfo/uclinux-dev
This message was resent by [email protected]
To unsubscribe see:
http://mailman.uclinux.org/mailman/options/uclinux-dev