0385bd737b25602d7f90fa655efa21af486075ac
[openwrt/staging/mkresin.git] / package / network / utils / iproute2 / patches / 175-reduce-dynamic-syms.patch
1 --- a/tc/Makefile
2 +++ b/tc/Makefile
3 @@ -111,7 +111,7 @@ LDLIBS += -L. -lm
4
5 ifeq ($(SHARED_LIBS),y)
6 LDLIBS += -ldl
7 -LDFLAGS += -Wl,-export-dynamic
8 +LDFLAGS += -Wl,--dynamic-list=dynsyms.list
9 endif
10
11 TCLIB := tc_core.o
12 @@ -141,7 +141,7 @@ MODDESTDIR := $(DESTDIR)$(LIBDIR)/tc
13 all: tc $(TCSO)
14
15 tc: $(TCOBJ) $(LIBNETLINK) libtc.a
16 - $(QUIET_LINK)$(CC) $^ $(LDFLAGS) $(LDLIBS) -o $@
17 + $(QUIET_LINK)$(CC) $(filter-out dynsyms.list, $^) $(LDFLAGS) $(LDLIBS) -o $@
18
19 libtc.a: $(TCLIB)
20 $(QUIET_AR)$(AR) rcs $@ $^
21 @@ -163,6 +163,7 @@ install: all
22 clean:
23 rm -f $(TCOBJ) $(TCLIB) libtc.a tc *.so emp_ematch.yacc.h; \
24 rm -f emp_ematch.yacc.*
25 + rm -f dynsyms.list
26
27 q_atm.so: q_atm.c
28 $(QUIET_CC)$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -shared -fpic -o q_atm.so q_atm.c -latm
29 @@ -202,4 +203,15 @@ static-syms.h: $(wildcard *.c)
30 sed -n '/'$$s'[^ ]* =/{s:.* \([^ ]*'$$s'[^ ]*\) .*:extern char \1[] __attribute__((weak)); if (!strcmp(sym, "\1")) return \1;:;p}' $$files ; \
31 done > $@
32
33 +else
34 +
35 +tc: dynsyms.list
36 +dynsyms.list: $(wildcard *.c)
37 + files="$(filter-out $(patsubst %.so,%.c,$(TCSO)), $^)" ; \
38 + echo "{" > $@ ; \
39 + for s in `grep -B 3 '\<dlsym' $$files | sed -n '/snprintf/{s:.*"\([^"]*\)".*:\1:;s:%s::;p}'` ; do \
40 + sed -n '/'$$s'[^ ]* =/{s:.* \([^ ]*'$$s'[^ ]*\) .*:\1;:;p}' $$files ; \
41 + done >> $@ ; \
42 + echo "show_stats; print_tm; parse_rtattr; get_u32; matches; addattr_l; addattr_nest; addattr_nest_end; };" >> $@
43 +
44 endif