From df0620e7ccb2026a3e18634632f4be5314075906 Mon Sep 17 00:00:00 2001 From: Jan Engelhardt Date: Wed, 27 Jun 2018 11:50:41 +0200 Subject: extensions: use __attribute__((constructor)) for autoregistration The ebtables initialization is easier, and, judging from the "static" recipe in Makefile, that calling ebt_*_register ahead of main is safe. This means that a static build won't need the pseudomain hack, and that -nostartfiles can also go away. Signed-off-by: Florian Westphal --- extensions/Makefile | 4 ++-- extensions/ebt_802_3.c | 2 +- extensions/ebt_among.c | 2 +- extensions/ebt_arp.c | 2 +- extensions/ebt_arpreply.c | 2 +- extensions/ebt_inat.c | 3 +-- extensions/ebt_ip.c | 2 +- extensions/ebt_ip6.c | 2 +- extensions/ebt_limit.c | 2 +- extensions/ebt_log.c | 2 +- extensions/ebt_mark.c | 2 +- extensions/ebt_mark_m.c | 2 +- extensions/ebt_nat.c | 2 +- extensions/ebt_nflog.c | 2 +- extensions/ebt_pkttype.c | 2 +- extensions/ebt_redirect.c | 2 +- extensions/ebt_standard.c | 2 +- extensions/ebt_stp.c | 2 +- extensions/ebt_string.c | 2 +- extensions/ebt_ulog.c | 2 +- extensions/ebt_vlan.c | 2 +- extensions/ebtable_broute.c | 2 +- extensions/ebtable_filter.c | 2 +- extensions/ebtable_nat.c | 2 +- 24 files changed, 25 insertions(+), 26 deletions(-) (limited to 'extensions') diff --git a/extensions/Makefile b/extensions/Makefile index 60a70a2..daa11fc 100644 --- a/extensions/Makefile +++ b/extensions/Makefile @@ -11,13 +11,13 @@ EXT_LIBSI+=$(foreach T,$(EXT_FUNC), -lebt_$(T)) EXT_LIBSI+=$(foreach T,$(EXT_TABLES), -lebtable_$(T)) extensions/ebt_%.so: extensions/ebt_%.o - $(CC) $(LDFLAGS) -shared -o $@ -lc $< -nostartfiles + $(CC) $(LDFLAGS) -shared -o $@ -lc $< extensions/libebt_%.so: extensions/ebt_%.so mv $< $@ extensions/ebtable_%.so: extensions/ebtable_%.o - $(CC) $(LDFLAGS) -shared -o $@ -lc $< -nostartfiles + $(CC) $(LDFLAGS) -shared -o $@ -lc $< extensions/libebtable_%.so: extensions/ebtable_%.so mv $< $@ diff --git a/extensions/ebt_802_3.c b/extensions/ebt_802_3.c index 4584849..d70fd44 100644 --- a/extensions/ebt_802_3.c +++ b/extensions/ebt_802_3.c @@ -141,7 +141,7 @@ static struct ebt_u_match _802_3_match = .extra_ops = opts, }; -void _init(void) +static void _INIT(void) { ebt_register_match(&_802_3_match); } diff --git a/extensions/ebt_among.c b/extensions/ebt_among.c index e4fc5ac..b1560e8 100644 --- a/extensions/ebt_among.c +++ b/extensions/ebt_among.c @@ -491,7 +491,7 @@ static struct ebt_u_match among_match = { .extra_ops = opts, }; -void _init(void) +static void _INIT(void) { ebt_register_match(&among_match); } diff --git a/extensions/ebt_arp.c b/extensions/ebt_arp.c index b281955..84b6e90 100644 --- a/extensions/ebt_arp.c +++ b/extensions/ebt_arp.c @@ -362,7 +362,7 @@ static struct ebt_u_match arp_match = .extra_ops = opts, }; -void _init(void) +static void _INIT(void) { ebt_register_match(&arp_match); } diff --git a/extensions/ebt_arpreply.c b/extensions/ebt_arpreply.c index 51eda66..399868b 100644 --- a/extensions/ebt_arpreply.c +++ b/extensions/ebt_arpreply.c @@ -133,7 +133,7 @@ static struct ebt_u_target arpreply_target = .extra_ops = opts, }; -void _init(void) +static void _INIT(void) { ebt_register_target(&arpreply_target); } diff --git a/extensions/ebt_inat.c b/extensions/ebt_inat.c index 681975d..48f65b4 100644 --- a/extensions/ebt_inat.c +++ b/extensions/ebt_inat.c @@ -379,8 +379,7 @@ static struct ebt_u_target idnat_target = .extra_ops = opts_d, }; -static void _init(void) __attribute__ ((constructor)); -static void _init(void) +static void _INIT(void) { register_target(&isnat_target); register_target(&idnat_target); diff --git a/extensions/ebt_ip.c b/extensions/ebt_ip.c index 1ffdb95..faffade 100644 --- a/extensions/ebt_ip.c +++ b/extensions/ebt_ip.c @@ -472,7 +472,7 @@ static struct ebt_u_match ip_match = .extra_ops = opts, }; -void _init(void) +static void _INIT(void) { ebt_register_match(&ip_match); } diff --git a/extensions/ebt_ip6.c b/extensions/ebt_ip6.c index 347797b..17a4303 100644 --- a/extensions/ebt_ip6.c +++ b/extensions/ebt_ip6.c @@ -413,7 +413,7 @@ static struct ebt_u_match ip6_match = .extra_ops = opts, }; -void _init(void) +static void _INIT(void) { ebt_register_match(&ip6_match); } diff --git a/extensions/ebt_limit.c b/extensions/ebt_limit.c index 2cbf4de..1fe9d84 100644 --- a/extensions/ebt_limit.c +++ b/extensions/ebt_limit.c @@ -212,7 +212,7 @@ static struct ebt_u_match limit_match = .extra_ops = opts, }; -void _init(void) +static void _INIT(void) { ebt_register_match(&limit_match); } diff --git a/extensions/ebt_log.c b/extensions/ebt_log.c index 97d5091..b5d3232 100644 --- a/extensions/ebt_log.c +++ b/extensions/ebt_log.c @@ -217,7 +217,7 @@ static struct ebt_u_watcher log_watcher = .extra_ops = opts, }; -void _init(void) +static void _INIT(void) { ebt_register_watcher(&log_watcher); } diff --git a/extensions/ebt_mark.c b/extensions/ebt_mark.c index 4cf1378..b4f93b5 100644 --- a/extensions/ebt_mark.c +++ b/extensions/ebt_mark.c @@ -172,7 +172,7 @@ static struct ebt_u_target mark_target = .extra_ops = opts, }; -void _init(void) +static void _INIT(void) { ebt_register_target(&mark_target); } diff --git a/extensions/ebt_mark_m.c b/extensions/ebt_mark_m.c index 7561f05..b6d11a2 100644 --- a/extensions/ebt_mark_m.c +++ b/extensions/ebt_mark_m.c @@ -121,7 +121,7 @@ static struct ebt_u_match mark_match = .extra_ops = opts, }; -void _init(void) +static void _INIT(void) { ebt_register_match(&mark_match); } diff --git a/extensions/ebt_nat.c b/extensions/ebt_nat.c index 00d9cd4..fe7e987 100644 --- a/extensions/ebt_nat.c +++ b/extensions/ebt_nat.c @@ -231,7 +231,7 @@ static struct ebt_u_target dnat_target = .extra_ops = opts_d, }; -void _init(void) +static void _INIT(void) { ebt_register_target(&snat_target); ebt_register_target(&dnat_target); diff --git a/extensions/ebt_nflog.c b/extensions/ebt_nflog.c index 405673a..04c547d 100644 --- a/extensions/ebt_nflog.c +++ b/extensions/ebt_nflog.c @@ -166,7 +166,7 @@ static struct ebt_u_watcher nflog_watcher = { .extra_ops = nflog_opts, }; -void _init(void) +static void _INIT(void) { ebt_register_watcher(&nflog_watcher); } diff --git a/extensions/ebt_pkttype.c b/extensions/ebt_pkttype.c index 486c85c..bf578fc 100644 --- a/extensions/ebt_pkttype.c +++ b/extensions/ebt_pkttype.c @@ -125,7 +125,7 @@ static struct ebt_u_match pkttype_match = .extra_ops = opts, }; -void _init(void) +static void _INIT(void) { ebt_register_match(&pkttype_match); } diff --git a/extensions/ebt_redirect.c b/extensions/ebt_redirect.c index 3f8227a..59fe818 100644 --- a/extensions/ebt_redirect.c +++ b/extensions/ebt_redirect.c @@ -108,7 +108,7 @@ static struct ebt_u_target redirect_target = .extra_ops = opts, }; -void _init(void) +static void _INIT(void) { ebt_register_target(&redirect_target); } diff --git a/extensions/ebt_standard.c b/extensions/ebt_standard.c index 81edead..f3c3308 100644 --- a/extensions/ebt_standard.c +++ b/extensions/ebt_standard.c @@ -84,7 +84,7 @@ static struct ebt_u_target standard = .extra_ops = opts, }; -void _init(void) +static void _INIT(void) { ebt_register_target(&standard); } diff --git a/extensions/ebt_stp.c b/extensions/ebt_stp.c index 5c5fc33..311bc63 100644 --- a/extensions/ebt_stp.c +++ b/extensions/ebt_stp.c @@ -337,7 +337,7 @@ static struct ebt_u_match stp_match = .extra_ops = opts, }; -void _init(void) +static void _INIT(void) { ebt_register_match(&stp_match); } diff --git a/extensions/ebt_string.c b/extensions/ebt_string.c index 7d24f80..97fbe19 100644 --- a/extensions/ebt_string.c +++ b/extensions/ebt_string.c @@ -312,7 +312,7 @@ static struct ebt_u_match string_match = .extra_ops = opts, }; -void _init(void) +static void _INIT(void) { ebt_register_match(&string_match); } diff --git a/extensions/ebt_ulog.c b/extensions/ebt_ulog.c index 54eec53..72a6c8b 100644 --- a/extensions/ebt_ulog.c +++ b/extensions/ebt_ulog.c @@ -180,7 +180,7 @@ static struct ebt_u_watcher ulog_watcher = .extra_ops = opts, }; -void _init(void) +static void _INIT(void) { ebt_register_watcher(&ulog_watcher); } diff --git a/extensions/ebt_vlan.c b/extensions/ebt_vlan.c index 0a37067..0818d48 100644 --- a/extensions/ebt_vlan.c +++ b/extensions/ebt_vlan.c @@ -181,7 +181,7 @@ static struct ebt_u_match vlan_match = { .extra_ops = opts, }; -void _init(void) +static void _INIT(void) { ebt_register_match(&vlan_match); } diff --git a/extensions/ebtable_broute.c b/extensions/ebtable_broute.c index 5259355..c106f08 100644 --- a/extensions/ebtable_broute.c +++ b/extensions/ebtable_broute.c @@ -23,7 +23,7 @@ ebt_u_table table = .help = print_help, }; -void _init(void) +static void _INIT(void) { ebt_register_table(&table); } diff --git a/extensions/ebtable_filter.c b/extensions/ebtable_filter.c index e41fb84..c0bf105 100644 --- a/extensions/ebtable_filter.c +++ b/extensions/ebtable_filter.c @@ -29,7 +29,7 @@ static struct ebt_u_table table = .help = print_help, }; -void _init(void) +static void _INIT(void) { ebt_register_table(&table); } diff --git a/extensions/ebtable_nat.c b/extensions/ebtable_nat.c index b21c9dd..ee04482 100644 --- a/extensions/ebtable_nat.c +++ b/extensions/ebtable_nat.c @@ -30,7 +30,7 @@ ebt_u_table table = .help = print_help, }; -void _init(void) +static void _INIT(void) { ebt_register_table(&table); } -- cgit v1.2.3