From: Luis Machado via Gdb-patches <gdb-patches@sourceware.org>
To: gdb-patches@sourceware.org
Subject: [PATCH,v2] [sim] Fix build failure in d10v sim
Date: Tue, 11 May 2021 10:07:43 -0300 [thread overview]
Message-ID: <20210511130743.3672216-1-luis.machado@linaro.org> (raw)
In-Reply-To: <20210510191423.3627307-1-luis.machado@linaro.org>
While building all targets on Ubuntu 20.04/aarch64, I ran into the following
build error:
In file included from /usr/include/string.h:495,
from ../../bfd/bfd.h:48,
from ../../../../repos/binutils-gdb/sim/d10v/interp.c:4:
In function 'memset',
inlined from 'sim_create_inferior' at ../../../../repos/binutils-gdb/sim/d10v/interp.c:1146:3:
/usr/include/aarch64-linux-gnu/bits/string_fortified.h:71:10: error: ‘__builtin_memset’ offset [33, 616] from the object at ‘State’ is out of the bounds of referenced subobject ‘regs’ with type ‘reg_t[16]’ {aka ‘short unsigned int[16]’} at offset 0 [-Werror=array-bounds]
71 | return __builtin___memset_chk (__dest, __ch, __len, __bos0 (__dest));
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
make[3]: *** [Makefile:558: interp.o] Error 1
The following patch fixes this for me.
OK?
sim/ChangeLog:
YYYY-MM-DD Luis Machado <luis.machado@linaro.org>
d10v/interp.c (sim_create_inferior): Fix memset call.
---
sim/d10v/interp.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/sim/d10v/interp.c b/sim/d10v/interp.c
index 86e566a79fb..64dd392381c 100644
--- a/sim/d10v/interp.c
+++ b/sim/d10v/interp.c
@@ -1142,8 +1142,12 @@ sim_create_inferior (SIM_DESC sd, struct bfd *abfd,
{
bfd_vma start_address;
- /* reset all state information */
- memset (&State.regs, 0, (uintptr_t)&State.mem - (uintptr_t)&State.regs);
+ /* Make sure we have the right structure for the following memset. */
+ _Static_assert ((uintptr_t) &State == (uintptr_t) &State.regs,
+ "&State != &State.regs");
+
+ /* Reset state from the regs field until the mem field. */
+ memset (&State, 0, (uintptr_t)&State.mem - (uintptr_t)&State.regs);
/* There was a hack here to copy the values of argc and argv into r0
and r1. The values were also saved into some high memory that
--
2.25.1
next prev parent reply other threads:[~2021-05-11 13:07 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-10 19:14 [PATCH] " Luis Machado via Gdb-patches
2021-05-10 22:30 ` Mike Frysinger via Gdb-patches
2021-05-11 2:01 ` Luis Machado via Gdb-patches
2021-05-11 20:48 ` Mike Frysinger via Gdb-patches
2021-05-11 13:07 ` Luis Machado via Gdb-patches [this message]
2021-05-11 21:54 ` [PATCH,v2] " Mike Frysinger via Gdb-patches
2021-05-12 3:59 ` Luis Machado via Gdb-patches
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210511130743.3672216-1-luis.machado@linaro.org \
--to=gdb-patches@sourceware.org \
--cc=luis.machado@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox