200-add_libssp_nonshared.patch 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. From 7ec87fbbc3cac99b4173d082dd6195f47c9a32e7 Mon Sep 17 00:00:00 2001
  2. From: Steven Barth <steven@midlink.org>
  3. Date: Mon, 22 Jun 2015 11:01:56 +0200
  4. Subject: [PATCH] Add libssp_nonshared.a so GCC's is not needed
  5. Signed-off-by: Steven Barth <steven@midlink.org>
  6. --- a/Makefile
  7. +++ b/Makefile
  8. @@ -66,7 +66,7 @@ CRT_LIBS = $(addprefix lib/,$(notdir $(C
  9. STATIC_LIBS = lib/libc.a
  10. SHARED_LIBS = lib/libc.so
  11. TOOL_LIBS = lib/musl-gcc.specs
  12. -ALL_LIBS = $(CRT_LIBS) $(STATIC_LIBS) $(SHARED_LIBS) $(EMPTY_LIBS) $(TOOL_LIBS)
  13. +ALL_LIBS = $(CRT_LIBS) $(STATIC_LIBS) $(SHARED_LIBS) $(EMPTY_LIBS) $(TOOL_LIBS) lib/libssp_nonshared.a
  14. ALL_TOOLS = obj/musl-gcc
  15. WRAPCC_GCC = gcc
  16. @@ -86,7 +86,7 @@ else
  17. all: $(ALL_LIBS) $(ALL_TOOLS)
  18. -OBJ_DIRS = $(sort $(patsubst %/,%,$(dir $(ALL_LIBS) $(ALL_TOOLS) $(ALL_OBJS) $(GENH) $(GENH_INT))) obj/include)
  19. +OBJ_DIRS = $(sort $(patsubst %/,%,$(dir $(ALL_LIBS) $(ALL_TOOLS) $(ALL_OBJS) $(GENH) $(GENH_INT))) obj/include obj/libssp_nonshared)
  20. $(ALL_LIBS) $(ALL_TOOLS) $(ALL_OBJS) $(ALL_OBJS:%.o=%.lo) $(GENH) $(GENH_INT): | $(OBJ_DIRS)
  21. @@ -113,6 +113,8 @@ obj/crt/rcrt1.o: $(srcdir)/ldso/dlstart.
  22. obj/crt/Scrt1.o obj/crt/rcrt1.o: CFLAGS_ALL += -fPIC
  23. +obj/libssp_nonshared/__stack_chk_fail_local.o: CFLAGS_ALL += $(CFLAGS_NOSSP)
  24. +
  25. OPTIMIZE_SRCS = $(wildcard $(OPTIMIZE_GLOBS:%=$(srcdir)/src/%))
  26. $(OPTIMIZE_SRCS:$(srcdir)/%.c=obj/%.o) $(OPTIMIZE_SRCS:$(srcdir)/%.c=obj/%.lo): CFLAGS += -O3
  27. @@ -165,6 +167,11 @@ lib/libc.a: $(AOBJS)
  28. $(AR) rc $@ $(AOBJS)
  29. $(RANLIB) $@
  30. +lib/libssp_nonshared.a: obj/libssp_nonshared/__stack_chk_fail_local.o
  31. + rm -f $@
  32. + $(AR) rc $@ $<
  33. + $(RANLIB) $@
  34. +
  35. $(EMPTY_LIBS):
  36. rm -f $@
  37. $(AR) rc $@
  38. --- /dev/null
  39. +++ b/libssp_nonshared/__stack_chk_fail_local.c
  40. @@ -0,0 +1,2 @@
  41. +#include "atomic.h"
  42. +void __attribute__((visibility ("hidden"))) __stack_chk_fail_local(void) { a_crash(); }