diff options
author | Harald Welte <laforge@gnumonks.org> | 2010-06-24 17:10:46 +0200 |
---|---|---|
committer | Harald Welte <laforge@gnumonks.org> | 2010-06-24 17:10:46 +0200 |
commit | 8c1f25e6276058b4ae96b37138b2ad1f91c1bb7e (patch) | |
tree | bd1a74b540e0c5494036319c01c11f3d7aeec0dc /src/target/firmware/lib/ctors.c | |
parent | 806da1525b17070ad1f4a10bdfdee4e4c041f21c (diff) |
[firmware] fix code that iterates over constructors
the first element after __CTORS_LIST__ contains the number of constructor
callbacks in the following array, so we have to skip it.
Diffstat (limited to 'src/target/firmware/lib/ctors.c')
-rw-r--r-- | src/target/firmware/lib/ctors.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/target/firmware/lib/ctors.c b/src/target/firmware/lib/ctors.c index 6136a884..982169df 100644 --- a/src/target/firmware/lib/ctors.c +++ b/src/target/firmware/lib/ctors.c @@ -1,11 +1,15 @@ /* iterate over list of constructor functions and call each element */ -void do_global_ctors(const char *ctors_start, const char *ctors_end) +void do_global_ctors(const char *_ctors_start, const char *ctors_end) { typedef void (*func_ptr)(void); - func_ptr *func; + func_ptr *func, *ctors_start = (func_ptr *) _ctors_start; - for (func = (func_ptr *) ctors_start; + /* skip the first entry, as it contains the number of + * constructors which we don't use */ + ctors_start++; + + for (func = ctors_start; *func && (func != (func_ptr *) ctors_end); func++) (*func)(); } |