|
|
00c0d4 |
commit db27f1251b008280a29d540b4f8ab2a38a0d80af
|
|
|
00c0d4 |
Author: Siddhesh Poyarekar <siddhesh@sourceware.org>
|
|
|
00c0d4 |
Date: Wed Jan 12 23:34:23 2022 +0530
|
|
|
00c0d4 |
|
|
|
00c0d4 |
debug: Autogenerate _FORTIFY_SOURCE tests
|
|
|
00c0d4 |
|
|
|
00c0d4 |
Rename debug/tst-chk1.c to debug/tst-fortify.c and add make hackery to
|
|
|
00c0d4 |
autogenerate tests with different macros enabled to build and run the
|
|
|
00c0d4 |
same test with different configurations as well as different
|
|
|
00c0d4 |
fortification levels.
|
|
|
00c0d4 |
|
|
|
00c0d4 |
The change also ends up expanding the -lfs tests to include
|
|
|
00c0d4 |
_FORTIFY_SOURCE=3.
|
|
|
00c0d4 |
|
|
|
00c0d4 |
Signed-off-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
|
|
|
00c0d4 |
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
|
|
|
00c0d4 |
|
|
|
00c0d4 |
# Conflicts:
|
|
|
00c0d4 |
# debug/Makefile
|
|
|
00c0d4 |
|
|
|
00c0d4 |
diff --git a/Makerules b/Makerules
|
|
|
00c0d4 |
index 5d6434c74bf9bfe5..05a549eb0f259113 100644
|
|
|
00c0d4 |
--- a/Makerules
|
|
|
00c0d4 |
+++ b/Makerules
|
|
|
00c0d4 |
@@ -444,6 +444,12 @@ $(objpfx)%$o: $(objpfx)%.c $(before-compile); $$(compile-command.c)
|
|
|
00c0d4 |
endef
|
|
|
00c0d4 |
object-suffixes-left := $(all-object-suffixes)
|
|
|
00c0d4 |
include $(o-iterator)
|
|
|
00c0d4 |
+
|
|
|
00c0d4 |
+define o-iterator-doit
|
|
|
00c0d4 |
+$(objpfx)%$o: $(objpfx)%.cc $(before-compile); $$(compile-command.cc)
|
|
|
00c0d4 |
+endef
|
|
|
00c0d4 |
+object-suffixes-left := $(all-object-suffixes)
|
|
|
00c0d4 |
+include $(o-iterator)
|
|
|
00c0d4 |
endif
|
|
|
00c0d4 |
|
|
|
00c0d4 |
# Generate version maps, but wait until sysdep-subdirs is known
|
|
|
00c0d4 |
diff --git a/debug/Makefile b/debug/Makefile
|
|
|
00c0d4 |
index b43f42ee3851f360..c92fd23dda1a7279 100644
|
|
|
00c0d4 |
--- a/debug/Makefile
|
|
|
00c0d4 |
+++ b/debug/Makefile
|
|
|
00c0d4 |
@@ -1,4 +1,5 @@
|
|
|
00c0d4 |
-# Copyright (C) 1998-2018 Free Software Foundation, Inc.
|
|
|
00c0d4 |
+# Copyright (C) 1998-2022 Free Software Foundation, Inc.
|
|
|
00c0d4 |
+# Copyright The GNU Toolchain Authors.
|
|
|
00c0d4 |
# This file is part of the GNU C Library.
|
|
|
00c0d4 |
|
|
|
00c0d4 |
# The GNU C Library is free software; you can redistribute it and/or
|
|
|
00c0d4 |
@@ -110,32 +111,60 @@ CFLAGS-tst-longjmp_chk3.c += -fexceptions -fasynchronous-unwind-tables
|
|
|
00c0d4 |
CPPFLAGS-tst-longjmp_chk3.c += -D_FORTIFY_SOURCE=1
|
|
|
00c0d4 |
CPPFLAGS-tst-realpath-chk.c += -D_FORTIFY_SOURCE=2
|
|
|
00c0d4 |
|
|
|
00c0d4 |
+# _FORTIFY_SOURCE tests.
|
|
|
00c0d4 |
+# Auto-generate tests for _FORTIFY_SOURCE for different levels, compilers and
|
|
|
00c0d4 |
+# preprocessor conditions based on tst-fortify.c.
|
|
|
00c0d4 |
+#
|
|
|
00c0d4 |
+# To add a new test condition, define a cflags-$(cond) make variable to set
|
|
|
00c0d4 |
+# CFLAGS for the file.
|
|
|
00c0d4 |
+
|
|
|
00c0d4 |
+tests-all-chk = tst-fortify
|
|
|
00c0d4 |
+tests-c-chk =
|
|
|
00c0d4 |
+tests-cc-chk =
|
|
|
00c0d4 |
+
|
|
|
00c0d4 |
+CFLAGS-tst-fortify.c += -Wno-format -Wno-deprecated-declarations -Wno-error
|
|
|
00c0d4 |
+
|
|
|
00c0d4 |
+# No additional flags for the default tests.
|
|
|
00c0d4 |
+define cflags-default
|
|
|
00c0d4 |
+endef
|
|
|
00c0d4 |
+
|
|
|
00c0d4 |
+define cflags-lfs
|
|
|
00c0d4 |
+CFLAGS-tst-fortify-$(1)-lfs-$(2).$(1) += -D_FILE_OFFSET_BITS=64
|
|
|
00c0d4 |
+endef
|
|
|
00c0d4 |
+
|
|
|
00c0d4 |
# We know these tests have problems with format strings, this is what
|
|
|
00c0d4 |
# we are testing. Disable that warning. They are also testing
|
|
|
00c0d4 |
# deprecated functions (notably gets) so disable that warning as well.
|
|
|
00c0d4 |
# And they also generate warnings from warning attributes, which
|
|
|
00c0d4 |
# cannot be disabled via pragmas, so require -Wno-error to be used.
|
|
|
00c0d4 |
-CFLAGS-tst-chk1.c += -Wno-format -Wno-deprecated-declarations -Wno-error
|
|
|
00c0d4 |
-CFLAGS-tst-chk2.c += -Wno-format -Wno-deprecated-declarations -Wno-error
|
|
|
00c0d4 |
-CFLAGS-tst-chk3.c += -Wno-format -Wno-deprecated-declarations -Wno-error
|
|
|
00c0d4 |
-CFLAGS-tst-chk4.cc += -Wno-format -Wno-deprecated-declarations -Wno-error
|
|
|
00c0d4 |
-CFLAGS-tst-chk5.cc += -Wno-format -Wno-deprecated-declarations -Wno-error
|
|
|
00c0d4 |
-CFLAGS-tst-chk6.cc += -Wno-format -Wno-deprecated-declarations -Wno-error
|
|
|
00c0d4 |
-CFLAGS-tst-chk7.c += -Wno-format -Wno-deprecated-declarations -Wno-error
|
|
|
00c0d4 |
-CFLAGS-tst-chk8.cc += -Wno-format -Wno-deprecated-declarations -Wno-error
|
|
|
00c0d4 |
-CFLAGS-tst-lfschk1.c += -Wno-format -Wno-deprecated-declarations -Wno-error
|
|
|
00c0d4 |
-CFLAGS-tst-lfschk2.c += -Wno-format -Wno-deprecated-declarations -Wno-error
|
|
|
00c0d4 |
-CFLAGS-tst-lfschk3.c += -Wno-format -Wno-deprecated-declarations -Wno-error
|
|
|
00c0d4 |
-CFLAGS-tst-lfschk4.cc += -Wno-format -Wno-deprecated-declarations -Wno-error
|
|
|
00c0d4 |
-CFLAGS-tst-lfschk5.cc += -Wno-format -Wno-deprecated-declarations -Wno-error
|
|
|
00c0d4 |
-CFLAGS-tst-lfschk6.cc += -Wno-format -Wno-deprecated-declarations -Wno-error
|
|
|
00c0d4 |
-LDLIBS-tst-chk4 = -lstdc++
|
|
|
00c0d4 |
-LDLIBS-tst-chk5 = -lstdc++
|
|
|
00c0d4 |
-LDLIBS-tst-chk6 = -lstdc++
|
|
|
00c0d4 |
-LDLIBS-tst-chk8 = -lstdc++
|
|
|
00c0d4 |
-LDLIBS-tst-lfschk4 = -lstdc++
|
|
|
00c0d4 |
-LDLIBS-tst-lfschk5 = -lstdc++
|
|
|
00c0d4 |
-LDLIBS-tst-lfschk6 = -lstdc++
|
|
|
00c0d4 |
+define gen-chk-test
|
|
|
00c0d4 |
+tests-$(1)-chk += tst-fortify-$(1)-$(2)-$(3)
|
|
|
00c0d4 |
+CFLAGS-tst-fortify-$(1)-$(2)-$(3).$(1) += -D_FORTIFY_SOURCE=$(3) -Wno-format \
|
|
|
00c0d4 |
+ -Wno-deprecated-declarations \
|
|
|
00c0d4 |
+ -Wno-error
|
|
|
00c0d4 |
+$(eval $(call cflags-$(2),$(1),$(3)))
|
|
|
00c0d4 |
+$(objpfx)tst-fortify-$(1)-$(2)-$(3).$(1): tst-fortify.c Makefile
|
|
|
00c0d4 |
+ ( echo "/* Autogenerated from Makefile. */"; \
|
|
|
00c0d4 |
+ echo ""; \
|
|
|
00c0d4 |
+ echo "#include \"tst-fortify.c\"" ) > $$@.tmp
|
|
|
00c0d4 |
+ mv $$@.tmp $$@
|
|
|
00c0d4 |
+endef
|
|
|
00c0d4 |
+
|
|
|
00c0d4 |
+chk-extensions = c cc
|
|
|
00c0d4 |
+chk-types = default lfs
|
|
|
00c0d4 |
+chk-levels = 1 2 3
|
|
|
00c0d4 |
+
|
|
|
00c0d4 |
+$(foreach e,$(chk-extensions), \
|
|
|
00c0d4 |
+ $(foreach t,$(chk-types), \
|
|
|
00c0d4 |
+ $(foreach l,$(chk-levels), \
|
|
|
00c0d4 |
+ $(eval $(call gen-chk-test,$(e),$(t),$(l))))))
|
|
|
00c0d4 |
+
|
|
|
00c0d4 |
+tests-all-chk += $(tests-c-chk) $(tests-cc-chk)
|
|
|
00c0d4 |
+
|
|
|
00c0d4 |
+define link-cc
|
|
|
00c0d4 |
+LDLIBS-$(1) = -lstdc++
|
|
|
00c0d4 |
+endef
|
|
|
00c0d4 |
+$(foreach t,$(tests-cc-chk), $(eval $(call link-cc,$(t))))
|
|
|
00c0d4 |
|
|
|
00c0d4 |
# backtrace_symbols only works if we link with -rdynamic. backtrace
|
|
|
00c0d4 |
# requires unwind tables on most architectures.
|
|
|
00c0d4 |
@@ -152,19 +181,25 @@ LDFLAGS-tst-backtrace6 = -rdynamic
|
|
|
00c0d4 |
|
|
|
00c0d4 |
CFLAGS-tst-ssp-1.c += -fstack-protector-all
|
|
|
00c0d4 |
|
|
|
00c0d4 |
-tests = backtrace-tst tst-longjmp_chk tst-chk1 tst-chk2 tst-chk3 \
|
|
|
00c0d4 |
- tst-lfschk1 tst-lfschk2 tst-lfschk3 test-strcpy_chk test-stpcpy_chk \
|
|
|
00c0d4 |
- tst-chk4 tst-chk5 tst-chk6 tst-chk7 tst-chk8 tst-lfschk4 tst-lfschk5 \
|
|
|
00c0d4 |
- tst-lfschk6 tst-longjmp_chk2 tst-backtrace2 tst-backtrace3 \
|
|
|
00c0d4 |
- tst-backtrace4 tst-backtrace5 tst-backtrace6 tst-realpath-chk
|
|
|
00c0d4 |
+tests = backtrace-tst \
|
|
|
00c0d4 |
+ tst-longjmp_chk \
|
|
|
00c0d4 |
+ test-strcpy_chk \
|
|
|
00c0d4 |
+ test-stpcpy_chk \
|
|
|
00c0d4 |
+ tst-longjmp_chk2 \
|
|
|
00c0d4 |
+ tst-backtrace2 \
|
|
|
00c0d4 |
+ tst-backtrace3 \
|
|
|
00c0d4 |
+ tst-backtrace4 \
|
|
|
00c0d4 |
+ tst-backtrace5 \
|
|
|
00c0d4 |
+ tst-backtrace6 \
|
|
|
00c0d4 |
+ tst-realpath-chk \
|
|
|
00c0d4 |
+ $(tests-all-chk)
|
|
|
00c0d4 |
|
|
|
00c0d4 |
ifeq ($(have-ssp),yes)
|
|
|
00c0d4 |
tests += tst-ssp-1
|
|
|
00c0d4 |
endif
|
|
|
00c0d4 |
|
|
|
00c0d4 |
ifeq (,$(CXX))
|
|
|
00c0d4 |
-tests-unsupported = tst-chk4 tst-chk5 tst-chk6 tst-chk8 \
|
|
|
00c0d4 |
- tst-lfschk4 tst-lfschk5 tst-lfschk6
|
|
|
00c0d4 |
+tests-unsupported = $(tests-cc-chk)
|
|
|
00c0d4 |
endif
|
|
|
00c0d4 |
|
|
|
00c0d4 |
extra-libs = libSegFault libpcprofile
|
|
|
00c0d4 |
@@ -191,20 +226,10 @@ ifeq ($(run-built-tests),yes)
|
|
|
00c0d4 |
LOCALES := de_DE.UTF-8
|
|
|
00c0d4 |
include ../gen-locales.mk
|
|
|
00c0d4 |
|
|
|
00c0d4 |
-$(objpfx)tst-chk1.out: $(gen-locales)
|
|
|
00c0d4 |
-$(objpfx)tst-chk2.out: $(gen-locales)
|
|
|
00c0d4 |
-$(objpfx)tst-chk3.out: $(gen-locales)
|
|
|
00c0d4 |
-$(objpfx)tst-chk4.out: $(gen-locales)
|
|
|
00c0d4 |
-$(objpfx)tst-chk5.out: $(gen-locales)
|
|
|
00c0d4 |
-$(objpfx)tst-chk6.out: $(gen-locales)
|
|
|
00c0d4 |
-$(objpfx)tst-chk7.out: $(gen-locales)
|
|
|
00c0d4 |
-$(objpfx)tst-chk8.out: $(gen-locales)
|
|
|
00c0d4 |
-$(objpfx)tst-lfschk1.out: $(gen-locales)
|
|
|
00c0d4 |
-$(objpfx)tst-lfschk2.out: $(gen-locales)
|
|
|
00c0d4 |
-$(objpfx)tst-lfschk3.out: $(gen-locales)
|
|
|
00c0d4 |
-$(objpfx)tst-lfschk4.out: $(gen-locales)
|
|
|
00c0d4 |
-$(objpfx)tst-lfschk5.out: $(gen-locales)
|
|
|
00c0d4 |
-$(objpfx)tst-lfschk6.out: $(gen-locales)
|
|
|
00c0d4 |
+define chk-gen-locales
|
|
|
00c0d4 |
+$(objpfx)$(1).out: $(gen-locales)
|
|
|
00c0d4 |
+endef
|
|
|
00c0d4 |
+$(foreach t, $(tests-all-chk), $(eval $(call chk-gen-locales,$(t))))
|
|
|
00c0d4 |
endif
|
|
|
00c0d4 |
|
|
|
00c0d4 |
sLIBdir := $(shell echo $(slibdir) | sed 's,lib\(\|64\)$$,\\\\$$LIB,')
|
|
|
00c0d4 |
diff --git a/debug/tst-chk2.c b/debug/tst-chk2.c
|
|
|
00c0d4 |
deleted file mode 100644
|
|
|
00c0d4 |
index be37ce2d22f0760a..0000000000000000
|
|
|
00c0d4 |
--- a/debug/tst-chk2.c
|
|
|
00c0d4 |
+++ /dev/null
|
|
|
00c0d4 |
@@ -1,2 +0,0 @@
|
|
|
00c0d4 |
-#define _FORTIFY_SOURCE 1
|
|
|
00c0d4 |
-#include "tst-chk1.c"
|
|
|
00c0d4 |
diff --git a/debug/tst-chk3.c b/debug/tst-chk3.c
|
|
|
00c0d4 |
deleted file mode 100644
|
|
|
00c0d4 |
index 38b8e4fb360ba722..0000000000000000
|
|
|
00c0d4 |
--- a/debug/tst-chk3.c
|
|
|
00c0d4 |
+++ /dev/null
|
|
|
00c0d4 |
@@ -1,2 +0,0 @@
|
|
|
00c0d4 |
-#define _FORTIFY_SOURCE 2
|
|
|
00c0d4 |
-#include "tst-chk1.c"
|
|
|
00c0d4 |
diff --git a/debug/tst-chk4.cc b/debug/tst-chk4.cc
|
|
|
00c0d4 |
deleted file mode 100644
|
|
|
00c0d4 |
index c82e6aac86038791..0000000000000000
|
|
|
00c0d4 |
--- a/debug/tst-chk4.cc
|
|
|
00c0d4 |
+++ /dev/null
|
|
|
00c0d4 |
@@ -1 +0,0 @@
|
|
|
00c0d4 |
-#include "tst-chk1.c"
|
|
|
00c0d4 |
diff --git a/debug/tst-chk5.cc b/debug/tst-chk5.cc
|
|
|
00c0d4 |
deleted file mode 100644
|
|
|
00c0d4 |
index be37ce2d22f0760a..0000000000000000
|
|
|
00c0d4 |
--- a/debug/tst-chk5.cc
|
|
|
00c0d4 |
+++ /dev/null
|
|
|
00c0d4 |
@@ -1,2 +0,0 @@
|
|
|
00c0d4 |
-#define _FORTIFY_SOURCE 1
|
|
|
00c0d4 |
-#include "tst-chk1.c"
|
|
|
00c0d4 |
diff --git a/debug/tst-chk6.cc b/debug/tst-chk6.cc
|
|
|
00c0d4 |
deleted file mode 100644
|
|
|
00c0d4 |
index 38b8e4fb360ba722..0000000000000000
|
|
|
00c0d4 |
--- a/debug/tst-chk6.cc
|
|
|
00c0d4 |
+++ /dev/null
|
|
|
00c0d4 |
@@ -1,2 +0,0 @@
|
|
|
00c0d4 |
-#define _FORTIFY_SOURCE 2
|
|
|
00c0d4 |
-#include "tst-chk1.c"
|
|
|
00c0d4 |
diff --git a/debug/tst-chk7.c b/debug/tst-chk7.c
|
|
|
00c0d4 |
deleted file mode 100644
|
|
|
00c0d4 |
index 2a7b32381268135c..0000000000000000
|
|
|
00c0d4 |
--- a/debug/tst-chk7.c
|
|
|
00c0d4 |
+++ /dev/null
|
|
|
00c0d4 |
@@ -1,2 +0,0 @@
|
|
|
00c0d4 |
-#define _FORTIFY_SOURCE 3
|
|
|
00c0d4 |
-#include "tst-chk1.c"
|
|
|
00c0d4 |
diff --git a/debug/tst-chk8.cc b/debug/tst-chk8.cc
|
|
|
00c0d4 |
deleted file mode 100644
|
|
|
00c0d4 |
index 2a7b32381268135c..0000000000000000
|
|
|
00c0d4 |
--- a/debug/tst-chk8.cc
|
|
|
00c0d4 |
+++ /dev/null
|
|
|
00c0d4 |
@@ -1,2 +0,0 @@
|
|
|
00c0d4 |
-#define _FORTIFY_SOURCE 3
|
|
|
00c0d4 |
-#include "tst-chk1.c"
|
|
|
00c0d4 |
diff --git a/debug/tst-chk1.c b/debug/tst-fortify.c
|
|
|
00c0d4 |
similarity index 100%
|
|
|
00c0d4 |
rename from debug/tst-chk1.c
|
|
|
00c0d4 |
rename to debug/tst-fortify.c
|
|
|
00c0d4 |
diff --git a/debug/tst-lfschk1.c b/debug/tst-lfschk1.c
|
|
|
00c0d4 |
deleted file mode 100644
|
|
|
00c0d4 |
index f3e6d47d5e4484c3..0000000000000000
|
|
|
00c0d4 |
--- a/debug/tst-lfschk1.c
|
|
|
00c0d4 |
+++ /dev/null
|
|
|
00c0d4 |
@@ -1,2 +0,0 @@
|
|
|
00c0d4 |
-#define _FILE_OFFSET_BITS 64
|
|
|
00c0d4 |
-#include "tst-chk1.c"
|
|
|
00c0d4 |
diff --git a/debug/tst-lfschk2.c b/debug/tst-lfschk2.c
|
|
|
00c0d4 |
deleted file mode 100644
|
|
|
00c0d4 |
index 95d4db1d32d2eeb3..0000000000000000
|
|
|
00c0d4 |
--- a/debug/tst-lfschk2.c
|
|
|
00c0d4 |
+++ /dev/null
|
|
|
00c0d4 |
@@ -1,2 +0,0 @@
|
|
|
00c0d4 |
-#define _FILE_OFFSET_BITS 64
|
|
|
00c0d4 |
-#include "tst-chk2.c"
|
|
|
00c0d4 |
diff --git a/debug/tst-lfschk3.c b/debug/tst-lfschk3.c
|
|
|
00c0d4 |
deleted file mode 100644
|
|
|
00c0d4 |
index 50a1ae1258f1553d..0000000000000000
|
|
|
00c0d4 |
--- a/debug/tst-lfschk3.c
|
|
|
00c0d4 |
+++ /dev/null
|
|
|
00c0d4 |
@@ -1,2 +0,0 @@
|
|
|
00c0d4 |
-#define _FILE_OFFSET_BITS 64
|
|
|
00c0d4 |
-#include "tst-chk3.c"
|
|
|
00c0d4 |
diff --git a/debug/tst-lfschk4.cc b/debug/tst-lfschk4.cc
|
|
|
00c0d4 |
deleted file mode 100644
|
|
|
00c0d4 |
index f3e6d47d5e4484c3..0000000000000000
|
|
|
00c0d4 |
--- a/debug/tst-lfschk4.cc
|
|
|
00c0d4 |
+++ /dev/null
|
|
|
00c0d4 |
@@ -1,2 +0,0 @@
|
|
|
00c0d4 |
-#define _FILE_OFFSET_BITS 64
|
|
|
00c0d4 |
-#include "tst-chk1.c"
|
|
|
00c0d4 |
diff --git a/debug/tst-lfschk5.cc b/debug/tst-lfschk5.cc
|
|
|
00c0d4 |
deleted file mode 100644
|
|
|
00c0d4 |
index 95d4db1d32d2eeb3..0000000000000000
|
|
|
00c0d4 |
--- a/debug/tst-lfschk5.cc
|
|
|
00c0d4 |
+++ /dev/null
|
|
|
00c0d4 |
@@ -1,2 +0,0 @@
|
|
|
00c0d4 |
-#define _FILE_OFFSET_BITS 64
|
|
|
00c0d4 |
-#include "tst-chk2.c"
|
|
|
00c0d4 |
diff --git a/debug/tst-lfschk6.cc b/debug/tst-lfschk6.cc
|
|
|
00c0d4 |
deleted file mode 100644
|
|
|
00c0d4 |
index 50a1ae1258f1553d..0000000000000000
|
|
|
00c0d4 |
--- a/debug/tst-lfschk6.cc
|
|
|
00c0d4 |
+++ /dev/null
|
|
|
00c0d4 |
@@ -1,2 +0,0 @@
|
|
|
00c0d4 |
-#define _FILE_OFFSET_BITS 64
|
|
|
00c0d4 |
-#include "tst-chk3.c"
|