[PATCH 17/31] sandbox: Allow weak symbols to be dropped
Heinrich Schuchardt
xypron.glpk at gmx.de
Tue Apr 25 04:33:45 CEST 2023
Am 25. April 2023 01:08:22 MESZ schrieb Simon Glass <sjg at chromium.org>:
>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.
This comment does not explain the necessity of the change. Why is it really needed? Has the compiler version in MSYS a problem?
Best regards
Heinrich
>
>Signed-off-by: Simon Glass <sjg at chromium.org>
>---
>
> 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 <log.h>
> #include <linux/compiler.h>
>
>+#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
>
> /* ------------------------------------------------------------------------- */
>
More information about the U-Boot
mailing list