From patchwork Sun Apr 30 01:29:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1775322 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=g68gYKa0; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Q88843Y5Nz1ydW for ; Sun, 30 Apr 2023 11:36:36 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 8EBAC863BC; Sun, 30 Apr 2023 03:31:13 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org 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=chromium.org header.i=@chromium.org header.b="g68gYKa0"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 71BA985CD8; Sun, 30 Apr 2023 03:30:36 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, 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-il1-x12a.google.com (mail-il1-x12a.google.com [IPv6:2607:f8b0:4864:20::12a]) (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 45E8B861AF for ; Sun, 30 Apr 2023 03:30:33 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-il1-x12a.google.com with SMTP id e9e14a558f8ab-32f397b44dcso30561035ab.1 for ; Sat, 29 Apr 2023 18:30:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1682818232; x=1685410232; 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=zI8uJNgAXAJ9qAdjoYtnQ2kBBz9p9YescElJ/jb3icw=; b=g68gYKa0QfjpoIke26sIRUy3pYXDUJCkOkRD6lHMwXywg81W+dV1aWyMuaz9QTf5p6 Z3dRnBoh5P8UmFply3mIFcPYrBPqFcaPUK5XbkH1UG247JvT+s//FHkWfVp0GgD1wIf4 SLkmoVwm4PlnK0PWVHTLdtkCEX4z0r4u9IiqI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682818232; x=1685410232; 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=zI8uJNgAXAJ9qAdjoYtnQ2kBBz9p9YescElJ/jb3icw=; b=d7p4A/x8WMsmRNqlk4E8dYep02LqRUNlGDCnKu+i+WMzWKkuJXo+E0/v6Nw4N8u9Vj UCYfeDYYT3wl1OXnwLIPh71jA4MuisWGRygqAgO48GE6jtVaYsw9cpHuCNj5b6Qiw5FW +2KsBwGDaYMs97h3mxMSWvoE+7Vf2ns1VCjCo0BPPBPD9AXK2UcSUseoS6acl2l1yq8D NixAsdPKdGHqWMK/UCcpmwOcjtzlw6oLZTc36f+WPLS5BcVPuBWIXaJAaY1ruND20UAJ WFGY9yBQygk0/9Hk5uPQdsPM/xIunOcYd3IXEqwB1ZSClDXGYObZDAI/YyKwnBsHD3qO O1kw== X-Gm-Message-State: AC+VfDwkIzIbMsnDO9TO8K4sKDCLQ7syKPK1MqzFnHU5oZd4ivHCbPun OUVneEXAACSGfpUtRP9vMWw4dvdnQDs9eoS3pNU= X-Google-Smtp-Source: ACHHUZ4YJPV9ArS2Bi9dPRxIw99IBksBDTyQLMRts2CV7Yo0V9UE/kXYEjzuf1VzYiv36SMTJUGEuA== X-Received: by 2002:a92:b70e:0:b0:32f:80d5:7668 with SMTP id k14-20020a92b70e000000b0032f80d57668mr2527316ili.8.1682818232720; Sat, 29 Apr 2023 18:30:32 -0700 (PDT) Received: from sjg1.lan (c-73-14-173-85.hsd1.co.comcast.net. [73.14.173.85]) by smtp.gmail.com with ESMTPSA id w4-20020a02cf84000000b0040f8ed3ab81sm7259429jar.129.2023.04.29.18.30.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 29 Apr 2023 18:30:32 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Bin Meng , =?utf-8?q?Pali_Roh=C3=A1r?= , Heinrich Schuchardt , Tom Rini , Simon Glass Subject: [PATCH v2 25/30] sandbox: Allow weak symbols to be dropped Date: Sat, 29 Apr 2023 19:29:58 -0600 Message-ID: <20230430013003.1047454-26-sjg@chromium.org> X-Mailer: git-send-email 2.40.1.495.gc816e09b53d-goog In-Reply-To: <20230430013003.1047454-1-sjg@chromium.org> References: <20230430013003.1047454-1-sjg@chromium.org> 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 sandbox build makes use of a small number of weak symbols. Allow these to be dropped when building for the PE format, since its support for weak symbols is poor. Signed-off-by: Simon Glass --- (no changes since v1) cmd/bootefi.c | 3 ++- cmd/bootz.c | 3 +++ common/usb.c | 3 +++ drivers/core/root.c | 3 +++ drivers/spi/sandbox_spi.c | 3 +++ env/env.c | 6 ++++++ lib/efi_loader/efi_image_loader.c | 3 +++ lib/efi_loader/efi_runtime.c | 4 ++++ lib/lmb.c | 4 +++- lib/time.c | 3 +++ 10 files changed, 33 insertions(+), 2 deletions(-) diff --git a/cmd/bootefi.c b/cmd/bootefi.c index 8aa15a64c836..21e4a87da53a 100644 --- a/cmd/bootefi.c +++ b/cmd/bootefi.c @@ -358,7 +358,8 @@ static efi_status_t do_bootefi_exec(efi_handle_t handle, void *load_options) u16 *exit_data = NULL; /* On ARM switch from EL3 or secure mode to EL2 or non-secure mode */ - switch_to_non_secure_mode(); + if (IS_ENABLED(CONFIG_WEAK_SYMBOLS)) + switch_to_non_secure_mode(); /* * The UEFI standard requires that the watchdog timer is set to five diff --git a/cmd/bootz.c b/cmd/bootz.c index f1423573d23d..1ffafbd6f2b9 100644 --- a/cmd/bootz.c +++ b/cmd/bootz.c @@ -13,6 +13,8 @@ #include #include +#ifdef CONFIG_WEAK_SYMBOLS + int __weak bootz_setup(ulong image, ulong *start, ulong *end) { /* Please define bootz_setup() for your platform */ @@ -20,6 +22,7 @@ int __weak bootz_setup(ulong image, ulong *start, ulong *end) puts("Your platform's zImage format isn't supported yet!\n"); return -1; } +#endif /* * zImage booting support diff --git a/common/usb.c b/common/usb.c index ae9253dfc0ed..cff53254a379 100644 --- a/common/usb.c +++ b/common/usb.c @@ -1220,6 +1220,8 @@ int usb_new_device(struct usb_device *dev) } #endif +#ifdef CONFIG_WEAK_SYMBOLS + __weak int board_usb_init(int index, enum usb_init_type init) { @@ -1231,6 +1233,7 @@ int board_usb_cleanup(int index, enum usb_init_type init) { return 0; } +#endif /* CONFIG_WEAK_SYMBOLS */ bool usb_device_has_child_on_port(struct usb_device *parent, int port) { diff --git a/drivers/core/root.c b/drivers/core/root.c index c4fb48548bb3..e311f93a08c9 100644 --- a/drivers/core/root.c +++ b/drivers/core/root.c @@ -347,10 +347,13 @@ int dm_extended_scan(bool pre_reloc_only) } #endif +#ifdef CONFIG_WEAK_SYMBOLS + __weak int dm_scan_other(bool pre_reloc_only) { return 0; } +#endif #if CONFIG_IS_ENABLED(OF_PLATDATA_INST) && CONFIG_IS_ENABLED(READ_ONLY) void *dm_priv_to_rw(void *priv) diff --git a/drivers/spi/sandbox_spi.c b/drivers/spi/sandbox_spi.c index f844597d04cf..f68c9f33bdb4 100644 --- a/drivers/spi/sandbox_spi.c +++ b/drivers/spi/sandbox_spi.c @@ -41,12 +41,15 @@ struct sandbox_spi_priv { uint mode; }; +#ifdef CONFIG_WEAK_SYMBOLS + __weak int sandbox_spi_get_emul(struct sandbox_state *state, struct udevice *bus, struct udevice *slave, struct udevice **emulp) { return -ENOENT; } +#endif uint sandbox_spi_get_speed(struct udevice *dev) { diff --git a/env/env.c b/env/env.c index ad774f41175b..bcc66b4a6a12 100644 --- a/env/env.c +++ b/env/env.c @@ -53,6 +53,8 @@ static struct env_driver *_env_driver_lookup(enum env_location loc) return NULL; } +#ifdef CONFIG_WEAK_SYMBOLS + static enum env_location env_locations[] = { #ifdef CONFIG_ENV_IS_IN_EEPROM ENVL_EEPROM, @@ -88,6 +90,7 @@ static enum env_location env_locations[] = { ENVL_NOWHERE, #endif }; +#endif /* CONFIG_WEAK_SYMBOLS */ static bool env_has_inited(enum env_location location) { @@ -106,6 +109,8 @@ static void env_set_inited(enum env_location location) gd->env_has_init |= BIT(location); } +#ifdef CONFIG_WEAK_SYMBOLS + /** * arch_env_get_location() - Returns the best env location for an arch * @op: operations performed on the environment @@ -155,6 +160,7 @@ __weak enum env_location env_get_location(enum env_operation op, int prio) { return arch_env_get_location(op, prio); } +#endif /* CONFIG_WEAK_SYMBOLS */ /** * env_driver_lookup() - Finds the most suited environment location diff --git a/lib/efi_loader/efi_image_loader.c b/lib/efi_loader/efi_image_loader.c index 26df0da16c93..c473cd58cfb8 100644 --- a/lib/efi_loader/efi_image_loader.c +++ b/lib/efi_loader/efi_image_loader.c @@ -174,10 +174,13 @@ static efi_status_t efi_loader_relocate(const IMAGE_BASE_RELOCATION *rel, return EFI_SUCCESS; } +#ifdef CONFIG_WEAK_SYMBOLS + void __weak invalidate_icache_all(void) { /* If the system doesn't support icache_all flush, cross our fingers */ } +#endif /** * efi_set_code_and_data_type() - determine the memory types to be used for code diff --git a/lib/efi_loader/efi_runtime.c b/lib/efi_loader/efi_runtime.c index bf54d6ad871d..d7cf3b7e9dc8 100644 --- a/lib/efi_loader/efi_runtime.c +++ b/lib/efi_loader/efi_runtime.c @@ -375,6 +375,9 @@ out: return EFI_EXIT(EFI_UNSUPPORTED); #endif } + +#ifdef CONFIG_WEAK_SYMBOLS + /** * efi_reset_system() - reset system * @@ -399,6 +402,7 @@ void __weak __efi_runtime EFIAPI efi_reset_system( { return; } +#endif /* CONFIG_WEAK_SYMBOLS */ /** * efi_reset_system_init() - initialize the reset driver diff --git a/lib/lmb.c b/lib/lmb.c index b2c233edb64e..f46442aba48a 100644 --- a/lib/lmb.c +++ b/lib/lmb.c @@ -148,9 +148,11 @@ void arch_lmb_reserve_generic(struct lmb *lmb, ulong sp, ulong end, ulong align) lmb_reserve(lmb, sp, bank_end - sp + 1); +#ifdef CONFIG_WEAK_SYMBOLS + if (gd->flags & GD_FLG_SKIP_RELOC) lmb_reserve(lmb, (phys_addr_t)(uintptr_t)_start, gd->mon_len); - +#endif break; } } diff --git a/lib/time.c b/lib/time.c index 00f4a1ac8fb3..e8da2a3aa6a6 100644 --- a/lib/time.c +++ b/lib/time.c @@ -179,6 +179,8 @@ uint64_t usec_to_tick(unsigned long usec) return tick; } +#ifdef CONFIG_WEAK_SYMBOLS + void __weak __udelay(unsigned long usec) { uint64_t tmp; @@ -188,6 +190,7 @@ void __weak __udelay(unsigned long usec) while (get_ticks() < tmp+1) /* loop till event */ /*NOP*/; } +#endif /* ------------------------------------------------------------------------- */