move talloc context creation out of on_dso / constructors

the various constructors get called in a non-obvious, linker determined
order, which makes certain objects disappear from the talloc report.

This change moves the talloc context creation into a new talloc_ctx.c file
diff --git a/openbsc/src/Makefile.am b/openbsc/src/Makefile.am
index d7a8462..cbfeeaa 100644
--- a/openbsc/src/Makefile.am
+++ b/openbsc/src/Makefile.am
@@ -9,7 +9,7 @@
 		gsm_subscriber.c msgb.c select.c chan_alloc.c timer.c debug.c db.c \
 		gsm_04_11.c telnet_interface.c subchan_demux.c \
 		trau_frame.c trau_mux.c paging.c e1_config.c e1_input.c tlv_parser.c \
-		input/misdn.c input/ipaccess.c signal.c gsm_utils.c talloc.c \
+		input/misdn.c input/ipaccess.c signal.c gsm_utils.c talloc.c talloc_ctx.c \
 		transaction.c rtp_proxy.c bsc_rll.c token_auth.c
 
 libvty_a_SOURCES = vty/buffer.c vty/command.c vty/vector.c vty/vty.c
diff --git a/openbsc/src/abis_nm.c b/openbsc/src/abis_nm.c
index a75ef7a..abf073c 100644
--- a/openbsc/src/abis_nm.c
+++ b/openbsc/src/abis_nm.c
@@ -2199,7 +2199,7 @@
 
 /* BS11 SWL */
 
-static void *tall_fle_ctx;
+void *tall_fle_ctx;
 
 struct abis_nm_bs11_sw {
 	struct gsm_bts *bts;
@@ -2564,10 +2564,3 @@
 {
 	return __simple_cmd(bts, NM_MT_IPACC_RESTART);
 }
-
-
-static __attribute__((constructor)) void on_dso_load_abis_nm(void)
-{
-	tall_fle_ctx = talloc_named_const(tall_bsc_ctx, 1, 
-					  "bs11_file_list_entry");
-}
diff --git a/openbsc/src/bsc_hack.c b/openbsc/src/bsc_hack.c
index 347e951..5f84513 100644
--- a/openbsc/src/bsc_hack.c
+++ b/openbsc/src/bsc_hack.c
@@ -1217,6 +1217,7 @@
 	int rc;
 
 	tall_bsc_ctx = talloc_named_const(NULL, 1, "openbsc");
+	talloc_ctx_init();
 	on_dso_load_token();
 
 	/* parse options */
diff --git a/openbsc/src/gsm_04_08.c b/openbsc/src/gsm_04_08.c
index dc2bd19..e5ab49d 100644
--- a/openbsc/src/gsm_04_08.c
+++ b/openbsc/src/gsm_04_08.c
@@ -56,7 +56,7 @@
 #define GSM_MAX_SSVERSION      128
 #define GSM_MAX_USERUSER       128
 
-static void *tall_locop_ctx;
+void *tall_locop_ctx;
 
 /* should ip.access BTS use direct RTP streams between each other (1),
  * or should OpenBSC always act as RTP relay/proxy in between (0) ? */
@@ -3896,8 +3896,6 @@
  */
 static __attribute__((constructor)) void on_dso_load_0408(void)
 {
-	tall_locop_ctx = talloc_named_const(tall_bsc_ctx, 1,
-					    "loc_updating_oper");
 	register_signal_handler(SS_LCHAN, gsm0408_handle_lchan_signal, NULL);
 	register_signal_handler(SS_ABISIP, handle_abisip_signal, NULL);
 }
diff --git a/openbsc/src/gsm_04_11.c b/openbsc/src/gsm_04_11.c
index 2994d72..85ad0ec 100644
--- a/openbsc/src/gsm_04_11.c
+++ b/openbsc/src/gsm_04_11.c
@@ -53,7 +53,7 @@
 
 #define UM_SAPI_SMS 3	/* See GSM 04.05/04.06 */
 
-static void *tall_gsms_ctx;
+void *tall_gsms_ctx;
 static u_int32_t new_callref = 0x40000001;
 
 struct value_string {
@@ -1076,7 +1076,5 @@
 
 static __attribute__((constructor)) void on_dso_load_sms(void)
 {
-	tall_gsms_ctx = talloc_named_const(tall_bsc_ctx, 1, "sms");
-
 	register_signal_handler(SS_SUBSCR, subscr_sig_cb, NULL);
 }
diff --git a/openbsc/src/gsm_subscriber.c b/openbsc/src/gsm_subscriber.c
index d91298e..297b8c8 100644
--- a/openbsc/src/gsm_subscriber.c
+++ b/openbsc/src/gsm_subscriber.c
@@ -36,8 +36,8 @@
 #include <openbsc/db.h>
 
 LLIST_HEAD(active_subscribers);
-static void *tall_subscr_ctx;
-static void *tall_sub_req_ctx;
+void *tall_subscr_ctx;
+void *tall_sub_req_ctx;
 
 /*
  * Struct for pending channel requests. This is managed in the
@@ -282,12 +282,3 @@
 	if (lchan->subscr && !llist_empty(&lchan->subscr->requests))
 		subscr_send_paging_request(lchan->subscr);
 }
-
-
-static __attribute__((constructor)) void on_dso_load_subscr(void)
-{
-	tall_subscr_ctx = talloc_named_const(tall_bsc_ctx, 1, "subscriber");
-
-	tall_sub_req_ctx = talloc_named_const(tall_bsc_ctx, 1,
-						      "subscr_request");
-}
diff --git a/openbsc/src/mncc.c b/openbsc/src/mncc.c
index 8cd62f6..f62541c 100644
--- a/openbsc/src/mncc.c
+++ b/openbsc/src/mncc.c
@@ -30,7 +30,7 @@
 #include <openbsc/talloc.h>
 #include <openbsc/gsm_data.h>
 
-static void *tall_call_ctx;
+void *tall_call_ctx;
 
 static struct mncc_names {
 	char *name;
@@ -389,8 +389,3 @@
 
 	return rc;
 }
-
-static __attribute__((constructor)) void on_dso_load_trau_mncc(void)
-{
-	tall_call_ctx = talloc_named_const(tall_bsc_ctx, 1, "gsm_call");
-}
diff --git a/openbsc/src/paging.c b/openbsc/src/paging.c
index dd22150..802024a 100644
--- a/openbsc/src/paging.c
+++ b/openbsc/src/paging.c
@@ -49,7 +49,7 @@
 #define PAGING_TIMEOUT 1, 75000
 #define MAX_PAGING_REQUEST 750
 
-static void *tall_paging_ctx;
+void *tall_paging_ctx;
 
 static unsigned int calculate_group(struct gsm_bts *bts, struct gsm_subscriber *subscr)
 {
@@ -309,8 +309,3 @@
 {
 	bts->paging.available_slots = free_slots;
 }
-
-static __attribute__((constructor)) void on_dso_load_paging(void)
-{
-	tall_paging_ctx = talloc_named_const(NULL, 1, "paging_request");
-}
diff --git a/openbsc/src/signal.c b/openbsc/src/signal.c
index bf5671e..e04cadf 100644
--- a/openbsc/src/signal.c
+++ b/openbsc/src/signal.c
@@ -24,7 +24,7 @@
 #include <string.h>
 
 
-static void *tall_sigh_ctx;
+void *tall_sigh_ctx;
 static LLIST_HEAD(signal_handler_list);
 
 struct signal_handler {
@@ -81,8 +81,3 @@
 		(*handler->cbfn)(subsys, signal, handler->data, signal_data);
 	}
 }
-
-static __attribute__((constructor)) void on_dso_load_signal(void)
-{
-	tall_sigh_ctx = talloc_named_const(NULL, 1, "signal_handler");
-}
diff --git a/openbsc/src/subchan_demux.c b/openbsc/src/subchan_demux.c
index 368b985..63be533 100644
--- a/openbsc/src/subchan_demux.c
+++ b/openbsc/src/subchan_demux.c
@@ -31,7 +31,7 @@
 #include <openbsc/talloc.h>
 #include <openbsc/gsm_data.h>
 
-static void *tall_tqe_ctx;
+void *tall_tqe_ctx;
 
 static inline void append_bit(struct demux_subch *sch, u_int8_t bit)
 {
@@ -320,9 +320,3 @@
 
 	return 0;
 }
-
-static __attribute__((constructor)) void on_dso_load_ss_demux(void)
-{
-	tall_tqe_ctx = talloc_named_const(tall_bsc_ctx, 1,
-					  "subch_txq_entry");
-}
diff --git a/openbsc/src/talloc_ctx.c b/openbsc/src/talloc_ctx.c
new file mode 100644
index 0000000..aa9f0b4
--- /dev/null
+++ b/openbsc/src/talloc_ctx.c
@@ -0,0 +1,32 @@
+#include <openbsc/talloc.h>
+#include <openbsc/gsm_data.h>
+
+extern void *tall_fle_ctx;
+extern void *tall_locop_ctx;
+extern void *tall_gsms_ctx;
+extern void *tall_subscr_ctx;
+extern void *tall_sub_req_ctx;
+extern void *tall_call_ctx;
+extern void *tall_paging_ctx;
+extern void *tall_sigh_ctx;
+extern void *tall_tqe_ctx;
+extern void *tall_trans_ctx;
+extern void *tall_map_ctx;
+extern void *tall_upq_ctx;
+
+void talloc_ctx_init(void)
+{
+	tall_fle_ctx = talloc_named_const(tall_bsc_ctx, 0, 
+					  "bs11_file_list_entry");
+	tall_locop_ctx = talloc_named_const(tall_bsc_ctx, 0, "loc_updating_oper");
+	tall_gsms_ctx = talloc_named_const(tall_bsc_ctx, 0, "sms");
+	tall_subscr_ctx = talloc_named_const(tall_bsc_ctx, 0, "subscriber");
+	tall_sub_req_ctx = talloc_named_const(tall_bsc_ctx, 0, "subscr_request");
+	tall_call_ctx = talloc_named_const(tall_bsc_ctx, 0, "gsm_call");
+	tall_paging_ctx = talloc_named_const(tall_bsc_ctx, 0, "paging_request");
+	tall_sigh_ctx = talloc_named_const(tall_bsc_ctx, 0, "signal_handler");
+	tall_tqe_ctx = talloc_named_const(tall_bsc_ctx, 0, "subch_txq_entry");
+	tall_trans_ctx = talloc_named_const(tall_bsc_ctx, 0, "transaction");
+	tall_map_ctx = talloc_named_const(tall_bsc_ctx, 0, "trau_map_entry");
+	tall_upq_ctx = talloc_named_const(tall_bsc_ctx, 0, "trau_upq_entry");
+}
diff --git a/openbsc/src/transaction.c b/openbsc/src/transaction.c
index 5e55665..8e2b0b6 100644
--- a/openbsc/src/transaction.c
+++ b/openbsc/src/transaction.c
@@ -29,7 +29,7 @@
 #include <openbsc/mncc.h>
 #include <openbsc/paging.h>
 
-static void *tall_trans_ctx;
+void *tall_trans_ctx;
 
 void _gsm48_cc_trans_free(struct gsm_trans *trans);
 
diff --git a/openbsc/src/trau_mux.c b/openbsc/src/trau_mux.c
index 9ff7001..6a19f0c 100644
--- a/openbsc/src/trau_mux.c
+++ b/openbsc/src/trau_mux.c
@@ -47,7 +47,7 @@
 static LLIST_HEAD(ss_map);
 static LLIST_HEAD(ss_upqueue);
 
-static void *tall_map_ctx, *tall_upq_ctx;
+void *tall_map_ctx, *tall_upq_ctx;
 
 /* map one particular subslot to another subslot */
 int trau_mux_map(const struct gsm_e1_subslot *src,
@@ -235,12 +235,3 @@
 	return subchan_mux_enqueue(mx, dst_e1_ss->e1_ts_ss, trau_bits_out,
 				   TRAU_FRAME_BITS);
 }
-
-static __attribute__((constructor)) void on_dso_load_trau_mux(void)
-{
-	tall_map_ctx = talloc_named_const(tall_bsc_ctx, 1,
-					  "trau_map_entry");
-
-	tall_upq_ctx = talloc_named_const(tall_bsc_ctx, 1,
-					  "trau_upq_entry");
-}
diff --git a/openbsc/src/vty/vty.c b/openbsc/src/vty/vty.c
index 53800d1..affe28d 100644
--- a/openbsc/src/vty/vty.c
+++ b/openbsc/src/vty/vty.c
@@ -1630,7 +1630,7 @@
 /* Install vty's own commands like `who' command. */
 void vty_init()
 {
-	tall_vty_ctx = talloc_named_const(tall_bsc_ctx, 1, "vty");
+	tall_vty_ctx = talloc_named_const(NULL, 0, "vty");
 
 	/* For further configuration read, preserve current directory. */
 	vty_save_cwd();