From mboxrd@z Thu Jan 1 00:00:00 1970 From: Heinrich Schuchardt Date: Wed, 19 May 2021 04:26:33 +0200 Subject: [PATCH 1/1] sandbox: add symbol _init for RISC-V compilation In-Reply-To: References: <20210513144540.497144-1-xypron.glpk@gmx.de> <66d15ab1-23e3-0ff2-7091-3e46447f8155@gmx.de> Message-ID: <9491ba3a-2508-03e3-a440-74fbe714a489@gmx.de> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On 5/18/21 11:36 PM, Jim Wilson wrote: > On Tue, May 18, 2021 at 2:32 PM Jim Wilson > wrote: > > On Tue, May 18, 2021 at 1:58 PM Heinrich Schuchardt > > wrote: > > I am compiling the sandbox_defconfig target of upstream U-Boot > with GCC > 11. Please, indicate what "legacy user code" you are referring to. > > > I have no idea what that is.? I'm not a uboot developer. > > > By "user code" I mean that it isn't toolchain code, as the toolchain > doesn't use init. > > Jim This seems to be the culprit: common/board_f.c:269: #elif defined(CONFIG_SANDBOX) || defined(CONFIG_EFI_APP) ????????gd->mon_len = (ulong)&_end - (ulong)_init; gd->mon_len is used here: common/board_f.c:344 gd->ram_top = board_get_usable_ram_top(gd->mon_len); @Simon: We don't relocate the sandbox code into the mmap'ed memory. Why should we use a nonzero value of gd->mon_len on the sandbox? When compiling the sandbox on x86_64 u-boot.map has: .init 0x0000000000031000 0x17 *(SORT_NONE(.init)) .init 0x0000000000031000 0x12 /usr/lib/gcc/x86_64-linux-gnu/11/../../../x86_64-linux-gnu/crti.o 0x0000000000031000 _init .init 0x0000000000031012 0x5 /usr/lib/gcc/x86_64-linux-gnu/11/../../../x86_64-linux-gnu/crtn.o This relates to https://github.com/gcc-mirror/gcc/blob/master/libgcc/config/i386/crti.S This file defines symbols _init and _fini. For aarch64 we have: https://github.com/gcc-mirror/gcc/blob/master/libgcc/config/aarch64/crti.S This file contains symbols _init and _fini, too. For RISC-V we have: https://github.com/gcc-mirror/gcc/blob/master/libgcc/config/riscv/crti.S It contains only a comment /* crti.S is empty because .init_array/.fini_array are used exclusively. */ Symbols _init and _fini don't exist on RISC-V. As the usage of _init is deprecated in GCC we should not use it in any U-Boot configuration, neither for SANDBOX nor for EFI_APP. Best regards Heinrich