diff options
author | Chris Metcalf <cmetcalf@ezchip.com> | 2014-11-12 20:00:06 (GMT) |
---|---|---|
committer | Chris Metcalf <cmetcalf@ezchip.com> | 2014-11-13 14:39:26 (GMT) |
commit | ce433f8090da6784cdee754defcbf325fc66f274 (patch) | |
tree | 81be5d2025ad1690228a18203875715e0647ff04 /arch/tile/include/uapi/asm/ptrace.h | |
parent | a5c1cb63ddf400cf58c7d8aecd045049f6818279 (diff) | |
download | linux-ce433f8090da6784cdee754defcbf325fc66f274.tar.xz |
tile: avoid undefined behavior with regs[TREG_TP] etc
Recent compilers warn about accesses to arrays past the end,
which is supported for pt_regs and sigcontext with the
intended alias past the end of regs[] to sp, tp, and lr
using TREG_SP, TREG_TP, and TREG_LR.
Make the intended usage explict by providing an anonymous
union of regs[56] on the one hand, and a short __regs[53]
on the other followed by the sp, tp, and lr fields, so the
aliasing is done explicitly and is visible to the compiler.
Reviewed-by: Jeff Epler <jepler@unpythonic.net>
Signed-off-by: Chris Metcalf <cmetcalf@ezchip.com>
Diffstat (limited to 'arch/tile/include/uapi/asm/ptrace.h')
-rw-r--r-- | arch/tile/include/uapi/asm/ptrace.h | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/arch/tile/include/uapi/asm/ptrace.h b/arch/tile/include/uapi/asm/ptrace.h index 7757e19..d03b829 100644 --- a/arch/tile/include/uapi/asm/ptrace.h +++ b/arch/tile/include/uapi/asm/ptrace.h @@ -52,12 +52,16 @@ typedef uint_reg_t pt_reg_t; * system call or exception. "struct sigcontext" has the same shape. */ struct pt_regs { - /* Saved main processor registers; 56..63 are special. */ - /* tp, sp, and lr must immediately follow regs[] for aliasing. */ - pt_reg_t regs[53]; - pt_reg_t tp; /* aliases regs[TREG_TP] */ - pt_reg_t sp; /* aliases regs[TREG_SP] */ - pt_reg_t lr; /* aliases regs[TREG_LR] */ + union { + /* Saved main processor registers; 56..63 are special. */ + pt_reg_t regs[56]; + struct { + pt_reg_t __regs[53]; + pt_reg_t tp; /* aliases regs[TREG_TP] */ + pt_reg_t sp; /* aliases regs[TREG_SP] */ + pt_reg_t lr; /* aliases regs[TREG_LR] */ + }; + }; /* Saved special registers. */ pt_reg_t pc; /* stored in EX_CONTEXT_K_0 */ |