From mboxrd@z Thu Jan 1 00:00:00 1970 From: Marek Behun Date: Mon, 15 Mar 2021 23:34:20 +0100 Subject: [PATCH u-boot v2 10/38] efi_loader: fix warning when linking with LTO In-Reply-To: References: <20210312103429.25895-1-marek.behun@nic.cz> <20210312103429.25895-11-marek.behun@nic.cz> Message-ID: <20210315233420.34a7e7cd@nic.cz> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On Fri, 12 Mar 2021 17:42:35 +0100 Heinrich Schuchardt 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 > > Reviewed-by: Bin Meng > > 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