1
0

175-reduce-dynamic-syms.patch 1.5 KB

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