add gdb sim sample for h8s
[openadk.git] / toolchain / binutils / patches / 2.29.1 / xtensa-fix-memory-corruption-by-broken-sysregs.patch
blob30103ee05ecafc42ba7b8347d0b5daa6197540ab
1 From 3c8788dbb70b40e737d4b8e30cab81406e5c5091 Mon Sep 17 00:00:00 2001
2 From: Max Filippov <jcmvbkbc@gmail.com>
3 Date: Wed, 2 Aug 2017 00:36:05 -0700
4 Subject: [PATCH] xtensa: fix memory corruption by broken sysregs
6 In some xtensa configurations there may be system/user registers in
7 xtensa-modules with negative index. ISA initialization for such config
8 may clobber heap and result in program termination.
9 Don't update lookup table entries for register with negative indices.
10 They are not directly accessible via RSR/WSR/XSR or RUR/WUR, so this
11 change should not affect processing of valid assembly/binary code.
13 bfd/
14 2017-08-02 Max Filippov <jcmvbkbc@gmail.com>
16 * xtensa-isa.c (xtensa_isa_init): Don't update lookup table
17 entries for sysregs with negative indices.
19 Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
20 ---
21 Backported from: d84ed528d4817b0ff854006b65a9f6ec75f0407a
23 bfd/xtensa-isa.c | 3 ++-
24 1 file changed, 2 insertions(+), 1 deletion(-)
26 diff --git a/bfd/xtensa-isa.c b/bfd/xtensa-isa.c
27 index 8da75bea8109..8c6ee88fdeae 100644
28 --- a/bfd/xtensa-isa.c
29 +++ b/bfd/xtensa-isa.c
30 @@ -292,7 +292,8 @@ xtensa_isa_init (xtensa_isa_status *errno_p, char **error_msg_p)
31 xtensa_sysreg_internal *sreg = &isa->sysregs[n];
32 is_user = sreg->is_user;
34 - isa->sysreg_table[is_user][sreg->number] = n;
35 + if (sreg->number >= 0)
36 + isa->sysreg_table[is_user][sreg->number] = n;
39 /* Set up the interface lookup table. */
40 --
41 2.1.4