[PATCH 1/2] score: Add RTEMS_OBFUSCATE_POINTER()

Sebastian Huber sebastian.huber at embedded-brains.de
Wed Oct 12 13:23:11 UTC 2016


On 12/10/16 11:13, Sebastian Huber wrote:
> Update #2790.
> ---
>   cpukit/score/include/rtems/score/basedefs.h | 12 +++++++++++-
>   1 file changed, 11 insertions(+), 1 deletion(-)
>
> diff --git a/cpukit/score/include/rtems/score/basedefs.h b/cpukit/score/include/rtems/score/basedefs.h
> index c378635..ea4d831 100644
> --- a/cpukit/score/include/rtems/score/basedefs.h
> +++ b/cpukit/score/include/rtems/score/basedefs.h
> @@ -10,7 +10,7 @@
>    *  COPYRIGHT (c) 1989-2007.
>    *  On-Line Applications Research Corporation (OAR).
>    *
> - *  Copyright (c) 2010-2015 embedded brains GmbH.
> + *  Copyright (c) 2010, 2016 embedded brains GmbH.
>    *
>    *  The license and distribution terms for this file may be
>    *  found in the file LICENSE in this distribution or at
> @@ -221,6 +221,16 @@
>     #define RTEMS_PRINTFLIKE( _format_pos, _ap_pos )
>   #endif
>   
> +/**
> + * @brief Obfuscates the pointer so that the compiler cannot perform
> + * optimizations based on the pointer value.
> + */
> +#if defined(__GNUC__)
> +  #define RTEMS_OBFUSCATE_POINTER( _ptr ) __asm__("" : "+r" (_ptr))
> +#else
> +  #define RTEMS_OBFUSCATE_POINTER( _ptr ) (void) (_ptr)
> +#endif
> +
>   #if __cplusplus >= 201103L
>     #define RTEMS_STATIC_ASSERT(cond, msg) \
>       static_assert(cond, # msg)

Looks like this works for any variable that can reside in a register. So 
maybe change this to

RTEMS_OBFUSCATE_VARIABLE( _var )

See also discussion here:

https://gcc.gnu.org/ml/gcc/2016-09/msg00114.html

-- 
Sebastian Huber, embedded brains GmbH

Address : Dornierstr. 4, D-82178 Puchheim, Germany
Phone   : +49 89 189 47 41-16
Fax     : +49 89 189 47 41-09
E-Mail  : sebastian.huber at embedded-brains.de
PGP     : Public key available on request.

Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.




More information about the devel mailing list