2018-01-10 23:29:21 +08:00
|
|
|
dnl
|
|
|
|
dnl GCC_CET_FLAGS
|
|
|
|
dnl (SHELL-CODE_HANDLER)
|
|
|
|
dnl
|
|
|
|
AC_DEFUN([GCC_CET_FLAGS],[dnl
|
2020-05-16 21:07:12 +08:00
|
|
|
GCC_ENABLE(cet, auto, ,[enable Intel CET in target libraries],
|
2018-06-18 21:32:39 +08:00
|
|
|
permit yes|no|auto)
|
2018-04-06 06:22:13 +08:00
|
|
|
AC_MSG_CHECKING([for CET support])
|
|
|
|
|
2020-06-25 03:27:57 +08:00
|
|
|
# NB: Avoid nested save_CFLAGS and save_LDFLAGS.
|
2018-01-10 23:29:21 +08:00
|
|
|
case "$host" in
|
|
|
|
i[[34567]]86-*-linux* | x86_64-*-linux*)
|
|
|
|
case "$enable_cet" in
|
2018-06-18 21:32:39 +08:00
|
|
|
auto)
|
2018-04-06 06:22:13 +08:00
|
|
|
# Check if target supports multi-byte NOPs
|
sync libiberty from gcc
config/
Sync from gcc
2020-07-15 H.J. Lu <hjl.tools@gmail.com>
PR bootstrap/96202
* cet.m4 (GCC_CET_HOST_FLAGS): Don't enable CET without CET
support in stage1 nor for build support.
libiberty/
* configure: Regenerate.
Sync from gcc
2020-09-08 Alan Modra <amodra@gmail.com>
* d-demangle.c: Include limits.h.
(ULONG_MAX, UINT_MAX): Provide fall-back definition.
(dlang_number): Simplify and correct overflow test. Only
write *ret on returning non-NULL. Make "ret" an unsigned long*.
Only succeed for result of [0,UINT_MAX].
(dlang_decode_backref): Simplify and correct overflow test.
Only write *ret on returning non-NULL. Only succeed for
result [1,MAX_LONG].
(dlang_backref): Remove now unnecessary range check.
(dlang_symbol_name_p): Likewise.
(string_need): Take a size_t n arg, and use size_t tem.
(string_append): Use size_t n.
(string_appendn, string_prependn): Take a size_t n arg.
(TEMPLATE_LENGTH_UNKNOWN): Define as -1UL.
(dlang_lname, dlang_parse_template): Take an unsigned long len
arg.
(dlang_symbol_backref, dlang_identifier, dlang_parse_integer),
(dlang_parse_integer, dlang_parse_string),
(dlang_parse_arrayliteral, dlang_parse_assocarray),
(dlang_parse_structlit, dlang_parse_tuple),
(dlang_template_symbol_param, dlang_template_args): Use
unsigned long variables.
* testsuite/d-demangle-expected: Add new tests.
2020-08-04 Iain Buclaw <ibuclaw@gdcproject.org>
* d-demangle.c (dlang_function_args): Handle 'in' and 'in ref'
parameter storage classes.
(dlang_type): Remove identifier type.
* testsuite/d-demangle-expected: Update tests.
2020-08-03 Richard Biener <rguenther@suse.de>
PR lto/96385
* simple-object-elf.c
(simple_object_elf_copy_lto_debug_sections): Localize global
UNDEFs and reuse the prevailing name.
2020-07-10 Ian Lance Taylor <iant@golang.org>
PR demangler/96143
* cp-demangle.c (d_lambda): Don't add substitution candidate.
* testsuite/demangle-expected: Update a few existing test cases
accordingly, and add a new test case.
2020-07-04 Jason Merrill <jason@redhat.com>
* cp-demangle.c (cplus_demangle_operators): Add di, dx, dX.
(d_expression_1): Handle di and dX.
(is_designated_init, d_maybe_print_designated_init): New.
(d_print_comp_inner): Use d_maybe_print_designated_init.
* testsuite/demangle-expected: Add designator tests.
2020-06-25 Nick Clifton <nickc@redhat.com>
* bsearch.c (bsearch): Remove use of register keyword.
* bsearch_r.c (bsearch_r): Likewise.
2020-09-08 17:27:15 +08:00
|
|
|
# and if compiler and assembler support CET insn.
|
2020-06-25 03:27:57 +08:00
|
|
|
cet_save_CFLAGS="$CFLAGS"
|
2020-05-16 21:07:12 +08:00
|
|
|
CFLAGS="$CFLAGS -fcf-protection"
|
2018-01-10 23:29:21 +08:00
|
|
|
AC_COMPILE_IFELSE(
|
|
|
|
[AC_LANG_PROGRAM(
|
|
|
|
[],
|
2018-04-06 06:22:13 +08:00
|
|
|
[
|
|
|
|
#if !defined(__SSE2__)
|
|
|
|
#error target does not support multi-byte NOPs
|
|
|
|
#else
|
|
|
|
asm ("setssbsy");
|
|
|
|
#endif
|
|
|
|
])],
|
2018-01-10 23:29:21 +08:00
|
|
|
[enable_cet=yes],
|
|
|
|
[enable_cet=no])
|
2020-06-25 03:27:57 +08:00
|
|
|
CFLAGS="$cet_save_CFLAGS"
|
2018-01-10 23:29:21 +08:00
|
|
|
;;
|
|
|
|
yes)
|
|
|
|
# Check if assembler supports CET.
|
|
|
|
AC_COMPILE_IFELSE(
|
|
|
|
[AC_LANG_PROGRAM(
|
|
|
|
[],
|
|
|
|
[asm ("setssbsy");])],
|
|
|
|
[],
|
|
|
|
[AC_MSG_ERROR([assembler with CET support is required for --enable-cet])])
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
enable_cet=no
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
if test x$enable_cet = xyes; then
|
2018-06-18 21:32:39 +08:00
|
|
|
$1="-fcf-protection -mshstk"
|
2018-04-06 06:22:13 +08:00
|
|
|
AC_MSG_RESULT([yes])
|
|
|
|
else
|
|
|
|
AC_MSG_RESULT([no])
|
2018-01-10 23:29:21 +08:00
|
|
|
fi
|
|
|
|
])
|
2020-04-30 05:25:36 +08:00
|
|
|
|
|
|
|
dnl
|
|
|
|
dnl GCC_CET_HOST_FLAGS
|
|
|
|
dnl (SHELL-CODE_HANDLER)
|
|
|
|
dnl
|
|
|
|
AC_DEFUN([GCC_CET_HOST_FLAGS],[dnl
|
|
|
|
GCC_ENABLE(cet, auto, ,[enable Intel CET in host libraries],
|
|
|
|
permit yes|no|auto)
|
|
|
|
AC_MSG_CHECKING([for CET support])
|
|
|
|
|
|
|
|
case "$host" in
|
|
|
|
i[[34567]]86-*-linux* | x86_64-*-linux*)
|
|
|
|
may_have_cet=yes
|
2020-06-25 03:27:57 +08:00
|
|
|
cet_save_CFLAGS="$CFLAGS"
|
2020-04-30 05:25:36 +08:00
|
|
|
CFLAGS="$CFLAGS -fcf-protection"
|
|
|
|
case "$enable_cet" in
|
|
|
|
auto)
|
|
|
|
# Check if target supports multi-byte NOPs
|
sync libiberty from gcc
config/
Sync from gcc
2020-07-15 H.J. Lu <hjl.tools@gmail.com>
PR bootstrap/96202
* cet.m4 (GCC_CET_HOST_FLAGS): Don't enable CET without CET
support in stage1 nor for build support.
libiberty/
* configure: Regenerate.
Sync from gcc
2020-09-08 Alan Modra <amodra@gmail.com>
* d-demangle.c: Include limits.h.
(ULONG_MAX, UINT_MAX): Provide fall-back definition.
(dlang_number): Simplify and correct overflow test. Only
write *ret on returning non-NULL. Make "ret" an unsigned long*.
Only succeed for result of [0,UINT_MAX].
(dlang_decode_backref): Simplify and correct overflow test.
Only write *ret on returning non-NULL. Only succeed for
result [1,MAX_LONG].
(dlang_backref): Remove now unnecessary range check.
(dlang_symbol_name_p): Likewise.
(string_need): Take a size_t n arg, and use size_t tem.
(string_append): Use size_t n.
(string_appendn, string_prependn): Take a size_t n arg.
(TEMPLATE_LENGTH_UNKNOWN): Define as -1UL.
(dlang_lname, dlang_parse_template): Take an unsigned long len
arg.
(dlang_symbol_backref, dlang_identifier, dlang_parse_integer),
(dlang_parse_integer, dlang_parse_string),
(dlang_parse_arrayliteral, dlang_parse_assocarray),
(dlang_parse_structlit, dlang_parse_tuple),
(dlang_template_symbol_param, dlang_template_args): Use
unsigned long variables.
* testsuite/d-demangle-expected: Add new tests.
2020-08-04 Iain Buclaw <ibuclaw@gdcproject.org>
* d-demangle.c (dlang_function_args): Handle 'in' and 'in ref'
parameter storage classes.
(dlang_type): Remove identifier type.
* testsuite/d-demangle-expected: Update tests.
2020-08-03 Richard Biener <rguenther@suse.de>
PR lto/96385
* simple-object-elf.c
(simple_object_elf_copy_lto_debug_sections): Localize global
UNDEFs and reuse the prevailing name.
2020-07-10 Ian Lance Taylor <iant@golang.org>
PR demangler/96143
* cp-demangle.c (d_lambda): Don't add substitution candidate.
* testsuite/demangle-expected: Update a few existing test cases
accordingly, and add a new test case.
2020-07-04 Jason Merrill <jason@redhat.com>
* cp-demangle.c (cplus_demangle_operators): Add di, dx, dX.
(d_expression_1): Handle di and dX.
(is_designated_init, d_maybe_print_designated_init): New.
(d_print_comp_inner): Use d_maybe_print_designated_init.
* testsuite/demangle-expected: Add designator tests.
2020-06-25 Nick Clifton <nickc@redhat.com>
* bsearch.c (bsearch): Remove use of register keyword.
* bsearch_r.c (bsearch_r): Likewise.
2020-09-08 17:27:15 +08:00
|
|
|
# and if compiler and assembler support CET.
|
2020-04-30 05:25:36 +08:00
|
|
|
AC_COMPILE_IFELSE(
|
|
|
|
[AC_LANG_PROGRAM(
|
|
|
|
[],
|
|
|
|
[
|
|
|
|
#if !defined(__SSE2__)
|
|
|
|
#error target does not support multi-byte NOPs
|
|
|
|
#else
|
|
|
|
asm ("setssbsy");
|
|
|
|
#endif
|
|
|
|
])],
|
|
|
|
[enable_cet=yes],
|
|
|
|
[enable_cet=no])
|
|
|
|
;;
|
|
|
|
yes)
|
sync libiberty from gcc
config/
Sync from gcc
2020-07-15 H.J. Lu <hjl.tools@gmail.com>
PR bootstrap/96202
* cet.m4 (GCC_CET_HOST_FLAGS): Don't enable CET without CET
support in stage1 nor for build support.
libiberty/
* configure: Regenerate.
Sync from gcc
2020-09-08 Alan Modra <amodra@gmail.com>
* d-demangle.c: Include limits.h.
(ULONG_MAX, UINT_MAX): Provide fall-back definition.
(dlang_number): Simplify and correct overflow test. Only
write *ret on returning non-NULL. Make "ret" an unsigned long*.
Only succeed for result of [0,UINT_MAX].
(dlang_decode_backref): Simplify and correct overflow test.
Only write *ret on returning non-NULL. Only succeed for
result [1,MAX_LONG].
(dlang_backref): Remove now unnecessary range check.
(dlang_symbol_name_p): Likewise.
(string_need): Take a size_t n arg, and use size_t tem.
(string_append): Use size_t n.
(string_appendn, string_prependn): Take a size_t n arg.
(TEMPLATE_LENGTH_UNKNOWN): Define as -1UL.
(dlang_lname, dlang_parse_template): Take an unsigned long len
arg.
(dlang_symbol_backref, dlang_identifier, dlang_parse_integer),
(dlang_parse_integer, dlang_parse_string),
(dlang_parse_arrayliteral, dlang_parse_assocarray),
(dlang_parse_structlit, dlang_parse_tuple),
(dlang_template_symbol_param, dlang_template_args): Use
unsigned long variables.
* testsuite/d-demangle-expected: Add new tests.
2020-08-04 Iain Buclaw <ibuclaw@gdcproject.org>
* d-demangle.c (dlang_function_args): Handle 'in' and 'in ref'
parameter storage classes.
(dlang_type): Remove identifier type.
* testsuite/d-demangle-expected: Update tests.
2020-08-03 Richard Biener <rguenther@suse.de>
PR lto/96385
* simple-object-elf.c
(simple_object_elf_copy_lto_debug_sections): Localize global
UNDEFs and reuse the prevailing name.
2020-07-10 Ian Lance Taylor <iant@golang.org>
PR demangler/96143
* cp-demangle.c (d_lambda): Don't add substitution candidate.
* testsuite/demangle-expected: Update a few existing test cases
accordingly, and add a new test case.
2020-07-04 Jason Merrill <jason@redhat.com>
* cp-demangle.c (cplus_demangle_operators): Add di, dx, dX.
(d_expression_1): Handle di and dX.
(is_designated_init, d_maybe_print_designated_init): New.
(d_print_comp_inner): Use d_maybe_print_designated_init.
* testsuite/demangle-expected: Add designator tests.
2020-06-25 Nick Clifton <nickc@redhat.com>
* bsearch.c (bsearch): Remove use of register keyword.
* bsearch_r.c (bsearch_r): Likewise.
2020-09-08 17:27:15 +08:00
|
|
|
# Check if compiler and assembler support CET.
|
2020-04-30 05:25:36 +08:00
|
|
|
AC_COMPILE_IFELSE(
|
|
|
|
[AC_LANG_PROGRAM(
|
|
|
|
[],
|
|
|
|
[asm ("setssbsy");])],
|
sync libiberty from gcc
config/
Sync from gcc
2020-07-15 H.J. Lu <hjl.tools@gmail.com>
PR bootstrap/96202
* cet.m4 (GCC_CET_HOST_FLAGS): Don't enable CET without CET
support in stage1 nor for build support.
libiberty/
* configure: Regenerate.
Sync from gcc
2020-09-08 Alan Modra <amodra@gmail.com>
* d-demangle.c: Include limits.h.
(ULONG_MAX, UINT_MAX): Provide fall-back definition.
(dlang_number): Simplify and correct overflow test. Only
write *ret on returning non-NULL. Make "ret" an unsigned long*.
Only succeed for result of [0,UINT_MAX].
(dlang_decode_backref): Simplify and correct overflow test.
Only write *ret on returning non-NULL. Only succeed for
result [1,MAX_LONG].
(dlang_backref): Remove now unnecessary range check.
(dlang_symbol_name_p): Likewise.
(string_need): Take a size_t n arg, and use size_t tem.
(string_append): Use size_t n.
(string_appendn, string_prependn): Take a size_t n arg.
(TEMPLATE_LENGTH_UNKNOWN): Define as -1UL.
(dlang_lname, dlang_parse_template): Take an unsigned long len
arg.
(dlang_symbol_backref, dlang_identifier, dlang_parse_integer),
(dlang_parse_integer, dlang_parse_string),
(dlang_parse_arrayliteral, dlang_parse_assocarray),
(dlang_parse_structlit, dlang_parse_tuple),
(dlang_template_symbol_param, dlang_template_args): Use
unsigned long variables.
* testsuite/d-demangle-expected: Add new tests.
2020-08-04 Iain Buclaw <ibuclaw@gdcproject.org>
* d-demangle.c (dlang_function_args): Handle 'in' and 'in ref'
parameter storage classes.
(dlang_type): Remove identifier type.
* testsuite/d-demangle-expected: Update tests.
2020-08-03 Richard Biener <rguenther@suse.de>
PR lto/96385
* simple-object-elf.c
(simple_object_elf_copy_lto_debug_sections): Localize global
UNDEFs and reuse the prevailing name.
2020-07-10 Ian Lance Taylor <iant@golang.org>
PR demangler/96143
* cp-demangle.c (d_lambda): Don't add substitution candidate.
* testsuite/demangle-expected: Update a few existing test cases
accordingly, and add a new test case.
2020-07-04 Jason Merrill <jason@redhat.com>
* cp-demangle.c (cplus_demangle_operators): Add di, dx, dX.
(d_expression_1): Handle di and dX.
(is_designated_init, d_maybe_print_designated_init): New.
(d_print_comp_inner): Use d_maybe_print_designated_init.
* testsuite/demangle-expected: Add designator tests.
2020-06-25 Nick Clifton <nickc@redhat.com>
* bsearch.c (bsearch): Remove use of register keyword.
* bsearch_r.c (bsearch_r): Likewise.
2020-09-08 17:27:15 +08:00
|
|
|
[support_cet=yes],
|
|
|
|
[support_cet=no])
|
|
|
|
if test $support_cet = "no"; then
|
|
|
|
if test x$enable_bootstrap != xno \
|
|
|
|
&& test -z "${with_build_subdir}" \
|
|
|
|
&& (test ! -f ../stage_current \
|
|
|
|
|| test `cat ../stage_current` != "stage1"); then
|
|
|
|
# Require CET support only for the final GCC build.
|
|
|
|
AC_MSG_ERROR([compiler and assembler with CET support are required for --enable-cet])
|
|
|
|
else
|
|
|
|
# Don't enable CET without CET support for non-bootstrap
|
|
|
|
# build, in stage1 nor for build support.
|
|
|
|
enable_cet=no
|
|
|
|
fi
|
|
|
|
fi
|
2020-04-30 05:25:36 +08:00
|
|
|
;;
|
|
|
|
esac
|
2020-06-25 03:27:57 +08:00
|
|
|
CFLAGS="$cet_save_CFLAGS"
|
2020-04-30 05:25:36 +08:00
|
|
|
;;
|
|
|
|
*)
|
|
|
|
may_have_cet=no
|
|
|
|
enable_cet=no
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
2020-06-25 03:27:57 +08:00
|
|
|
cet_save_CFLAGS="$CFLAGS"
|
2020-04-30 05:25:36 +08:00
|
|
|
CFLAGS="$CFLAGS -fcf-protection=none"
|
2020-06-25 03:27:57 +08:00
|
|
|
cet_save_LDFLAGS="$LDFLAGS"
|
2020-04-30 05:25:36 +08:00
|
|
|
LDFLAGS="$LDFLAGS -Wl,-z,ibt,-z,shstk"
|
|
|
|
if test x$may_have_cet = xyes; then
|
|
|
|
# Check whether -fcf-protection=none -Wl,-z,ibt,-z,shstk work.
|
|
|
|
AC_TRY_LINK(
|
|
|
|
[],[return 0;],
|
|
|
|
[may_have_cet=yes],
|
|
|
|
[may_have_cet=no])
|
|
|
|
fi
|
|
|
|
|
|
|
|
if test x$may_have_cet = xyes; then
|
2020-05-13 09:37:03 +08:00
|
|
|
if test x$cross_compiling = xno; then
|
|
|
|
AC_TRY_RUN([
|
2021-03-18 22:54:15 +08:00
|
|
|
int
|
|
|
|
main ()
|
|
|
|
{
|
|
|
|
asm ("endbr32");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
],
|
|
|
|
[have_multi_byte_nop=yes],
|
|
|
|
[have_multi_byte_nop=no])
|
|
|
|
have_cet=no
|
|
|
|
if test x$have_multi_byte_nop = xyes; then
|
|
|
|
AC_TRY_RUN([
|
2020-04-30 05:25:36 +08:00
|
|
|
static void
|
|
|
|
foo (void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
__attribute__ ((noinline, noclone))
|
|
|
|
xxx (void (*f) (void))
|
|
|
|
{
|
|
|
|
f ();
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
__attribute__ ((noinline, noclone))
|
|
|
|
bar (void)
|
|
|
|
{
|
|
|
|
xxx (foo);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
main ()
|
|
|
|
{
|
|
|
|
bar ();
|
|
|
|
return 0;
|
|
|
|
}
|
2021-03-18 22:54:15 +08:00
|
|
|
],
|
|
|
|
[have_cet=no],
|
|
|
|
[have_cet=yes])
|
|
|
|
fi
|
2020-05-13 09:37:03 +08:00
|
|
|
if test x$enable_cet = xno -a x$have_cet = xyes; then
|
|
|
|
AC_MSG_ERROR([Intel CET must be enabled on Intel CET enabled host])
|
|
|
|
fi
|
2020-04-30 05:25:36 +08:00
|
|
|
fi
|
2020-05-13 09:37:03 +08:00
|
|
|
else
|
|
|
|
# Enable CET in cross compiler if possible so that it will run on both
|
|
|
|
# CET and non-CET hosts.
|
|
|
|
have_cet=yes
|
2020-04-30 05:25:36 +08:00
|
|
|
fi
|
|
|
|
if test x$enable_cet = xyes; then
|
|
|
|
$1="-fcf-protection"
|
|
|
|
AC_MSG_RESULT([yes])
|
|
|
|
else
|
|
|
|
AC_MSG_RESULT([no])
|
|
|
|
fi
|
2020-06-25 03:27:57 +08:00
|
|
|
CFLAGS="$cet_save_CFLAGS"
|
|
|
|
LDFLAGS="$cet_save_LDFLAGS"
|
2020-04-30 05:25:36 +08:00
|
|
|
])
|