use-ldflags.patch 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. Description: Use hardened LDFLAGS
  2. Add "read-only relocation" link flag when building library
  3. Author: Praveen Arimbrathodiyil <praveen@debian.org>
  4. Last-Update: 2013-06-13
  5. --- a/Makefile
  6. +++ b/Makefile
  7. @@ -11,6 +11,7 @@
  8. CFLAGS_DEBUG = $(CFLAGS) -O0 -g $(CFLAGS_DEBUG_EXTRA)
  9. CFLAGS_FAST = $(CFLAGS) -O3 $(CFLAGS_FAST_EXTRA)
  10. CFLAGS_LIB = $(CFLAGS_FAST) -fPIC
  11. +LDFLAGS +=-Wl,-soname,libhttp_parser.so.0
  12. test: test_g test_fast
  13. ./test_g
  14. @@ -32,7 +33,7 @@
  15. $(CC) $(CPPFLAGS_FAST) $(CFLAGS_FAST) -c test.c -o $@
  16. http_parser.o: http_parser.c http_parser.h Makefile
  17. - $(CC) $(CPPFLAGS_FAST) $(CFLAGS_FAST) -c http_parser.c
  18. + $(CC) $(CPPFLAGS_FAST) $(CFLAGS_FAST) $(LDFLAGS) -c http_parser.c
  19. test-run-timed: test_fast
  20. while(true) do time ./test_fast > /dev/null; done
  21. @@ -41,10 +42,10 @@
  22. valgrind ./test_g
  23. libhttp_parser.o: http_parser.c http_parser.h Makefile
  24. - $(CC) $(CPPFLAGS_FAST) $(CFLAGS_LIB) -c http_parser.c -o libhttp_parser.o
  25. + $(CC) $(CPPFLAGS_FAST) $(CFLAGS_LIB) $(LDFLAGS) -c http_parser.c -o libhttp_parser.o
  26. library: libhttp_parser.o
  27. - $(CC) -shared -o libhttp_parser.so libhttp_parser.o
  28. + $(CC) $(LDFLAGS) -shared -o libhttp_parser.so.0 libhttp_parser.o
  29. package: http_parser.o
  30. $(AR) rcs libhttp_parser.a http_parser.o
  31. @@ -66,7 +67,7 @@
  32. clean:
  33. rm -f *.o *.a tags test test_fast test_g \
  34. - http_parser.tar libhttp_parser.so \
  35. + http_parser.tar libhttp_parser.so.0 \
  36. url_parser url_parser_g parsertrace parsertrace_g
  37. contrib/url_parser.c: http_parser.h