[PATCH u-boot v2 10/38] efi_loader: fix warning when linking with LTO
Marek Behun
marek.behun at nic.cz
Mon Mar 15 23:34:20 CET 2021
On Fri, 12 Mar 2021 17:42:35 +0100
Heinrich Schuchardt <xypron.glpk at gmx.de> wrote:
> On 12.03.21 11:34, Marek Behún wrote:
> > When linking with LTO, the compiler complains about type mismatch of
> > variables `__efi_runtime_start`, `__efi_runtime_stop`,
> > `__efi_runtime_rel_start` and `__efi_runtime_rel_stop`:
> >
> > include/efi_loader.h:218:21: warning: type of ‘__efi_runtime_start’
> > does not match original
> > declaration [-Wlto-type-mismatch]
> > 218 | extern unsigned int __efi_runtime_start, __efi_runtime_stop;
> > | ^
> > arch/sandbox/lib/sections.c:7:6: note: ‘__efi_runtime_start’ was
> > previously declared here
> > 7 | char __efi_runtime_start[0] __attribute__((section(".__efi_run
> > | ^
> >
> > Change the type to char[] in include/efi_loader.h.
> >
> > Signed-off-by: Marek Behún <marek.behun at nic.cz>
> > Reviewed-by: Bin Meng <bmeng.cn at gmail.com>
>
> This patch leaves us with definition differences:
>
> We have:
>
> arch/arm/lib/sections.c:31:
> char __efi_runtime_start[0]
> __attribute__((section(".__efi_runtime_start")));
>
> arch/x86/lib/sections.c:6:char __efi_runtime_start[0]
> __attribute__((section(".__efi_runtime_start")));
>
> We should use [] everywhere. [0] was needed by elder GCC versions.
No, these two things are different: in the header file we have an
extern declaration, while in the sections.c files those are definitions.
We cannot use char __efi_runtime_start[] for definition, the compiler
will complain:
warning: array ‘__efi_runtime_start’ assumed to have one element
On the other hand the sections.c file explains why those symbols need
to be declared in a C file and why a 0-size array is chosen.
Marek
More information about the U-Boot
mailing list