[ipxe-devel] [PATCH 1/1] [efi] avoid stringop-truncation error in util/elf2efi.c

Heinrich Schuchardt xypron.glpk at gmx.de
Sat Aug 25 06:01:24 UTC 2018


On 08/24/2018 01:34 AM, Michael Brown wrote:
> On 23/08/18 21:12, Heinrich Schuchardt wrote:
>> Avoid the following error with gcc 7.3:
>>
>> In function ‘process_section’,
>>      inlined from ‘elf2pe.isra.4’ at util/elf2efi.c:914:25:
>> util/elf2efi.c:497:2: error: ‘strncpy’ specified bound 8 equals
>> destination size [-Werror=stringop-truncation]
>>    strncpy ( ( char * ) new->hdr.Name, name, sizeof ( new->hdr.Name ) );
>>    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> cc1: all warnings being treated as errors
>>
>> The truncation to eight charactres is desired here, so we don't want this
>> warning to create an error.
>>
>> Signed-off-by: Heinrich Schuchardt <xypron.glpk at gmx.de>
> 
> This should already be fixed by:
> 
>   http://git.ipxe.org/ipxe.git/commitdiff/8ed4e3049
> 
> Michael
> 
Hello Michael,

despite the patch you mention HOSTCC util/elf2efi64 for the
arm64/snp.efi target is called with

-Wall -W -Wformat-nonliteral  -fno-stack-protector -fno-dwarf2-cfi-asm
-fno-exceptions  -fno-unwind-tables -fno-asynchronous-unwind-tables
-Wno-address  -mabi=lp64 -O2 -g -Werror

Please, observe there is no -Wno-stringop-truncation.

So the patches may be similar but for building the arm64/snp.efi target
my patch is still needed.

Further you will have observed that HOSTCC is called with -mabi=lp64 due
to bad patch
[build] Conditionalise use of -mabi=lp64 for ARM64 builds

I will send another patch for that problem.

Could you set up a VM with Debian Buster and test cross compiling with
gcc 8.2, please.

Best regards

Heinrich



More information about the ipxe-devel mailing list