]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Improve the build system to *properly* remove unnecessary symbols from the runtime...
authorKevin P. Fleming <kpfleming@digium.com>
Wed, 18 Mar 2009 01:55:22 +0000 (01:55 +0000)
committerKevin P. Fleming <kpfleming@digium.com>
Wed, 18 Mar 2009 01:55:22 +0000 (01:55 +0000)
With these changes, for a module to export symbols into the global namespace, it must have *both* the AST_MODFLAG_GLOBAL_SYMBOLS flag and a linker script that allows the linker to leave the symbols exposed in the module's .so file (see res_odbc.exports for an example).

git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@182808 65c4cc65-6c06-0410-ace0-fbb531ad65f3

22 files changed:
Makefile.rules
build_tools/strip_nonapi [deleted file]
default.exports [new file with mode: 0644]
include/asterisk/astobj2.h
main/Makefile
main/asterisk.exports [new file with mode: 0644]
main/astobj2.c
makeopts.in
res/res_adsi.exports [new file with mode: 0644]
res/res_agi.exports [new file with mode: 0644]
res/res_config_odbc.c
res/res_config_pgsql.c
res/res_crypto.c
res/res_features.exports [new file with mode: 0644]
res/res_indications.c
res/res_jabber.exports [new file with mode: 0644]
res/res_monitor.exports [new file with mode: 0644]
res/res_musiconhold.c
res/res_odbc.exports [new file with mode: 0644]
res/res_smdi.exports [new file with mode: 0644]
res/res_snmp.c
res/res_speech.exports [new file with mode: 0644]

index e4b174577fba5402679f51e048f02cc0acc72542..e6427172db8d197ff4d593fd1fa24aff459dbc38 100644 (file)
@@ -51,8 +51,13 @@ endif
 # per-target settings will be applied
 CC_CFLAGS=$(PTHREAD_CFLAGS) $(ASTCFLAGS)
 CXX_CFLAGS=$(PTHREAD_CFLAGS) $(filter-out -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations $(AST_DECLARATION_AFTER_STATEMENT),$(ASTCFLAGS))
-CC_LDFLAGS_SO=$(PTHREAD_CFLAGS) $(ASTLDFLAGS) $(SOLINK)
-CXX_LDFLAGS_SO=$(PTHREAD_CFLAGS) $(ASTLDFLAGS) $(SOLINK)
+
+ifeq ($(GNU_LD),1)
+SO_SUPPRESS_SYMBOLS=-Wl,--version-script,$(if $(wildcard $(subst .so,.exports,$@)),$(subst .so,.exports,$@),$(ASTTOPDIR)/default.exports)
+endif
+
+CC_LDFLAGS_SO=$(PTHREAD_CFLAGS) $(ASTLDFLAGS) $(SOLINK) $(SO_SUPPRESS_SYMBOLS)
+CXX_LDFLAGS_SO=$(PTHREAD_CFLAGS) $(ASTLDFLAGS) $(SOLINK) $(SO_SUPPRESS_SYMBOLS)
 CC_LIBS=$(PTHREAD_LIBS) $(LIBS)
 CXX_LIBS=$(PTHREAD_LIBS) $(LIBS)
 
diff --git a/build_tools/strip_nonapi b/build_tools/strip_nonapi
deleted file mode 100755 (executable)
index ade30c9..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-#!/bin/sh -e
-
-# This script is designed to remove all non-API global symbols from an object
-# file. The only global symbols that should be retained are those that belong
-# to the official namespace. Unfortunately doing this is platform-specific, as
-# the object file manipulation tools are not consistent across platforms.
-#
-# On platforms where this script does not know what to do, the object file
-# will retain non-API global symbols, and this may have unpleasant side effects.
-#
-# Prefixes that belong to the official namespace are:
-#      ast_
-#      _ast_
-#      __ast_
-#      astman_
-#      pbx_
-
-case "${PROC}" in
-       powerpc64)
-               TEXTSYM=" D "
-               ;;
-       *)
-               TEXTSYM=" T "
-               ;;
-esac
-
-FILTER="${GREP} -v -e ^ast_ -e ^_ast_ -e ^__ast_ -e ^astman_ -e ^pbx_"
-
-case "${OSARCH}" in
-    linux-gnu)
-       nm ${1} | ${GREP} -e "$TEXTSYM" | cut -d" " -f3 | ${FILTER} > striplist
-       sed -e "s/^/-N /" striplist | xargs -n 40 ${STRIP} ${1}
-       rm -f striplist
-       ;;
-    *)
-       ;;
-esac
diff --git a/default.exports b/default.exports
new file mode 100644 (file)
index 0000000..5e76754
--- /dev/null
@@ -0,0 +1,4 @@
+{
+       local:
+               *;
+};
index dd154ec8593d3425a482d355881d53c58281f7ce..ec841b888d48b86f197a62ad5e89d0b17e361a75 100644 (file)
@@ -188,15 +188,15 @@ int ao2_ref(void *o, int delta);
 #ifndef DEBUG_THREADS
 int ao2_lock(void *a);
 #else
-#define ao2_lock(a) _ao2_lock(a, __FILE__, __PRETTY_FUNCTION__, __LINE__, #a)
-int _ao2_lock(void *a, const char *file, const char *func, int line, const char *var);
+#define ao2_lock(a) __ao2_lock(a, __FILE__, __PRETTY_FUNCTION__, __LINE__, #a)
+int __ao2_lock(void *a, const char *file, const char *func, int line, const char *var);
 #endif
 
 #ifndef DEBUG_THREADS
 int ao2_trylock(void *a);
 #else
-#define ao2_trylock(a) _ao2_trylock(a, __FILE__, __PRETTY_FUNCTION__, __LINE__, #a)
-int _ao2_trylock(void *a, const char *file, const char *func, int line, const char *var);
+#define ao2_trylock(a) __ao2_trylock(a, __FILE__, __PRETTY_FUNCTION__, __LINE__, #a)
+int __ao2_trylock(void *a, const char *file, const char *func, int line, const char *var);
 #endif
 
 /*!
@@ -208,8 +208,8 @@ int _ao2_trylock(void *a, const char *file, const char *func, int line, const ch
 #ifndef DEBUG_THREADS
 int ao2_unlock(void *a);
 #else
-#define ao2_unlock(a) _ao2_unlock(a, __FILE__, __PRETTY_FUNCTION__, __LINE__, #a)
-int _ao2_unlock(void *a, const char *file, const char *func, int line, const char *var);
+#define ao2_unlock(a) __ao2_unlock(a, __FILE__, __PRETTY_FUNCTION__, __LINE__, #a)
+int __ao2_unlock(void *a, const char *file, const char *func, int line, const char *var);
 #endif
 
 /*!
index c8a878378d58724fa100c22da19a2b188f60478d..0b83191e06fe24bac0603865f91a45288a52e4ef 100644 (file)
@@ -94,6 +94,10 @@ ifeq ($(OSARCH),SunOS)
   ASTLINK=
 endif
 
+ifeq ($(GNU_LD),1)
+ASTLINK+=-Wl,--version-script,asterisk.exports
+endif
+
 editline/libedit.a:
        cd editline && test -f config.h || CFLAGS="$(PTHREAD_CFLAGS) $(subst $(ASTTOPDIR),../../,$(ASTCFLAGS:-Werror=))" LDFLAGS="$(ASTLDFLAGS)" ./configure --build=$(BUILD_PLATFORM) --host=$(HOST_PLATFORM) --with-ncurses=$(NCURSES_DIR) --with-curses=$(CURSES_DIR) --with-termcap=$(TERMCAP_DIR) --with-tinfo=$(TINFO_DIR)
        $(MAKE) -C editline libedit.a
@@ -133,20 +137,19 @@ else
   H323LDLIBS=
 endif
 
-asterisk: $(OBJS) editline/libedit.a db1-ast/libdb1.a $(AST_EMBED_LDSCRIPTS)
+asterisk: $(OBJS) editline/libedit.a db1-ast/libdb1.a $(AST_EMBED_LDSCRIPTS) asterisk.exports
        @$(ASTTOPDIR)/build_tools/make_build_h > $(ASTTOPDIR)/include/asterisk/build.h.tmp
        @if cmp -s $(ASTTOPDIR)/include/asterisk/build.h.tmp $(ASTTOPDIR)/include/asterisk/build.h ; then echo ; else \
                mv $(ASTTOPDIR)/include/asterisk/build.h.tmp $(ASTTOPDIR)/include/asterisk/build.h ; \
        fi
        @rm -f $(ASTTOPDIR)/include/asterisk/build.h.tmp
        @$(CC) -c -o buildinfo.o $(ASTCFLAGS) buildinfo.c
-       $(ECHO_PREFIX) echo "   [LD] $^ -> $@"
+       $(ECHO_PREFIX) echo "   [LD] $(OBJS) editline/libedit.a db1-ast/libdb1.a $(AST_EMBED_LDSCRIPTS) -> $@"
 ifneq ($(findstring chan_h323,$(MENUSELECT_CHANNELS)),)
-       $(CMD_PREFIX) $(CC) $(STATIC_BUILD) -o $@ $(ASTLINK) $(AST_EMBED_LDFLAGS) $(ASTLDFLAGS) $^ buildinfo.o $(AST_LIBS) $(AST_EMBED_LIBS)
+       $(CMD_PREFIX) $(CC) $(STATIC_BUILD) -o $@ $(ASTLINK) $(AST_EMBED_LDFLAGS) $(ASTLDFLAGS) $(OBJS) editline/libedit.a db1-ast/libdb1.a $(AST_EMBED_LDSCRIPTS) buildinfo.o $(AST_LIBS) $(AST_EMBED_LIBS)
 else
-       $(CMD_PREFIX) $(CXX) $(STATIC_BUILD) -o $@ $(ASTLINK) $(AST_EMBED_LDFLAGS) $(ASTLDFLAGS) $(H323LDFLAGS) $^ buildinfo.o $(AST_LIBS) $(AST_EMBED_LIBS) $(H323LDLIBS)
+       $(CMD_PREFIX) $(CXX) $(STATIC_BUILD) -o $@ $(ASTLINK) $(AST_EMBED_LDFLAGS) $(ASTLDFLAGS) $(H323LDFLAGS) $(OBJS) editline/libedit.a db1-ast/libdb1.a $(AST_EMBED_LDSCRIPTS) buildinfo.o $(AST_LIBS) $(AST_EMBED_LIBS) $(H323LDLIBS)
 endif
-       $(CMD_PREFIX) $(ASTTOPDIR)/build_tools/strip_nonapi $@ || rm $@
 
 clean::
        rm -f asterisk
diff --git a/main/asterisk.exports b/main/asterisk.exports
new file mode 100644 (file)
index 0000000..f18c0ff
--- /dev/null
@@ -0,0 +1,28 @@
+{
+       global:
+               ast_*;
+               _ast_*;
+               __ast_*;
+               pbx_*;
+               astman_*;
+               ao2_*;
+               __ao2_*;
+               option_debug;
+               option_verbose;
+               dahdi_chan_name;
+               dahdi_chan_name_len;
+               dahdi_chan_mode;
+               cid_di;
+               cid_dr;
+               clidsb;
+               MD5*;
+               sched_*;
+               io_*;
+               jb_*;
+               channelreloadreason2txt;
+               devstate2str;
+               manager_event;
+               dialed_interface_info;
+       local:
+               *;
+};
index 56ab75a21108d70906dacd44e875038049b248b2..8157c78cf297242f01539057fa903dfd83319090 100644 (file)
@@ -128,7 +128,7 @@ static inline struct astobj2 *INTERNAL_OBJ(void *user_data)
 #ifndef DEBUG_THREADS
 int ao2_lock(void *user_data)
 #else
-int _ao2_lock(void *user_data, const char *file, const char *func, int line, const char *var)
+int __ao2_lock(void *user_data, const char *file, const char *func, int line, const char *var)
 #endif
 {
        struct astobj2 *p = INTERNAL_OBJ(user_data);
@@ -150,7 +150,7 @@ int _ao2_lock(void *user_data, const char *file, const char *func, int line, con
 #ifndef DEBUG_THREADS
 int ao2_trylock(void *user_data)
 #else
-int _ao2_trylock(void *user_data, const char *file, const char *func, int line, const char *var)
+int __ao2_trylock(void *user_data, const char *file, const char *func, int line, const char *var)
 #endif
 {
        struct astobj2 *p = INTERNAL_OBJ(user_data);
@@ -177,7 +177,7 @@ int _ao2_trylock(void *user_data, const char *file, const char *func, int line,
 #ifndef DEBUG_THREADS
 int ao2_unlock(void *user_data)
 #else
-int _ao2_unlock(void *user_data, const char *file, const char *func, int line, const char *var)
+int __ao2_unlock(void *user_data, const char *file, const char *func, int line, const char *var)
 #endif
 {
        struct astobj2 *p = INTERNAL_OBJ(user_data);
index 790ba6e864408e3a2f66bbf3903e560ba7613b0d..f680cd76d8bb6cee34f0f5a71c0ff08658068133 100644 (file)
@@ -43,6 +43,8 @@ GC_LDFLAGS=@GC_LDFLAGS@
 PTHREAD_CFLAGS=@PTHREAD_CFLAGS@
 PTHREAD_LIBS=@PTHREAD_LIBS@
 
+GNU_LD=@GNU_LD@
+
 prefix = @prefix@
 exec_prefix = @exec_prefix@
 
diff --git a/res/res_adsi.exports b/res/res_adsi.exports
new file mode 100644 (file)
index 0000000..a4119dc
--- /dev/null
@@ -0,0 +1,33 @@
+{
+       global:
+               ast_adsi_available;
+               ast_adsi_begin_download;
+               ast_adsi_channel_restore;
+               ast_adsi_clear_screen;
+               ast_adsi_clear_soft_keys;
+               ast_adsi_connect_session;
+               ast_adsi_data_mode;
+               ast_adsi_disconnect_session;
+               ast_adsi_display;
+               ast_adsi_download_connect;
+               ast_adsi_download_disconnect;
+               ast_adsi_end_download;
+               ast_adsi_get_cpeid;
+               ast_adsi_get_cpeinfo;
+               ast_adsi_input_control;
+               ast_adsi_input_format;
+               ast_adsi_load_session;
+               ast_adsi_load_soft_key;
+               ast_adsi_print;
+               ast_adsi_query_cpeid;
+               ast_adsi_query_cpeinfo;
+               ast_adsi_read_encoded_dtmf;
+               ast_adsi_set_keys;
+               ast_adsi_set_line;
+               ast_adsi_transmit_message;
+               ast_adsi_transmit_message_full;
+               ast_adsi_unload_session;
+               ast_adsi_voice_mode;
+       local:
+               *;
+};
diff --git a/res/res_agi.exports b/res/res_agi.exports
new file mode 100644 (file)
index 0000000..e1b1196
--- /dev/null
@@ -0,0 +1,7 @@
+{
+       global:
+               ast_agi_register;
+               ast_agi_unregister;
+       local:
+               *;
+};
index 7f11b5db356123b6bddd8404d6a1dd4cb05e00fe..5c3c1f6693d88317f07b4bafb2e2511f62b71c48 100644 (file)
@@ -558,7 +558,7 @@ static int load_module (void)
        return 0;
 }
 
-AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_GLOBAL_SYMBOLS, "ODBC Configuration",
+AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "ODBC Configuration",
                .load = load_module,
                .unload = unload_module,
                );
index 494497033c61fe9940cccd335d52d04bf3f21280..986223480488e2512895ec51a32833816d6bcc20 100644 (file)
@@ -835,7 +835,7 @@ static int realtime_pgsql_status(int fd, int argc, char **argv)
 }
 
 /* needs usecount semantics defined */
-AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_GLOBAL_SYMBOLS, "PostgreSQL RealTime Configuration Driver",
+AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "PostgreSQL RealTime Configuration Driver",
                .load = load_module,
                .unload = unload_module,
                .reload = reload
index c2c33d0158afaeed66b9406b97353347f77e83a2..8fd78c498af68e745f08c7cfe470d41d7df7385b 100644 (file)
@@ -624,7 +624,7 @@ static int unload_module(void)
 }
 
 /* needs usecount semantics defined */
-AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_GLOBAL_SYMBOLS, "Cryptographic Digital Signatures",
+AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "Cryptographic Digital Signatures",
                .load = load_module,
                .unload = unload_module,
                .reload = reload
diff --git a/res/res_features.exports b/res/res_features.exports
new file mode 100644 (file)
index 0000000..344a652
--- /dev/null
@@ -0,0 +1,13 @@
+{
+       global:
+               ast_bridge_call;
+               ast_masq_park_call;
+               ast_park_call;
+               ast_parking_ext;
+               ast_pickup_call;
+               ast_pickup_ext;
+               ast_register_feature;
+               ast_unregister_feature;
+       local:
+               *;
+};
index 9bff10b76e8fca6aa4831f6b0110f5fa779d7a78..b1c948c95cf7e4fe6708259373ad232b25e1569a 100644 (file)
@@ -399,7 +399,7 @@ static int reload(void)
        return ind_load_module();
 }
 
-AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_GLOBAL_SYMBOLS, "Indications Resource",
+AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "Indications Resource",
                .load = load_module,
                .unload = unload_module,
                .reload = reload,
diff --git a/res/res_jabber.exports b/res/res_jabber.exports
new file mode 100644 (file)
index 0000000..8df1fee
--- /dev/null
@@ -0,0 +1,13 @@
+{
+       global:
+               ast_aji_create_chat;
+               ast_aji_disconnect;
+               ast_aji_get_client;
+               ast_aji_get_clients;
+               ast_aji_increment_mid;
+               ast_aji_invite_chat;
+               ast_aji_join_chat;
+               ast_aji_send;
+       local:
+               *;
+};
diff --git a/res/res_monitor.exports b/res/res_monitor.exports
new file mode 100644 (file)
index 0000000..4352dc8
--- /dev/null
@@ -0,0 +1,11 @@
+{
+       global:
+               ast_monitor_change_fname;
+               ast_monitor_pause;
+               ast_monitor_setjoinfiles;
+               ast_monitor_start;
+               ast_monitor_stop;
+               ast_monitor_unpause;
+       local:
+               *;
+};
index cd8bb3e1007c6df1420cd64a0ed7a50268e393c4..95fe16ec2a0f3dc166db3d967c51a96615c65f8a 100644 (file)
@@ -1486,7 +1486,7 @@ static int unload_module(void)
        return res;
 }
 
-AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_GLOBAL_SYMBOLS, "Music On Hold Resource",
+AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "Music On Hold Resource",
        .load = load_module,
        .unload = unload_module,
        .reload = reload,
diff --git a/res/res_odbc.exports b/res/res_odbc.exports
new file mode 100644 (file)
index 0000000..1e38d49
--- /dev/null
@@ -0,0 +1,11 @@
+{
+       global:
+               ast_odbc_backslash_is_escape;
+               ast_odbc_prepare_and_execute;
+               ast_odbc_release_obj;
+               ast_odbc_request_obj;
+               ast_odbc_sanity_check;
+               ast_odbc_smart_execute;
+       local:
+               *;
+};
diff --git a/res/res_smdi.exports b/res/res_smdi.exports
new file mode 100644 (file)
index 0000000..7fe3edf
--- /dev/null
@@ -0,0 +1,18 @@
+{
+       global:
+               ast_smdi_interface_find;
+               ast_smdi_interface_unref;
+               ast_smdi_md_message_destroy;
+               ast_smdi_md_message_pop;
+               ast_smdi_md_message_putback;
+               ast_smdi_md_message_wait;
+               ast_smdi_mwi_message_destroy;
+               ast_smdi_mwi_message_pop;
+               ast_smdi_mwi_message_putback;
+               ast_smdi_mwi_message_wait;
+               ast_smdi_mwi_message_wait_station;
+               ast_smdi_mwi_set;
+               ast_smdi_mwi_unset;
+       local:
+               *;
+};
index 6bbf231718935bc0c8f738e881dbb7cc7b54b2c2..5ec0419ade91465c3f64159bafec2d73ac1d5fe6 100644 (file)
@@ -109,7 +109,7 @@ static int unload_module(void)
        return ((thread != AST_PTHREADT_NULL) ? pthread_join(thread, NULL) : 0);
 }
 
-AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_GLOBAL_SYMBOLS, "SNMP [Sub]Agent for Asterisk",
+AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "SNMP [Sub]Agent for Asterisk",
                .load = load_module,
                .unload = unload_module,
                );
diff --git a/res/res_speech.exports b/res/res_speech.exports
new file mode 100644 (file)
index 0000000..2266607
--- /dev/null
@@ -0,0 +1,21 @@
+{
+       global:
+               ast_speech_change;
+               ast_speech_change_results_type;
+               ast_speech_change_state;
+               ast_speech_destroy;
+               ast_speech_dtmf;
+               ast_speech_grammar_activate;
+               ast_speech_grammar_deactivate;
+               ast_speech_grammar_load;
+               ast_speech_grammar_unload;
+               ast_speech_new;
+               ast_speech_register;
+               ast_speech_results_free;
+               ast_speech_results_get;
+               ast_speech_start;
+               ast_speech_unregister;
+               ast_speech_write;
+       local:
+               *;
+};