1
0

175-reduce-dynamic-syms.patch 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. --- a/tc/Makefile
  2. +++ b/tc/Makefile
  3. @@ -107,7 +107,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. @@ -137,7 +137,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. @@ -159,6 +159,7 @@ install: all
  18. clean:
  19. rm -f $(TCOBJ) $(TCLIB) libtc.a tc *.so emp_ematch.yacc.h; \
  20. rm -f emp_ematch.yacc.*
  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. @@ -198,4 +199,15 @@ 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. +dynsyms.list: $(wildcard *.c)
  31. + files="$(filter-out $(patsubst %.so,%.c,$(TCSO)), $^)" ; \
  32. + echo "{" > $@ ; \
  33. + for s in `grep -B 3 '\<dlsym' $$files | sed -n '/snprintf/{s:.*"\([^"]*\)".*:\1:;s:%s::;p}'` ; do \
  34. + sed -n '/'$$s'[^ ]* =/{s:.* \([^ ]*'$$s'[^ ]*\) .*:\1;:;p}' $$files ; \
  35. + done >> $@ ; \
  36. + echo "show_stats; print_tm; parse_rtattr; get_u32; matches; addattr_l; addattr_nest; addattr_nest_end; };" >> $@
  37. +
  38. endif