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.
---
 Makefile                    | 34 +---------------------------------
 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 +-
 include/ebtables_u.h        |  2 ++
 26 files changed, 28 insertions(+), 59 deletions(-)

diff --git a/Makefile b/Makefile
index 7c70db0..4d7b10f 100644
--- a/Makefile
+++ b/Makefile
@@ -116,39 +116,7 @@ daemon: ebtablesd ebtablesu
 # a little scripting for a static binary, making one for ebtables-restore
 # should be completely analogous
 static: extensions/ebt_*.c extensions/ebtable_*.c ebtables.c communication.c 
ebtables-standalone.c getethertype.c libebtc.c useful_functions.c
-       cp ebtables-standalone.c ebtables-standalone.c_ ; \
-       cp include/ebtables_u.h include/ebtables_u.h_ ; \
-       sed "s/ main(/ pseudomain(/" ebtables-standalone.c > 
ebtables-standalone.c__ ; \
-       mv ebtables-standalone.c__ ebtables-standalone.c ; \
-       printf "\nint main(int argc, char *argv[])\n{\n "  >> 
ebtables-standalone.c ; \
-       for arg in $(EXT_FUNC) \
-       ; do \
-       sed s/_init/_$${arg}_init/ extensions/ebt_$${arg}.c > 
extensions/ebt_$${arg}.c_ ; \
-       mv extensions/ebt_$${arg}.c_ extensions/ebt_$${arg}.c ; \
-       printf "\t%s();\n" _$${arg}_init >> ebtables-standalone.c ; \
-       printf "extern void %s();\n" _$${arg}_init >> include/ebtables_u.h ; \
-       done ; \
-       for arg in $(EXT_TABLES) \
-       ; do \
-       sed s/_init/_t_$${arg}_init/ extensions/ebtable_$${arg}.c > 
extensions/ebtable_$${arg}.c_ ; \
-       mv extensions/ebtable_$${arg}.c_ extensions/ebtable_$${arg}.c ; \
-       printf "\t%s();\n" _t_$${arg}_init >> ebtables-standalone.c ; \
-       printf "extern void %s();\n" _t_$${arg}_init >> include/ebtables_u.h ; \
-       done ; \
-       printf "\n\tpseudomain(argc, argv);\n\treturn 0;\n}\n" >> 
ebtables-standalone.c ;\
-       $(CC) $(CFLAGS) $(LDFLAGS) $(PROGSPECS) -o $@ $^ -I$(KERNEL_INCLUDES) 
-Iinclude ; \
-       for arg in $(EXT_FUNC) \
-       ; do \
-       sed "s/ .*_init/ _init/" extensions/ebt_$${arg}.c > 
extensions/ebt_$${arg}.c_ ; \
-       mv extensions/ebt_$${arg}.c_ extensions/ebt_$${arg}.c ; \
-       done ; \
-       for arg in $(EXT_TABLES) \
-       ; do \
-       sed "s/ .*_init/ _init/" extensions/ebtable_$${arg}.c > 
extensions/ebtable_$${arg}.c_ ; \
-       mv extensions/ebtable_$${arg}.c_ extensions/ebtable_$${arg}.c ; \
-       done ; \
-       mv ebtables-standalone.c_ ebtables-standalone.c ; \
-       mv include/ebtables_u.h_ include/ebtables_u.h
+       $(CC) $(CFLAGS) $(LDFLAGS) $(PROGSPECS) -o $@ $^ -I$(KERNEL_INCLUDES) 
-Iinclude
 
 tmp1:=$(shell printf $(BINDIR) | sed 's/\//\\\//g')
 tmp2:=$(shell printf $(SYSCONFIGDIR) | sed 's/\//\\\//g')
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 3deff1b..6af06b8 100644
--- a/extensions/ebt_string.c
+++ b/extensions/ebt_string.c
@@ -310,7 +310,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);
 }
diff --git a/include/ebtables_u.h b/include/ebtables_u.h
index 3235bf5..7f5968d 100644
--- a/include/ebtables_u.h
+++ b/include/ebtables_u.h
@@ -44,6 +44,8 @@
 #define EBT_ALIGN(s) (((s) + (EBT_MIN_ALIGN-1)) & ~(EBT_MIN_ALIGN-1))
 #define ERRORMSG_MAXLEN 128
 
+#define _INIT __attribute__((constructor)) _init
+
 struct ebt_u_entries
 {
        int policy;
-- 
2.17.1

--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to