link-extra-libs-bounded): New variables.
(built-program-cmd): Omit $(run-program-prefix) for static BP tests.
* Makerules (do-tests-clean, common-mostlyclean): Remove BP test files.
* Rules (tests-bp.out): New variable.
(tests): Conditionally add BP tests.
(binaries-bounded): Add variable and associated rule.
* csu/Makefile [build-bounded] (extra-objs, install-lib):
Move conditional stuff after place where condition is defined.
$(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)
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
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
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:
$(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))
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)
$(+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.
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
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