Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0A485C6FD18 for ; Tue, 28 Mar 2023 18:55:21 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id E991D85CAD; Tue, 28 Mar 2023 20:55:08 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=konsulko.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=konsulko.com header.i=@konsulko.com header.b="Wtx3L1TJ"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 63D3285C95; Tue, 28 Mar 2023 20:54:59 +0200 (CEST) Received: from mail-yw1-x1136.google.com (mail-yw1-x1136.google.com [IPv6:2607:f8b0:4864:20::1136]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 9DC8285C98 for ; Tue, 28 Mar 2023 20:54:54 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=konsulko.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=trini@konsulko.com Received: by mail-yw1-x1136.google.com with SMTP id 00721157ae682-54601d90118so92560137b3.12 for ; Tue, 28 Mar 2023 11:54:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=konsulko.com; s=google; t=1680029693; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Xn/r76MrGXyVzJRLm0F3efCQBz0y/zALaZiwnbar8Yk=; b=Wtx3L1TJTmLbLmnebNwDhcr6rtvdhyM10zJbDNYXDMNgLqH0qpWT2Lu94gBBTmtUsS wwUVOfx6GHLPzN8S5rucmO4qAmPj7pgDQYp3proBu3bIO7orEor8v5YUsIcKdwdkMtdW eznuJ6+E/POjO44+WJeLNQQNTHgS9YTWr9S4U= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680029693; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Xn/r76MrGXyVzJRLm0F3efCQBz0y/zALaZiwnbar8Yk=; b=K5IbOt990uJ1G4/yvPIyxjtk9PhSykRvuTmYc1dN6fKiFezbsw+WekL43hG/WiNJEh s9KXD+/2UJEf7boo+9ZNThBM0qPeHsbRSHLpubol9/yhx3nF0G76bHaNFl1EXIgACwnr WFaD95pt5d1x8zIVxkD60PADNSV8ALu5NFSt8Zl6ByTC6G4HBSOsbZaic1rmTUU6BV5l jhbX9kQ3NTdFVi3en/udI3sqqsuHU7F78tLT1/vx1PeeSggrm3QI2WhYwhAHzwzszzXS Tg6/cDtKaiR1l83KMmxYLLi+XkkqXAsAudtZdAiBnErXAgK29FZ1t310gt538UDEYY+S Fe0w== X-Gm-Message-State: AAQBX9f0UYOtsDnC7f2nuA2o3ZpHFg5uBtqp0ybEIhe4DY/tOKMgmCuk MJbceR1xUBNYa/GHiviAznwWcRIFLkaOlax2LDhOBw== X-Google-Smtp-Source: AKy350YvvEH9T1P7Mo+95nnF7HWdopOtGR3PN/bENDS5BNKEzofQ9SYPHlV6hCfoq45372zCEW2cWw== X-Received: by 2002:a81:8707:0:b0:544:57ba:a32e with SMTP id x7-20020a818707000000b0054457baa32emr15562172ywf.9.1680029693180; Tue, 28 Mar 2023 11:54:53 -0700 (PDT) Received: from bill-the-cat.lan (2603-6081-7b00-6400-aab4-31cf-c563-6345.res6.spectrum.com. [2603:6081:7b00:6400:aab4:31cf:c563:6345]) by smtp.gmail.com with ESMTPSA id q127-20020a81b285000000b00545f2dbe3a2sm973187ywh.34.2023.03.28.11.54.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Mar 2023 11:54:52 -0700 (PDT) From: Tom Rini To: u-boot@lists.denx.de Cc: AdityaK , Andrew Pinski Subject: [PATCH 2/2] linker_lists: Rework start/end macros to not rely on undefined behavior Date: Tue, 28 Mar 2023 14:54:51 -0400 Message-Id: <20230328185451.4150977-2-trini@konsulko.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230328185451.4150977-1-trini@konsulko.com> References: <20230328185451.4150977-1-trini@konsulko.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean Per the GCC bug listed below, the way we do linker lists is relying on undefined behavior that seems to work in gcc, but doesn't always work in clang. Andrew suggests rewriting our start/end macros in a different way (as implemented here, from what he said in comment 1) to avoid these problems. Reported-by: AdityaK Suggested-by: Andrew Pinski Link: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108915 Signed-off-by: Tom Rini --- Andrew, please feel free to reply with any further tags you want here, I wasn't exactly sure of the best way to attribute this to you. Thanks! --- include/linker_lists.h | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/include/linker_lists.h b/include/linker_lists.h index d3da9d44e853..f9a2ee0c762a 100644 --- a/include/linker_lists.h +++ b/include/linker_lists.h @@ -127,7 +127,9 @@ static char start[0] __aligned(CONFIG_LINKER_LIST_ALIGN) \ __attribute__((unused)) \ __section("__u_boot_list_2_"#_list"_1"); \ - (_type *)&start; \ + _type * tmp = (_type *)&start; \ + asm("":"+r"(tmp)); \ + tmp; \ }) /** @@ -153,7 +155,9 @@ ({ \ static char end[0] __aligned(4) __attribute__((unused)) \ __section("__u_boot_list_2_"#_list"_3"); \ - (_type *)&end; \ + _type * tmp = (_type *)&end; \ + asm("":"+r"(tmp)); \ + tmp; \ }) /** * ll_entry_count() - Return the number of elements in linker-generated array @@ -247,7 +251,9 @@ ({ \ static char start[0] __aligned(4) __attribute__((unused)) \ __section("__u_boot_list_1"); \ - (_type *)&start; \ + _type * tmp = (_type *)&start; \ + asm("":"+r"(tmp)); \ + tmp; \ }) /** @@ -270,7 +276,9 @@ ({ \ static char end[0] __aligned(4) __attribute__((unused)) \ __section("__u_boot_list_3"); \ - (_type *)&end; \ + _type * tmp = (_type *)&end; \ + asm("":"+r"(tmp)); \ + tmp; \ }) #endif /* __ASSEMBLY__ */ -- 2.34.1