summaryrefslogtreecommitdiffstats
path: root/src/target/firmware/lib
diff options
context:
space:
mode:
authorHarald Welte2010-06-24 11:46:47 +0200
committerHarald Welte2010-06-24 11:46:47 +0200
commit7419d6559f22ec7c364e7bdedd5e179d34f79775 (patch)
treec72ce4245b22e65e484fde4a4b391f5317996812 /src/target/firmware/lib
parentfw/layer1/l23_api: Process each message in a function (diff)
downloadosmocom-7419d6559f22ec7c364e7bdedd5e179d34f79775.tar.gz
osmocom-7419d6559f22ec7c364e7bdedd5e179d34f79775.tar.xz
osmocom-7419d6559f22ec7c364e7bdedd5e179d34f79775.zip
[firmware] Add support for __attribute__ ((constructor))
We modify the linker scripts to include the .ctors and .dtors sections and add some code to actually call them before we jump to the main() function.
Diffstat (limited to 'src/target/firmware/lib')
-rw-r--r--src/target/firmware/lib/Makefile2
-rw-r--r--src/target/firmware/lib/ctors.c11
2 files changed, 12 insertions, 1 deletions
diff --git a/src/target/firmware/lib/Makefile b/src/target/firmware/lib/Makefile
index 8542743..987857c 100644
--- a/src/target/firmware/lib/Makefile
+++ b/src/target/firmware/lib/Makefile
@@ -1,7 +1,7 @@
LIBRARIES+=mini
mini_DIR=lib
-mini_SRCS=vsprintf.c string.c ctype.c printf.c console.c \
+mini_SRCS=vsprintf.c string.c ctype.c printf.c console.c ctors.c \
changebit.S clearbit.S div64.S lib1funcs.S memcpy.S memset.S setbit.S testchangebit.S testclearbit.S testsetbit.S
diff --git a/src/target/firmware/lib/ctors.c b/src/target/firmware/lib/ctors.c
new file mode 100644
index 0000000..6136a88
--- /dev/null
+++ b/src/target/firmware/lib/ctors.c
@@ -0,0 +1,11 @@
+
+/* iterate over list of constructor functions and call each element */
+void do_global_ctors(const char *ctors_start, const char *ctors_end)
+{
+ typedef void (*func_ptr)(void);
+ func_ptr *func;
+
+ for (func = (func_ptr *) ctors_start;
+ *func && (func != (func_ptr *) ctors_end); func++)
+ (*func)();
+}