Hi Andre,

On 04/01/17 11:21, Andre Vieira (lists) wrote:
Hello,

This patch adds the attribute "warn_unused_result" to the following
intrinsics:
__cmse_TT{,A,AT,T}_fptr
cmse_TT{,A,AT,T}
cmse_nonsecure_caller
cmse_check_address_range

If the result of these intrinsics is not used it means the result of the
checks they perform are never used and that could become the source of a
security vulnerability in the user's code.  We hope this will limit these.

Due to the current limitations of "warn_unused_result", adding them to
the __cmse_TT*_fptr intrinsics is pointless since the user will most
likely use the macro 'cmse_TT*_fptr' instead, which casts the result of
__cmse_TT*_fptr and that seems to be enough to count as a "use". I
decided to leave them in there anyway in case the warning becomes a bit
smarter in the future. Warnings for cmse_check_pointed_object will never
be issued for the same reason. Also if you assign the result of any of
these intrinsics to a variable you never use, you will only get a
warning about an unused variable, though this warning is not turned on
by default.

Ran cmse regression tests for arm-none-eabi both ARMv8-M Baseline and
Mainline.

Is this OK for stage 3?

Cheers,
Andre

gcc/ChangeLog:
2017-01-04  Andre Vieira  <andre.simoesdiasvie...@arm.com>

         * config/gcc/arm_cmse.h (__cmse_TT_fptr,__cmse_TTA_fptr,
         __cmse_TTAT_fptr,__cmse_TTT_fptr,cmse_TT, cmse_TTA, cmse_TTAT,
         cmse_TTT, cmse_nonsecure_caller, cmse_check_address_range):
         Add warn_unused_result attribute to function declaration.

gcc/testsuite/ChangeLog:
2017-01-04  Andre Vieira  <andre.simoesdiasvie...@arm.com>

         * gcc.target/arm/cmse/cmse-3.c: Add warning tests for the
         warn_unused_result warning.


diff --git a/gcc/config/arm/arm_cmse.h b/gcc/config/arm/arm_cmse.h
index 
82b58b1c4f4a12ba6062e2cc2632653788d0eeb7..d37f4e2b446c3c80d56af8b633323837f327973f
 100644
--- a/gcc/config/arm/arm_cmse.h
+++ b/gcc/config/arm/arm_cmse.h
@@ -116,11 +116,13 @@ typedef void (*__cmse_fptr)(void);
 }
__extension__ static __inline __attribute__ ((__always_inline__))
+__attribute__ ((__warn_unused_result__))

Don't add a second __attribute__ annotation, change the first one to be:
 __attribute__ ((__always_inline__, __warn_unused_result__))


Ok with that change.
Thanks,
Kyrill

Reply via email to