]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
treewide: unify the linker symbol reference format
authorShiji Yang <yangshiji66@outlook.com>
Thu, 3 Aug 2023 01:47:17 +0000 (09:47 +0800)
committerTom Rini <trini@konsulko.com>
Wed, 9 Aug 2023 13:21:42 +0000 (09:21 -0400)
Now all linker symbols are declared as type char[]. Though we can
reference the address via both the array name 'var' and its address
'&var'. It's better to unify them to avoid confusing developers.
This patch converts all '&var' linker symbol refrences to the most
commonly used format 'var'.

Signed-off-by: Shiji Yang <yangshiji66@outlook.com>
Reviewed-by: Tom Rini <trini@konsulko.com>
21 files changed:
arch/arc/lib/relocate.c
arch/arm/cpu/arm926ejs/mxs/mxs.c
arch/arm/cpu/arm926ejs/mxs/spl_boot.c
arch/arm/mach-stm32mp/boot_params.c
arch/mips/lib/reloc.c
arch/mips/mach-jz47xx/jz4780/jz4780.c
arch/mips/mach-mtmips/mt7621/spl/launch.c
arch/mips/mach-mtmips/mt7621/spl/spl.c
arch/riscv/cpu/jh7110/spl.c
arch/x86/lib/relocate.c
arch/x86/lib/spl.c
arch/xtensa/lib/relocate.c
board/sifive/unleashed/unleashed.c
board/sifive/unmatched/unmatched.c
board/starfive/visionfive2/starfive_visionfive2.c
board/xilinx/common/board.c
common/board_f.c
common/board_r.c
drivers/ddr/imx/phy/helper.c
lib/fdtdec.c
lib/trace.c

index 682e274f9bcf477839f1c21c61ac126e122fca03..fd6f4fbc9304c326063ff143d18f02033ea5f5fa 100644 (file)
@@ -13,20 +13,20 @@ DECLARE_GLOBAL_DATA_PTR;
 
 int copy_uboot_to_ram(void)
 {
-       size_t len = (size_t)&__image_copy_end - (size_t)&__image_copy_start;
+       size_t len = (size_t)__image_copy_end - (size_t)__image_copy_start;
 
        if (gd->flags & GD_FLG_SKIP_RELOC)
                return 0;
 
-       memcpy((void *)gd->relocaddr, (void *)&__image_copy_start, len);
+       memcpy((void *)gd->relocaddr, (void *)__image_copy_start, len);
 
        return 0;
 }
 
 int clear_bss(void)
 {
-       ulong dst_addr = (ulong)&__bss_start + gd->reloc_off;
-       size_t len = (size_t)&__bss_end - (size_t)&__bss_start;
+       ulong dst_addr = (ulong)__bss_start + gd->reloc_off;
+       size_t len = (size_t)__bss_end - (size_t)__bss_start;
 
        memset((void *)dst_addr, 0x00, len);
 
@@ -38,8 +38,8 @@ int clear_bss(void)
  */
 int do_elf_reloc_fixups(void)
 {
-       Elf32_Rela *re_src = (Elf32_Rela *)(&__rel_dyn_start);
-       Elf32_Rela *re_end = (Elf32_Rela *)(&__rel_dyn_end);
+       Elf32_Rela *re_src = (Elf32_Rela *)__rel_dyn_start;
+       Elf32_Rela *re_end = (Elf32_Rela *)__rel_dyn_end;
 
        if (gd->flags & GD_FLG_SKIP_RELOC)
                return 0;
@@ -55,8 +55,8 @@ int do_elf_reloc_fixups(void)
                offset_ptr_rom = (Elf32_Addr *)re_src->r_offset;
 
                /* Check that the location of the relocation is in .text */
-               if (offset_ptr_rom >= (Elf32_Addr *)&__image_copy_start &&
-                   offset_ptr_rom < (Elf32_Addr *)&__image_copy_end) {
+               if (offset_ptr_rom >= (Elf32_Addr *)__image_copy_start &&
+                   offset_ptr_rom < (Elf32_Addr *)__image_copy_end) {
                        unsigned int val, do_swap = 0;
                        /* Switch to the in-RAM version */
                        offset_ptr_ram = (Elf32_Addr *)((ulong)offset_ptr_rom +
@@ -64,11 +64,11 @@ int do_elf_reloc_fixups(void)
 
 #ifdef __LITTLE_ENDIAN__
                        /* If location in ".text" section swap value */
-                       if (((u32)offset_ptr_rom >= (u32)&__text_start &&
-                            (u32)offset_ptr_rom <= (u32)&__text_end)
+                       if (((u32)offset_ptr_rom >= (u32)__text_start &&
+                            (u32)offset_ptr_rom <= (u32)__text_end)
 #if defined(__ARC700__) || defined(__ARC600__)
-                           || ((u32)offset_ptr_rom >= (u32)&__ivt_start &&
-                               (u32)offset_ptr_rom <= (u32)&__ivt_end)
+                           || ((u32)offset_ptr_rom >= (u32)__ivt_start &&
+                               (u32)offset_ptr_rom <= (u32)__ivt_end)
 #endif
                           )
                                do_swap = 1;
@@ -91,8 +91,8 @@ int do_elf_reloc_fixups(void)
                                val = (val << 16) | (val >> 16);
 
                        /* Check that the target points into executable */
-                       if (val < (unsigned int)&__image_copy_start ||
-                           val > (unsigned int)&__image_copy_end) {
+                       if (val < (unsigned int)__image_copy_start ||
+                           val > (unsigned int)__image_copy_end) {
                                /* TODO: Use panic() instead of debug()
                                 *
                                 * For some reason GCC might generate
@@ -101,7 +101,7 @@ int do_elf_reloc_fixups(void)
                                 * ----------------------->8--------------------
                                 * static int setup_mon_len(void)
                                 * {
-                                *         gd->mon_len = (ulong)&__bss_end - CONFIG_SYS_MONITOR_BASE;
+                                *         gd->mon_len = (ulong)__bss_end - CONFIG_SYS_MONITOR_BASE;
                                 *         return 0;
                                 * }
                                 * ----------------------->8--------------------
index 4d21e3df76eca374609932e2f80d5b875b07c576..6d6166cb839f485a157e9718544bc72b2b7804da 100644 (file)
@@ -100,7 +100,7 @@ int arch_cpu_init(void)
        struct mxs_clkctrl_regs *clkctrl_regs =
                (struct mxs_clkctrl_regs *)MXS_CLKCTRL_BASE;
 
-       mx28_fixup_vt((uint32_t)&_start);
+       mx28_fixup_vt((uint32_t)_start);
 
        /*
         * Enable NAND clock
index 5598c552ab9b33f1d3cd4b3b0bc6c5f44619a517..5e7bdb78be1d4880598382fbbf9f1321d17078ac 100644 (file)
@@ -103,7 +103,7 @@ static void mxs_spl_fixup_vectors(void)
         */
 
        /* cppcheck-suppress nullPointer */
-       memcpy(0x0, &_start, 0x60);
+       memcpy(0x0, _start, 0x60);
 }
 
 static void mxs_spl_console_init(void)
index 24d04dcf0f99e73ffe894b5a7f1123fca59c8c22..158bf40cb97e8fb688ab1523413a3b312ab936a0 100644 (file)
@@ -29,7 +29,7 @@ void *board_fdt_blob_setup(int *err)
                        return (void *)nt_fw_dtb;
                log_debug("%s: DTB not found.\n", __func__);
        }
-       log_debug("%s: fall back to builtin DTB, %p\n", __func__, &_end);
+       log_debug("%s: fall back to builtin DTB, %p\n", __func__, _end);
 
-       return (void *)&_end;
+       return (void *)_end;
 }
index 67c8af2f35a5722a1facc7126f1b2017bb0f92f5..9cf6809f40688aae47ae0c55d9a1693dec32f64a 100644 (file)
@@ -146,7 +146,7 @@ void relocate_code(ulong start_addr_sp, gd_t *new_gd, ulong relocaddr)
 
        /* Clear the .bss section */
        bss_start = (uint8_t *)((unsigned long)__bss_start + off);
-       bss_len = (unsigned long)&__bss_end - (unsigned long)__bss_start;
+       bss_len = (unsigned long)__bss_end - (unsigned long)__bss_start;
        memset(bss_start, 0, bss_len);
 
        /* Jump to the relocated U-Boot */
index 15d1eff2ba7ad0f083aa4f2787e4b799a604d320..4584368ce814336a8c62848c8bf29919af79290a 100644 (file)
@@ -42,7 +42,7 @@ void board_init_f(ulong dummy)
        enable_caches();
 
        /* Clear the BSS */
-       memset(__bss_start, 0, (char *)&__bss_end - __bss_start);
+       memset(__bss_start, 0, (size_t)__bss_end - (size_t)__bss_start);
 
        gd->flags |= GD_FLG_SPL_INIT;
 
index 37c20a5f564009de9c702a8002d1fb430d456174..95dd65913d4cf9f8bbf77cbd7711204d27254dfa 100644 (file)
@@ -70,7 +70,7 @@ void secondary_cpu_init(void)
                cpumask = 0x0f;
 
                /* Make BootROM/TPL redirect Core1's bootup flow to our entry point */
-               writel((uintptr_t)&_start, sysc + BOOT_SRAM_BASE_REG);
+               writel((uintptr_t)_start, sysc + BOOT_SRAM_BASE_REG);
 
                bootup_secondary_core();
        }
index aa5b267bb96908e2dd001e0f332976aa8cb01be9..25b409e241762c3b23b2f2366dfaa9434cec8487 100644 (file)
@@ -86,7 +86,7 @@ unsigned long spl_nor_get_uboot_base(void)
 
 uint32_t spl_nand_get_uboot_raw_page(void)
 {
-       const struct stage_header *sh = (const struct stage_header *)&_start;
+       const struct stage_header *sh = (const struct stage_header *)_start;
        u32 addr;
 
        addr = image_get_header_size() + be32_to_cpu(sh->stage_size);
index 72adcefa0e9d3154c5cd5bb33d5b2fa9eb392d8a..7da6c261bc5d304827cabd2f5b53d483ffdfe860 100644 (file)
@@ -77,8 +77,8 @@ void harts_early_init(void)
         * If it is not cleared, the ECC part is invalid, and an ECC error
         * will be reported when reading data.
         */
-       ptr = (ulong *)&__bss_end;
-       len = L2_LIM_MEM_END - (ulong)&__bss_end;
+       ptr = (ulong *)__bss_end;
+       len = L2_LIM_MEM_END - (ulong)__bss_end;
        remain = len % sizeof(ulong);
        len /= sizeof(ulong);
 
index 5b1b420a643373888b9908a8955de3bd344aa481..da819b9bdd2c1be9e291dee24de2b801886abecd 100644 (file)
@@ -26,11 +26,11 @@ DECLARE_GLOBAL_DATA_PTR;
 
 int copy_uboot_to_ram(void)
 {
-       size_t len = (uintptr_t)&__data_end - (uintptr_t)&__text_start;
+       size_t len = (uintptr_t)__data_end - (uintptr_t)__text_start;
 
        if (gd->flags & GD_FLG_SKIP_RELOC)
                return 0;
-       memcpy((void *)gd->relocaddr, (void *)&__text_start, len);
+       memcpy((void *)gd->relocaddr, (void *)__text_start, len);
 
        return 0;
 }
@@ -38,8 +38,8 @@ int copy_uboot_to_ram(void)
 #ifndef CONFIG_EFI_APP
 int clear_bss(void)
 {
-       ulong dst_addr = (ulong)&__bss_start + gd->reloc_off;
-       size_t len = (uintptr_t)&__bss_end - (uintptr_t)&__bss_start;
+       ulong dst_addr = (ulong)__bss_start + gd->reloc_off;
+       size_t len = (uintptr_t)__bss_end - (uintptr_t)__bss_start;
 
        if (gd->flags & GD_FLG_SKIP_RELOC)
                return 0;
@@ -150,12 +150,12 @@ static void do_elf_reloc_fixups32(unsigned int text_base, uintptr_t size,
  */
 int do_elf_reloc_fixups(void)
 {
-       void *re_src = (void *)(&__rel_dyn_start);
-       void *re_end = (void *)(&__rel_dyn_end);
+       void *re_src = (void *)__rel_dyn_start;
+       void *re_end = (void *)__rel_dyn_end;
        uint text_base;
 
        /* The size of the region of u-boot that runs out of RAM. */
-       uintptr_t size = (uintptr_t)&__bss_end - (uintptr_t)&__text_start;
+       uintptr_t size = (uintptr_t)__bss_end - (uintptr_t)__text_start;
 
        if (gd->flags & GD_FLG_SKIP_RELOC)
                return 0;
index b6812bb8ca2b365b57b5a8ec1e654ebce701e6e0..73512d3d4c8c8bf4ea848f17f4540a7eb2c4f59e 100644 (file)
@@ -138,9 +138,9 @@ static int x86_spl_init(void)
 
 #ifndef CONFIG_SYS_COREBOOT
        log_debug("bss\n");
-       debug("BSS clear from %lx to %lx len %lx\n", (ulong)&__bss_start,
-             (ulong)&__bss_end, (ulong)&__bss_end - (ulong)&__bss_start);
-       memset(&__bss_start, 0, (ulong)&__bss_end - (ulong)&__bss_start);
+       debug("BSS clear from %lx to %lx len %lx\n", (ulong)__bss_start,
+             (ulong)__bss_end, (ulong)__bss_end - (ulong)__bss_start);
+       memset(__bss_start, 0, (ulong)__bss_end - (ulong)__bss_start);
 # ifndef CONFIG_TPL
 
        /* TODO(sjg@chromium.org): Consider calling cpu_init_r() here */
index 3dc8edc801d7721f946bb4824c0129a41f080b1a..a499590c75bc5f143ef9dd008b36262b63e027de 100644 (file)
@@ -9,8 +9,8 @@
 
 int clear_bss(void)
 {
-       size_t len = (size_t)&__bss_end - (size_t)&__bss_start;
+       size_t len = (size_t)__bss_end - (size_t)__bss_start;
 
-       memset((void *)&__bss_start, 0x00, len);
+       memset((void *)__bss_start, 0x00, len);
        return 0;
 }
index b6ab06a08fb4a0b3bf45e4993d2037aa0a03b81d..3c5dd50c369b5738f3a21895ddba09e188c31f39 100644 (file)
@@ -122,7 +122,7 @@ void *board_fdt_blob_setup(int *err)
                        return (ulong *)(uintptr_t)gd->arch.firmware_fdt_addr;
        }
 
-       return (ulong *)&_end;
+       return (ulong *)_end;
 }
 
 int board_init(void)
index 6295deeae23404300c75b677896b15c62dd5573a..6675548c2bf81ae648194c6ef7db9443010d795f 100644 (file)
@@ -19,7 +19,7 @@ void *board_fdt_blob_setup(int *err)
                        return (ulong *)(uintptr_t)gd->arch.firmware_fdt_addr;
        }
 
-       return (ulong *)&_end;
+       return (ulong *)_end;
 }
 
 int board_init(void)
index 07dcca26b3023b3664f82f306a5b4e51ebdebccf..d609262b67603512f7578cc6de604f458fb357ae 100644 (file)
@@ -49,5 +49,5 @@ void *board_fdt_blob_setup(int *err)
                        return (ulong *)(uintptr_t)gd->arch.firmware_fdt_addr;
        }
 
-       return (ulong *)&_end;
+       return (ulong *)_end;
 }
index 0328d68e751223d8c0fbb2d2eeb7d6b97c6ded74..bc5cdd89b55fb78ba7f0e7df640f1d5f06020d64 100644 (file)
@@ -374,12 +374,12 @@ void *board_fdt_blob_setup(int *err)
                 * region
                 */
                if (IS_ENABLED(CONFIG_SPL_SEPARATE_BSS))
-                       fdt_blob = (ulong *)&_image_binary_end;
+                       fdt_blob = (ulong *)_image_binary_end;
                else
-                       fdt_blob = (ulong *)&__bss_end;
+                       fdt_blob = (ulong *)__bss_end;
        } else {
                /* FDT is at end of image */
-               fdt_blob = (ulong *)&_end;
+               fdt_blob = (ulong *)_end;
        }
 
        if (fdt_magic(fdt_blob) == FDT_MAGIC)
index 50edac5b7a8bac7b609840567ded26bc8228bd69..77e3925a5ad0d2d8f1a0315c66e5b27ad8ea5fd9 100644 (file)
@@ -124,8 +124,8 @@ static int display_text_info(void)
 #if !defined(CONFIG_SANDBOX) && !defined(CONFIG_EFI_APP)
        ulong bss_start, bss_end, text_base;
 
-       bss_start = (ulong)&__bss_start;
-       bss_end = (ulong)&__bss_end;
+       bss_start = (ulong)__bss_start;
+       bss_end = (ulong)__bss_end;
 
 #ifdef CONFIG_TEXT_BASE
        text_base = CONFIG_TEXT_BASE;
@@ -290,21 +290,21 @@ __weak int init_func_vid(void)
 static int setup_mon_len(void)
 {
 #if defined(__ARM__) || defined(__MICROBLAZE__)
-       gd->mon_len = (ulong)&__bss_end - (ulong)_start;
+       gd->mon_len = (ulong)__bss_end - (ulong)_start;
 #elif defined(CONFIG_SANDBOX) && !defined(__riscv)
-       gd->mon_len = (ulong)&_end - (ulong)_init;
+       gd->mon_len = (ulong)_end - (ulong)_init;
 #elif defined(CONFIG_SANDBOX)
        /* gcc does not provide _init in crti.o on RISC-V */
        gd->mon_len = 0;
 #elif defined(CONFIG_EFI_APP)
-       gd->mon_len = (ulong)&_end - (ulong)_init;
+       gd->mon_len = (ulong)_end - (ulong)_init;
 #elif defined(CONFIG_NIOS2) || defined(CONFIG_XTENSA)
        gd->mon_len = CONFIG_SYS_MONITOR_LEN;
 #elif defined(CONFIG_SH) || defined(CONFIG_RISCV)
-       gd->mon_len = (ulong)(&__bss_end) - (ulong)(&_start);
+       gd->mon_len = (ulong)(__bss_end) - (ulong)(_start);
 #elif defined(CONFIG_SYS_MONITOR_BASE)
-       /* TODO: use (ulong)&__bss_end - (ulong)&__text_start; ? */
-       gd->mon_len = (ulong)&__bss_end - CONFIG_SYS_MONITOR_BASE;
+       /* TODO: use (ulong)__bss_end - (ulong)__text_start; ? */
+       gd->mon_len = (ulong)__bss_end - CONFIG_SYS_MONITOR_BASE;
 #endif
        return 0;
 }
index 4aaa89403117e95027ee4b9bd6787bf1ce5a3685..598155c7753d2efb3ae1ddac6608ec003fa5d92a 100644 (file)
@@ -126,9 +126,9 @@ static int initr_reloc_global_data(void)
 #ifdef __ARM__
        monitor_flash_len = _end - __image_copy_start;
 #elif defined(CONFIG_RISCV)
-       monitor_flash_len = (ulong)&_end - (ulong)&_start;
+       monitor_flash_len = (ulong)_end - (ulong)_start;
 #elif !defined(CONFIG_SANDBOX) && !defined(CONFIG_NIOS2)
-       monitor_flash_len = (ulong)&__init_end - gd->relocaddr;
+       monitor_flash_len = (ulong)__init_end - gd->relocaddr;
 #endif
 #if defined(CONFIG_MPC85xx) || defined(CONFIG_MPC86xx)
        /*
index 8cd438791e540c20dc0f9decf936c214482340e1..855a874ac1e1bacd8610549cea4eeda5a6be6d78 100644 (file)
@@ -46,13 +46,13 @@ void ddr_load_train_firmware(enum fw_type type)
        u32 error = 0;
        unsigned long pr_to32, pr_from32;
        uint32_t fw_offset = type ? IMEM_2D_OFFSET : 0;
-       unsigned long imem_start = (unsigned long)&_end + fw_offset;
+       unsigned long imem_start = (unsigned long)_end + fw_offset;
        unsigned long dmem_start;
        unsigned long imem_len = IMEM_LEN, dmem_len = DMEM_LEN;
 
 #ifdef CONFIG_SPL_OF_CONTROL
        if (gd->fdt_blob && !fdt_check_header(gd->fdt_blob)) {
-               imem_start = roundup((unsigned long)&_end +
+               imem_start = roundup((unsigned long)_end +
                                     fdt_totalsize(gd->fdt_blob), 4) +
                        fw_offset;
        }
index c60972dfbe868acee761d5569f0012b9f3e4a024..7a69167648354f005e1d6791e8d1955c879912cd 100644 (file)
@@ -1230,12 +1230,12 @@ static void *fdt_find_separate(void)
 #ifdef CONFIG_SPL_BUILD
        /* FDT is at end of BSS unless it is in a different memory region */
        if (IS_ENABLED(CONFIG_SPL_SEPARATE_BSS))
-               fdt_blob = (ulong *)&_image_binary_end;
+               fdt_blob = (ulong *)_image_binary_end;
        else
-               fdt_blob = (ulong *)&__bss_end;
+               fdt_blob = (ulong *)__bss_end;
 #else
        /* FDT is at end of image */
-       fdt_blob = (ulong *)&_end;
+       fdt_blob = (ulong *)_end;
 
        if (_DEBUG && !fdtdec_prepare_fdt(fdt_blob)) {
                int stack_ptr;
index 1091a5793a1cab6523e7082a0009c8e874c1b6e8..4874bef861bf6c56cc459ea20b8d1af5b3793b49 100644 (file)
@@ -51,7 +51,7 @@ static inline uintptr_t __attribute__((no_instrument_function))
        uintptr_t offset = (uintptr_t)func_ptr;
 
 #ifdef CONFIG_SANDBOX
-       offset -= (uintptr_t)&_init;
+       offset -= (uintptr_t)_init;
 #else
        if (gd->flags & GD_FLG_RELOC)
                offset -= gd->relocaddr;