diff options
-rw-r--r-- | Makeconfig | 19 | ||||
-rw-r--r-- | Makerules | 7 | ||||
-rw-r--r-- | Rules | 13 | ||||
-rw-r--r-- | csu/Makefile | 9 |
4 files changed, 40 insertions, 8 deletions
@@ -400,6 +400,18 @@ ifndef +link-static $(common-objpfx)libc% $(+postinit),$^) \ $(link-extra-libs-static) $(link-libc-static) $(+postctor) $(+postinit) endif +# Command for statically linking bounded-pointer programs with the C library. +ifndef +link-bounded ++link-bounded = $(CC) -nostdlib -nostartfiles -static -fbounded-pointers -o $@ \ + $(sysdep-LDFLAGS) $(LDFLAGS) \ + $(addprefix $(csu-objpfx),b$(static-start-installed-name)) \ + $(+preinit) $(+prector) \ + $(filter-out $(addprefix $(csu-objpfx),start.o \ + $(start-installed-name))\ + $(+preinit) $(link-extra-libs-bounded) \ + $(common-objpfx)libc% $(+postinit),$^) \ + $(link-extra-libs-bounded) $(link-libc-bounded) $(+postctor) $(+postinit) +endif ifndef config-LDFLAGS ifeq (yes,$(build-shared)) config-LDFLAGS = -Wl,-dynamic-linker=$(slibdir)/$(rtld-installed-name) @@ -458,6 +470,8 @@ link-libc-static = $(gnulib) $(common-objpfx)libc_pic.a link-extra-libs-static = $(link-extra-libs) endif endif +link-libc-bounded = $(common-objpfx)libc_b.a $(gnulib) $(common-objpfx)libc_b.a +link-extra-libs-bounded = $(foreach lib,$(LDLIBS-$(@F)),$(common-objpfx)$(lib)_b.a) ifndef gnulib gnulib := -lgcc @@ -486,7 +500,10 @@ run-program-prefix = $(elf-objpfx)$(rtld-installed-name) \ else run-program-prefix = endif -built-program-cmd = $(run-program-prefix) $(built-program-file) +# Never use $(run-program-prefix) for the statically-linked %-bp test programs +built-program-cmd = $(patsubst %,$(run-program-prefix),\ + $(filter-out %-bp,$(built-program-file))) \ + $(built-program-file) ifndef LD LD := ld -X @@ -948,7 +948,8 @@ clean: common-clean mostlyclean: common-mostlyclean do-tests-clean: - -rm -f $(patsubst %,$(objpfx)%.out,$(tests) $(test-srcs)) + -rm -f $(addprefix $(objpfx),$(addsuffix .out,$(tests) $(test-srcs)) \ + $(addsuffix -bp.out,$(tests) $(test-srcs))) # Remove the object files. common-mostlyclean: @@ -957,7 +958,9 @@ common-mostlyclean: $(addsuffix .o,$(tests) $(test-srcs) \ $(others) \ $(sysdep-others)) \ - $(addsuffix .out,$(tests) $(test-srcs))) + $(addsuffix -bp,$(tests) $(test-srcs)) \ + $(addsuffix .out,$(tests) $(test-srcs)) \ + $(addsuffix -bp.out,$(tests) $(test-srcs))) -rm -f $(addprefix $(objpfx),$(extra-objs) $(install-lib) \ $(install-lib.so) \ $(install-lib.so:%.so=%_pic.a)) @@ -88,7 +88,10 @@ endif ifeq ($(cross-compiling),yes) tests: $(addprefix $(objpfx),$(tests) $(test-srcs)) else -tests: $(tests:%=$(objpfx)%.out) +ifeq ($(build-bounded),yes) +tests-bp.out = $(tests:%=$(objpfx)%-bp.out) +endif +tests: $(tests:%=$(objpfx)%.out) $(tests-bp.out) endif ifeq ($(build-programs),yes) @@ -115,6 +118,14 @@ $(addprefix $(objpfx),$(binaries-static)): %: %.o \ $(+link-static) endif +ifeq ($(build-bounded),yes) +binaries-bounded = $(addsuffix -bp,$(tests) $(test-srcs)) +$(addprefix $(objpfx),$(binaries-bounded)): %-bp: %.ob \ + $(sort $(filter $(common-objpfx)lib%,$(link-libc-bounded))) \ + $(addprefix $(csu-objpfx),start.ob) $(+preinit) $(+postinit) + $(+link-bounded) +endif + ifneq "$(strip $(tests) $(test-srcs))" "" # These are the implicit rules for making test outputs # from the test programs and whatever input files are present. diff --git a/csu/Makefile b/csu/Makefile index 2b697a7..b57d3a7 100644 --- a/csu/Makefile +++ b/csu/Makefile @@ -34,10 +34,6 @@ extra-objs = start.o gmon-start.o \ omit-deps = $(patsubst %.o,%,$(start-installed-name) g$(start-installed-name) \ b$(start-installed-name) $(csu-dummies)) install-lib = $(start-installed-name) g$(start-installed-name) $(csu-dummies) -ifeq (yes,$(build-bounded)) -extra-objs += b$(start-installed-name) -install-lib += b$(start-installed-name) -endif distribute = initfini.c gmon-start.c start.c defs.awk munch.awk \ abi-note.S init.c munch-tmpl.c generated = version-info.h @@ -47,6 +43,11 @@ all: # Make this the default target; it will be defined in Rules. include ../Makeconfig +ifeq (yes,$(build-bounded)) +extra-objs += b$(start-installed-name) +install-lib += b$(start-installed-name) +endif + ifeq (yes,$(elf)) before-compile += $(objpfx)abi-tag.h generated += abi-tag.h |