From f0efd92502a0eb33c8f8f9e1ea03b25a714b2d72 Mon Sep 17 00:00:00 2001 From: Joel Hutton Date: Wed, 31 Jul 2019 08:56:35 +0000 Subject: [Arm][CMSE]Add warn_unused_return attribute to cmse functions At present it is possible to call the CMSE functions for checking addresses (such as cmse_check_address_range) and forget to check/use the return value. This patch makes the interfaces more robust against programmer error by marking these functions with the warn_unused_result attribute. With this set, any use of these functions that does not use the result will produce a warning. This produces a warning on default warn levels when the result of the cmse functions is not used. For the following function: void foo() { int *data; cmse_check_address_range((int*)data, 0, 0); } The following warning is emitted: warning: ignoring return value of 'cmse_check_address_range' declared with attribute 'warn_unused_result' [-Wunused-result] 6 | cmse_check_address_range((int*)data, 0, 0); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ gcc/ChangeLog: 2019-07-31 Joel Hutton * config/arm/arm_cmse.h (cmse_nonsecure_caller): Add warn_unused_result attribute. (cmse_check_address_range): Add warn_unused_result attribute. libgcc/ChangeLog: 2019-07-31 Joel Hutton * config/arm/cmse.c (cmse_check_address_range): Add warn_unused_result attribute. 2019-07-31 Joel Hutton * gcc.target/arm/cmse/cmse-17.c: New test. From-SVN: r273924 --- libgcc/ChangeLog | 5 +++++ libgcc/config/arm/cmse.c | 1 + 2 files changed, 6 insertions(+) (limited to 'libgcc') diff --git a/libgcc/ChangeLog b/libgcc/ChangeLog index 7997ad8..c9aea1d 100644 --- a/libgcc/ChangeLog +++ b/libgcc/ChangeLog @@ -1,3 +1,8 @@ +2019-07-31 Joel Hutton + + * config/arm/cmse.c (cmse_check_address_range): Add + warn_unused_result attribute. + 2019-07-22 Martin Liska * config/pa/stublib.c: Remove stub symbol __gnu_lto_v1. diff --git a/libgcc/config/arm/cmse.c b/libgcc/config/arm/cmse.c index 34a46fd..0c5a3ea 100644 --- a/libgcc/config/arm/cmse.c +++ b/libgcc/config/arm/cmse.c @@ -30,6 +30,7 @@ address range. See ACLE changes for ARMv8-M. */ void * +__attribute__ ((warn_unused_result)) cmse_check_address_range (void *p, size_t size, int flags) { cmse_address_info_t permb, perme; -- cgit v1.1 From 428642b132a4f2ce6c368398ec7f2ff307f33f8a Mon Sep 17 00:00:00 2001 From: Matt Thomas Date: Wed, 31 Jul 2019 14:11:16 +0000 Subject: config.gcc (hppa*-*-netbsd*): New target. gcc/ChangeLog: * config.gcc (hppa*-*-netbsd*): New target. * config/pa/pa-netbsd.h: New file. * config/pa/pa32-netbsd.h: New file. libgcc/ChangeLog: * config.host (hppa*-*-netbsd*): New case. * config/pa/t-netbsd: New file. Co-Authored-By: Matthew Green Co-Authored-By: Maya Rashish Co-Authored-By: Nick Hudson From-SVN: r273933 --- libgcc/ChangeLog | 8 ++++++++ libgcc/config.host | 3 +++ libgcc/config/pa/t-netbsd | 9 +++++++++ 3 files changed, 20 insertions(+) create mode 100644 libgcc/config/pa/t-netbsd (limited to 'libgcc') diff --git a/libgcc/ChangeLog b/libgcc/ChangeLog index c9aea1d..33b6fa8 100644 --- a/libgcc/ChangeLog +++ b/libgcc/ChangeLog @@ -1,3 +1,11 @@ +2019-07-31 Matt Thomas + Nick Hudson + Matthew Green + Maya Rashish + + * config.host (hppa*-*-netbsd*): New case. + * config/pa/t-netbsd: New file. + 2019-07-31 Joel Hutton * config/arm/cmse.c (cmse_check_address_range): Add diff --git a/libgcc/config.host b/libgcc/config.host index f5ca779..503ebb6 100644 --- a/libgcc/config.host +++ b/libgcc/config.host @@ -634,6 +634,9 @@ hppa[12]*-*-hpux11*) hppa*-*-openbsd*) tmake_file="$tmake_file pa/t-openbsd" ;; +hppa*-*-netbsd*) + tmake_file="$tmake_file pa/t-netbsd" + ;; i[34567]86-*-darwin*) tmake_file="$tmake_file i386/t-crtpc t-crtfm i386/t-msabi" tm_file="$tm_file i386/darwin-lib.h" diff --git a/libgcc/config/pa/t-netbsd b/libgcc/config/pa/t-netbsd new file mode 100644 index 0000000..8b99068 --- /dev/null +++ b/libgcc/config/pa/t-netbsd @@ -0,0 +1,9 @@ +#Plug millicode routines into libgcc.a We want these on both native and +#cross compiles. We use the "64-bit" routines because the "32-bit" code +#is broken for certain corner cases. +LIB1ASMSRC = pa/milli64.S +LIB1ASMFUNCS = _divI _divU _remI _remU _div_const _mulI _dyncall + +HOST_LIBGCC2_CFLAGS += -DELF=1 -DLINUX=1 + +LIB2ADD = $(srcdir)/config/pa/fptr.c -- cgit v1.1