From patchwork Wed Feb 28 10:48:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilias Apalodimas X-Patchwork-Id: 1905647 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=PAuLXwMs; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TlB0m16ccz23qP for ; Wed, 28 Feb 2024 21:48:40 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 7773587F18; Wed, 28 Feb 2024 11:48:36 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.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=linaro.org header.i=@linaro.org header.b="PAuLXwMs"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 5397987F95; Wed, 28 Feb 2024 11:48:35 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) (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 2A80087ECC for ; Wed, 28 Feb 2024 11:48:30 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=ilias.apalodimas@linaro.org Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-412a9e9c776so4172355e9.0 for ; Wed, 28 Feb 2024 02:48:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1709117309; x=1709722109; darn=lists.denx.de; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=0RiJ060W+MiJoLPkrGN4326RYWZe+CwVgExo/eISRDE=; b=PAuLXwMsK/THxEiHAHioECeX+8i5wSxcyQi8tQYm4mt5q60T6rmzNtagVIpX6PFQV+ xpZ4FEdXKqwB1F4Nb7Ulqj/28PL3y12plmb1q9r5vFSNJhZ6uO/BkV/il8YVs49c++IZ m6JVvyZMmsXYay0bAUKjoccgOOaSXgX/2R9rGfgZrz7xfjGI8QJyZHpPLsOcSkspnL0V KakXfTHtzbmVKlJJv28j0E7f09UKD5L6lxSkYdx5Iuwm8Qa3OV8leaZLe0a/iZ/wAf2C HfocE+iMaSzAHFDGDWv/4BVdKxzBon979ksY49v3z27JaqD2q9Bvaw/pqz0NjZvblMJ0 nRPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709117309; x=1709722109; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=0RiJ060W+MiJoLPkrGN4326RYWZe+CwVgExo/eISRDE=; b=LWYlmrc7kkiWxVeHDv2cDF4d/AF0KiRrJT128JhdY6HRUyh5SOLL9UnnVeAw6n9Yly XFzRv8gUXqeH6wZ8KAiNLh+PpBOW3YCAjMw/Mj6ZbN/RNX1ktP8oxwyD7u4GGE9O0G/b FQiVcDcpbKtAA/QPoVUufD7gz5aFZ52OCVk50N2T3r4b5UwoaK+HvCpPsLOvwXYBkYVj BceA+iVn0s3EQPE0hOifsftbn5Urybxe8e+GtNMDQmxsJMT3/mGOC14a6U0gZTvW+SG5 WjxobUcDcXtJxUy5h2sQG8u9Fkp8oIixpanvgfMHNQ+KqZGqOEPmIsLrYKuI/nf5aB+2 yFsQ== X-Gm-Message-State: AOJu0Yzq5b3YzLET1zobQXPvX1K61zvnJgstaK650nAEJBpudklMSS1r i2MSRF+l75c8Ve5SSc0Ke4czRP2g0DB2cul9znnmTmYP9CtYtfgQTQF+wpFBqdNXW3JH4arhDgC 7ZYs= X-Google-Smtp-Source: AGHT+IHiyARlL2wi6DZkqf3Vv9qhoRsMOQmrh5WF/9dyCp50cqICL+Bxu/6csILTgBYXNreFPEX6dg== X-Received: by 2002:a05:600c:4f48:b0:412:73f5:3aa5 with SMTP id m8-20020a05600c4f4800b0041273f53aa5mr2043657wmq.16.1709117309425; Wed, 28 Feb 2024 02:48:29 -0800 (PST) Received: from hades.. ([78.87.146.252]) by smtp.gmail.com with ESMTPSA id x1-20020a05600c2a4100b00410dd253008sm1680314wme.42.2024.02.28.02.48.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Feb 2024 02:48:29 -0800 (PST) From: Ilias Apalodimas To: u-boot@lists.denx.de, trini@konsulko.com, cfsworks@gmail.com Cc: caleb.connolly@linaro.org, sumit.garg@linaro.org, Ilias Apalodimas , Simon Glass , Philipp Tomsich , Kever Yang , Michal Simek , Jorge Ramirez-Ortiz , Yegor Yefremov , Heinrich Schuchardt , Shiji Yang , Bin Meng Subject: [RFC PATCH 0/6] Clean up arm linker scripts Date: Wed, 28 Feb 2024 12:48:03 +0200 Message-Id: <20240228104811.1366694-1-ilias.apalodimas@linaro.org> X-Mailer: git-send-email 2.37.2 MIME-Version: 1.0 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 The arm linker scripts had a mix of symbols and C defined variables in an effort to emit relative references instead of absolute ones e.g [0]. This has led to confusion over the years, ending up with mixed section definitions. Some sections being defined with overlays and different definitions between v7 and v8 architectures. For example __efi_runtime_rel_start/end is defined as a linker symbol for armv8 and a C variable in armv7. I am not sure if this used to be a compiler bug, but linker scripts nowadays can emit relative references, as long as the symbol definition is contained within the section definition. So let's switch most of the C defined variables and clean up the arm sections.c file. There's still a few symbols remaining -- __secure_start/end, __secure_stack_start/end and __end which can be cleaned up in a followup series. The resulting binary (tested in QEMU v7/v8) had no size differences apart from the emited sections and object types of those variables. I've also added prints throughout the U-Boot init sequence. The offsets and delta for 'end - start' section sizes is unchanged. For example on QEMU v8: $~ ./scripts/bloat-o-meter u-boot u-boot.new add/remove: 0/0 grow/shrink: 0/0 up/down: 0/0 (0) Function old new delta Total: Before=798861, After=798861, chg +0.00% $~ readelf -sW u-boot | grep bss_s 12: 00000000001029b8 0 SECTION LOCAL DEFAULT 12 .bss_start 8088: 0000000000000018 0 NOTYPE GLOBAL DEFAULT 1 _bss_start_ofs 8376: 00000000001029b8 0 OBJECT GLOBAL DEFAULT 12 __bss_start $~ readelf -sW u-boot.new | grep bss_s 8085: 0000000000000018 0 NOTYPE GLOBAL DEFAULT 1 _bss_start_ofs 8373: 00000000001029b8 0 NOTYPE GLOBAL DEFAULT 12 __bss_start For QEMU v7 the differences are a bit bigger but only affect the variables placed in the .bss section because that was defined as an OVERLAY in the existing linker script. For example: $~ nm u-boot | grep tftp_prev_block 000ca0dc ? tftp_prev_block $~ nm u-boot.new | grep tftp_prev_block 000e0a5c b tftp_prev_block -----> The symbol is now placed into .bss It's worth noting that since the efi regions are affected by the change, booting with EFI is preferable while testing. Booting the kernel only should be enough since the efi stub and the kernel proper do request boottime and runtime services respectively. Something along the lines of > virtio scan && load virtio 0 $kernel_addr_r Image && bootefi $kernel_addr_r will work for QEMU aarch64. Tested platforms: - QEMU aarch64 - Xilinx kv260 kria starter kit & zynq - QEMU armv7 - STM32MP157C-DK2 [0] commit 3ebd1cbc49f0 ("arm: make __bss_start and __bss_end__ compiler-generated") Ilias Apalodimas (6): arm: baltos: remove custom linker script arm: clean up v7 and v8 linker scripts for bss_start/end arm: fix __efi_runtime_rel_start/end definitions arm: clean up v7 and v8 linker scripts for __rel_dyn_start/end arm: fix __efi_runtime_start/end definitions arm: move image_copy_start/end to linker symbols arch/arm/cpu/armv8/u-boot-spl.lds | 14 +-- arch/arm/cpu/armv8/u-boot.lds | 45 ++------ arch/arm/cpu/u-boot.lds | 74 +++---------- arch/arm/lib/sections.c | 10 -- arch/arm/mach-rockchip/u-boot-tpl-v8.lds | 22 +--- arch/arm/mach-zynq/u-boot.lds | 72 +++--------- board/qualcomm/dragonboard820c/u-boot.lds | 41 ++----- board/vscom/baltos/u-boot.lds | 128 ---------------------- include/asm-generic/sections.h | 3 + lib/efi_loader/efi_runtime.c | 1 + 10 files changed, 58 insertions(+), 352 deletions(-) delete mode 100644 board/vscom/baltos/u-boot.lds --- 2.37.2