Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1E8DCC4338F for ; Sun, 22 Aug 2021 17:52:10 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 600A5611AF for ; Sun, 22 Aug 2021 17:52:09 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 600A5611AF Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 189CF82C0C; Sun, 22 Aug 2021 19:52:06 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.b="bU5ScekG"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 9287F821F0; Sun, 22 Aug 2021 19:52:03 +0200 (CEST) Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id ABA8482C0C for ; Sun, 22 Aug 2021 19:51:59 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=pali@kernel.org Received: by mail.kernel.org (Postfix) with ESMTPSA id DC139611AF; Sun, 22 Aug 2021 17:51:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1629654718; bh=7f1PXhKnJuCkJoOjdTv9k4Yxl4HGntiGDFtq7zxA9rE=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=bU5ScekGrzd4ic4pdhoR4seWOeYsB122Spg0OJAV3lD3AvyLfdfyANw8LKoGDjanE QKhnfXKpLZZhA8cHqF6UjHhXdfbI3Uax7WE41MzH2TquzZcrgfLNV9ZpTTZK3uJ4Q1 0IxWjuF+nCYs+2iGMoHDgClaDcux7WUJx3OCQDjHhwwdPckk9IvVjcH+O2w2cNFWwF YnNzBLPBolG+pM5EvX/adXZWpUFphp3gLYlrQYfX8BA/dfkFoUDQm0i5FpaI/n5HcZ 0EUUCnBun7Xp+KANPnzr0/1OciswTzQYatpTMVKRENvNI4UbWK917eAW59sw1LePQ3 /YPEsRLKTjC9Q== Received: by pali.im (Postfix) id B82217C7; Sun, 22 Aug 2021 19:51:55 +0200 (CEST) Date: Sun, 22 Aug 2021 19:51:55 +0200 From: Pali =?utf-8?B?Um9ow6Fy?= To: Samuel Holland Cc: u-boot@lists.denx.de, Jagan Teki , Andre Przywara , AKASHI Takahiro , Alexandru Gagniuc , Baruch Siach , Bharat Gooty , Chris Packham , Fabio Estevam , Frieder Schrempf , Jernej Skrabec , Marek =?utf-8?B?QmVow7pu?= , "NXP i.MX U-Boot Team" , Naoki Hayama , Patrick Delaunay , Priyanka Jain , Rayagonda Kokatanur , Simon Glass , Stefan Roese , Stefano Babic , Sughosh Ganu , Trevor Woerner , lauri.hintsala@silabs.com Subject: Re: [PATCH v2 2/4] tools: mkimage: Add Allwinner TOC0 support Message-ID: <20210822175155.gkfreikcgl37iyje@pali> References: <20210822044649.13585-1-samuel@sholland.org> <20210822044649.13585-3-samuel@sholland.org> <20210822100712.6ho23p2y56ghyuny@pali> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20180716 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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.2 at phobos.denx.de X-Virus-Status: Clean On Sunday 22 August 2021 12:44:05 Samuel Holland wrote: > >> +struct toc0_main_info { > >> + uint8_t name[8]; > >> + __le32 magic; > >> + __le32 checksum; > >> + __le32 serial; > >> + __le32 status; > >> + __le32 num_items; > >> + __le32 length; > >> + uint8_t platform[4]; > >> + uint8_t reserved[8]; > >> + uint8_t end[4]; > >> +}; > >> + > >> +#define TOC0_MAIN_INFO_NAME "TOC0.GLH" > >> +#define TOC0_MAIN_INFO_MAGIC 0x89119800 > >> +#define TOC0_MAIN_INFO_END "MIE;" > >> + > >> +struct toc0_item_info { > >> + __le32 name; > >> + __le32 offset; > >> + __le32 length; > >> + __le32 status; > >> + __le32 type; > >> + __le32 load_addr; > >> + uint8_t reserved[4]; > >> + uint8_t end[4]; > >> +}; > > > > These structures are raw image structures, right? Therefore they should > > be marked as __packed? > > I'm not sure why I would want to do that? The structures do not have any > padding to start with, and the layout of the image format implies that > they will be naturally aligned (and in fact the boot ROM assumes this). > Marking them as packed would only cause GCC to generate less efficient code. Because this code is running on the build machine, not on target hardware where is the boot ROM. It is compiled by host compiler and build machine may have totally different padding / layout schematics and C compiler is free in this case to put any padding between any two members in that structure. And if GCC generates different or less efficient code, it means that __packed is really needed here.