diff options
author | merrill <merrill@138bc75d-0d04-0410-961f-82ee72b054a4> | 1994-07-29 19:03:37 +0000 |
---|---|---|
committer | merrill <merrill@138bc75d-0d04-0410-961f-82ee72b054a4> | 1994-07-29 19:03:37 +0000 |
commit | 13d403897117dd824dedce93122f2bb6092310cb (patch) | |
tree | ff09d4aec59c8c85b0a8490344f534acaa2bfdc9 /gcc | |
parent | a0b2c9a2cb13df03137ff439458e3e02c02bba24 (diff) | |
download | gcc-13d403897117dd824dedce93122f2bb6092310cb.tar.gz |
(DO_GLOBAL_CTORS_BODY): Reverse order of execution
of constuctor lists.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@7818 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/config/svr3.h | 2 | ||||
-rw-r--r-- | gcc/gbl-ctors.h | 17 |
2 files changed, 12 insertions, 7 deletions
diff --git a/gcc/config/svr3.h b/gcc/config/svr3.h index 8e7acd6a706..dd5cbc5a092 100644 --- a/gcc/config/svr3.h +++ b/gcc/config/svr3.h @@ -221,7 +221,7 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. /* CTOR_LIST_BEGIN and CTOR_LIST_END are machine-dependent because they push on the stack. */ -#ifdef STACK_GROWS_DOWNWARD +#ifndef STACK_GROWS_DOWNWARD /* Constructor list on stack is in reverse order. Go to the end of the list and go backwards to call constructors in the right order. */ diff --git a/gcc/gbl-ctors.h b/gcc/gbl-ctors.h index 2e7f520d685..32ff0333991 100644 --- a/gcc/gbl-ctors.h +++ b/gcc/gbl-ctors.h @@ -63,18 +63,23 @@ extern void __do_global_dtors (); we define it once here as a macro to avoid various instances getting out-of-sync with one another. */ -/* The first word may or may not contain the number of pointers in the table. +/* Some systems place the number of pointers + in the first word of the table. + On other systems, that word is -1. In all cases, the table is null-terminated. - We ignore the first word and scan up to the null. */ + If the length is not recorded, count up to the null. */ /* Some systems use a different strategy for finding the ctors. For example, svr3. */ #ifndef DO_GLOBAL_CTORS_BODY #define DO_GLOBAL_CTORS_BODY \ do { \ - func_ptr *p; \ - for (p = __CTOR_LIST__ + 1; *p; ) \ - (*p++) (); \ -} while (0) + unsigned nptrs = (unsigned HOST_WIDE_INT) __CTOR_LIST__[0]; \ + unsigned i; \ + if (nptrs == -1) \ + for (nptrs = 0; __CTOR_LIST__[nptrs + 1] != 0; nptrs++); \ + for (i = nptrs; i >= 1; i--) \ + __CTOR_LIST__[i] (); \ +} while (0) #endif |