From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id D7uuARuGmWCfJgAAWB0awg (envelope-from ) for ; Mon, 10 May 2021 15:14:35 -0400 Received: by simark.ca (Postfix, from userid 112) id F07201E813; Mon, 10 May 2021 15:14:34 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-0.7 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,RDNS_DYNAMIC,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (ip-8-43-85-97.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 0FE621E813 for ; Mon, 10 May 2021 15:14:34 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 6F08C386186A; Mon, 10 May 2021 19:14:33 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6F08C386186A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1620674073; bh=Jnat65fw2hdZ6WYZTgmIhh4dbU4N1QGlcUy89T5pyXw=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=YZPbwPluYH1Hb0io/hglUgZ6w2ivsxHcIH/U5OviWdMssswrrerVT5JeFIS1d6ULk Jb0AzlN1VFYVgrgLYdRb1B6T5GQONp+6BqPXE+mO2dOJTi4TkEJLEykpMWSN7j3DeW FvQLNI6XbuShdUwZx8k0e7wDEQkfgzhspNpHPv7c= Received: from mail-qv1-xf35.google.com (mail-qv1-xf35.google.com [IPv6:2607:f8b0:4864:20::f35]) by sourceware.org (Postfix) with ESMTPS id 6689A386186A for ; Mon, 10 May 2021 19:14:31 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 6689A386186A Received: by mail-qv1-xf35.google.com with SMTP id r13so8937499qvm.7 for ; Mon, 10 May 2021 12:14:31 -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:subject:date:message-id:mime-version :content-transfer-encoding; bh=Jnat65fw2hdZ6WYZTgmIhh4dbU4N1QGlcUy89T5pyXw=; b=dfVkBN6nnRpt3+AFDLEKZyAYaUnBEivpd/b8FhXGg8VIKiRR/4zFX765wxeKvebpRV KcbidmrLlNBvFYtaap41yY6AmdyXDDpsRzO0M5GBgjPkqSAbx8Qj9RzwBBz5Tq3q5IxI sMp5Km6NE9FBD79YBaRUR2Fl6sg6v/yCGDy32hqM/YekR2HlhSbL5zxA3HneZpNdf5Me 0hEiF+OOAdv6cqyBRYkMeuFIxZHpqYZCD0cPqdxn84/2NmQPwmwNVDkg4NJjLW+CKpfI OBw+U/MfaCOvn9h4e3xm+Y/LpVBz7yjz7vSwVNRJBECgYIsieAuCxoUjWDqjDHOoAug3 BhWg== X-Gm-Message-State: AOAM530KRbjQyxtsjxQvvNa2CG/HLsFU3pnvNcTnvbZ8cVWaslGiUJGX 1E8M9VmsRZ1Y57kWTnCraet1HdjEmFRtJg== X-Google-Smtp-Source: ABdhPJzspcEyjIBXblsTY9Y7J0Emu0w82jjkqFCZcOBCTGVcVMQlWu19eOos/5rRi4xnF6OGccfp2A== X-Received: by 2002:ad4:5668:: with SMTP id bm8mr24978210qvb.28.1620674070979; Mon, 10 May 2021 12:14:30 -0700 (PDT) Received: from localhost.localdomain ([2804:7f0:4841:40ad:215f:36bd:5b9a:ad6]) by smtp.gmail.com with ESMTPSA id c187sm11836291qkd.8.2021.05.10.12.14.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 May 2021 12:14:30 -0700 (PDT) To: gdb-patches@sourceware.org Subject: [PATCH] [sim] Fix build failure in d10v sim Date: Mon, 10 May 2021 16:14:23 -0300 Message-Id: <20210510191423.3627307-1-luis.machado@linaro.org> X-Mailer: git-send-email 2.25.1 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 I looked at a different sim (cr16), and it zeroes out the entire State, not just the registers. It is unclear why we have the casts to uintptr. 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 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sim/d10v/interp.c b/sim/d10v/interp.c index 86e566a79fb..a59779810eb 100644 --- a/sim/d10v/interp.c +++ b/sim/d10v/interp.c @@ -1143,7 +1143,7 @@ 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); + memset (&State, 0, sizeof (State)); /* 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