From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id MTaULqqBmmCXPQAAWB0awg (envelope-from ) for ; Tue, 11 May 2021 09:07:54 -0400 Received: by simark.ca (Postfix, from userid 112) id B07431F11C; Tue, 11 May 2021 09:07:54 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-1.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id D5C641E01F for ; Tue, 11 May 2021 09:07:53 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 5F3F53839C4B; Tue, 11 May 2021 13:07:53 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5F3F53839C4B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1620738473; bh=uLcyjfCikf+fSi2r6i+2Bp1uL2LllZL8dZe4uJCoC/M=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=f/doXrlpdpB4FmBgoNamtH4M5UvB9z3lPxKpppcKmbzQGZ37lBlxy93QtsFiKtVvb C3j39ATtPj2OKC3ag7OqpNorzPvOly2EpgYl6TJQudwF3+xwpFq21iRJn+GwAG514Q WOpujX46CjrM4Hz2xBAL7sl6buR49GAG+Coa2sIg= Received: from mail-qt1-x82a.google.com (mail-qt1-x82a.google.com [IPv6:2607:f8b0:4864:20::82a]) by sourceware.org (Postfix) with ESMTPS id DF64138515E8 for ; Tue, 11 May 2021 13:07:48 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org DF64138515E8 Received: by mail-qt1-x82a.google.com with SMTP id 1so14498217qtb.0 for ; Tue, 11 May 2021 06:07:48 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=uLcyjfCikf+fSi2r6i+2Bp1uL2LllZL8dZe4uJCoC/M=; b=IiTgZrB1AxFg47rbW1FzhNUJPkGb9RHWJ19i/A0DpzcZ36iQ0x/UcSOxAyunDcXrFg ln2oI0iyu2iKWZVD5aOwbesehEggQpJxaNKr5v9nDCyx6WeIUMB3Nj5OUTEjl8I0Wm// zNFjTZqlF1Em8G8sP01dXN9wFJlYgI/+p4NDYnki5LazWOFmwxKUzDneMouT9GrHfXqm 8mLgzR225rPUMGlsVZjBOza9eEy01y+/lyRqe8BRJXZzrBpd7+RBb3afy3JBEfRNN0i1 l3l0szagHur7v1nq+XY7Nu24ZquOdEAJ6fr1HpAdgWLsEGXwZ36SxOIXbJjIFXEWAXPb JjSw== X-Gm-Message-State: AOAM532AmiWAXm+mJK4kwXUS/D19tuTOBwD29J2LL9Ac8rHj2JtXLT7J 680B32GdfK0PM4cjlNc/J13PtmoMNanSug== X-Google-Smtp-Source: ABdhPJzF/TlYwloeuzuNdW87PawHqX164LZxG/CnM/IFpL8u8TxHCHcUu0cARIRvClC2KMLrYqf+mg== X-Received: by 2002:ac8:6a01:: with SMTP id t1mr24663904qtr.47.1620738468458; Tue, 11 May 2021 06:07:48 -0700 (PDT) Received: from localhost.localdomain ([2804:7f0:4841:40ad:215f:36bd:5b9a:ad6]) by smtp.gmail.com with ESMTPSA id l10sm15118572qtn.28.2021.05.11.06.07.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 May 2021 06:07:48 -0700 (PDT) To: gdb-patches@sourceware.org Subject: [PATCH,v2] [sim] Fix build failure in d10v sim Date: Tue, 11 May 2021 10:07:43 -0300 Message-Id: <20210511130743.3672216-1-luis.machado@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210510191423.3627307-1-luis.machado@linaro.org> References: <20210510191423.3627307-1-luis.machado@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Luis Machado via Gdb-patches Reply-To: Luis Machado Errors-To: gdb-patches-bounces@sourceware.org Sender: "Gdb-patches" 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 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