CTOR Section Problem

Nickolay Kolchin nbkolchin at gmail.com
Mon Feb 18 05:38:01 UTC 2008


Hi,

1. GCC 4.3 doesn't have this problem on SH4. (I've added __USE_INIT_FINI__ to
gcc/config/rtems[elf].h ). cdtest and sp tests work ok.

2. Quick and dirty (and totally incorrect) fix for dtors problem:

GCC 4.3 introduced new type of dtor processing: HIDDEN_DTOR_LIST_END.
Of course, we got into that that case. I don't know how to restore 4.2
behaviour.

But simple fix to crtstuff.c works:

---------------------------------------
#ifdef FINI_ARRAY_SECTION_ASM_OP
  /* If we are using .fini_array then destructors will be run via that
     mechanism.  */
#elif defined(HIDDEN_DTOR_LIST_END)
  {
    /* Safer version that makes sure only .dtors function pointers are
       called even if the static variable is maliciously changed.  */
    extern func_ptr __DTOR_END__[] __attribute__((visibility ("hidden")));
    static size_t dtor_idx;
    const size_t max_idx = __DTOR_END__ - __DTOR_LIST__ - 1;
    func_ptr f;

    while (dtor_idx < max_idx)
      {
	f = __DTOR_LIST__[++dtor_idx];
+	if(f) f (); else break;
-       f();
      }
  }

---------------------------------------

cdtest worked ok, after that fix.

This is not the way to go. Somebody, must find what defines should be
set, to restore previous DTOR behaviour.

--
Nickolay



More information about the users mailing list