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: 776452 Delivered-To: patch@linaro.org Received: by 2002:adf:e94d:0:b0:33d:f458:43ce with SMTP id m13csp226726wrn; Wed, 28 Feb 2024 02:48:39 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCVmUmOAVR46PN6Wt7ePGly4mV0eM1FewyljZvZmFc8rXunlhnyZOwDVd0yfn2OPo9E7zSoQQj+GzyQKK9Y13T3J X-Google-Smtp-Source: AGHT+IFXO2XG3h6icI8G3gIpFeBDlIPkNP0oS1KY05jHq1Jdc6SJVVHpV9R/JZNhYbpwy0FxPibb X-Received: by 2002:a5d:4051:0:b0:33d:754c:8daf with SMTP id w17-20020a5d4051000000b0033d754c8dafmr1819224wrp.10.1709117319490; Wed, 28 Feb 2024 02:48:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1709117319; cv=none; d=google.com; s=arc-20160816; b=fOG+bhyCh7iAvWJAEcHSxu/cG+KBg+Nulmt1MRLMLMNptqcCgwHQKplCHquZROJ0lD A4vQN0ymibkv6UJ1gtY4WjCTQKAsDUgcnilF5nFwdi95ikDd6C4CAzKgZEMWuS3Oj/8Y W6dPfjM5ZmXATg53jBGhPZHdhu4UNLG8Hvyq3PdQDnmXzobeg+9pmdK9cd1SeRD0NU/D UyvyGm5K+nQufip191OclLE2rDBQk+vT6YzaD71lC/zh3vbUn0BkM6t782IzDyeOeAA4 0hBtjpHSY3+42uEH7cEyxmatgxjpo5sZqwaM380lb7dMiFyrZmO6CwxniwSZ8szM7+Fv XSqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature; bh=0RiJ060W+MiJoLPkrGN4326RYWZe+CwVgExo/eISRDE=; fh=Qc7Bwm8F6A6m2T1dNMTqiCGSn6FsxQ9ndhZ8EDBeZTo=; b=orDcv9SvmuRXZZxuFM6yP5LrczYOqkJ5ZktuczLIPXlAmrNpMOLi2bMaUBcY/mCzj/ 3wtApiVDQM7q9vg7z13ENzEL9qjAzfdtNU3kYurNP6R/MS5DaWw0rkf8NsnKloE3zZ8p 7wCQt2H+xGHa1XKY+wI9AkgLru+95dTHR0WNMk5yxLIB2DWaXoZuEDH+DOmVXAjivjui QlVU6Ljs8eRX8L3/Fdzr5vtUueJl9MxQwKBnhuo1lUZaTXtrhgubWhB8N/DGMc6j4id5 nLKJC+EiMmKBEYhvy/XDwHEwI7byNFE1c4VVWo5gKw0GxIk3P1yGZJvX0ujZw6h0yBnU 9zfA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=PAuLXwMs; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [85.214.62.61]) by mx.google.com with ESMTPS id e15-20020adff34f000000b0033dc6de0e42si4305587wrp.0.2024.02.28.02.48.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Feb 2024 02:48:39 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=PAuLXwMs; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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-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