Sim bfin build failure with gcc 11

Simon Marchi simon.marchi@polymtl.ca
Mon May 24 01:41:58 GMT 2021



On 2021-05-23 9:37 p.m., Mike Frysinger wrote:
> On 23 May 2021 20:51, Simon Marchi via Gdb-patches wrote:
>> I see this with gcc 11:
>>
>> $ ccache gcc  -DHAVE_CONFIG_H -DWITH_DEFAULT_MODEL='"bf537"' -DWITH_DEFAULT_ALIGNMENT=STRICT_ALIGNMENT  -DWITH_TARGET_BYTE_ORDER=BFD_ENDIAN_LITTLE  -DWITH_HW=1 -DDEFAULT_INLINE=0   -Wall -Wdeclaration-after-statement -Wpointer-arith -Wpointer-sign -Wno-unused -Wunused-value -Wunused-function -Wno-switch -Wno-char-subscripts -Wmissing-prototypes -Wdeclaration-after-statement -Wempty-body -Wmissing-parameter-type -Wold-style-declaration -Werror  -I. -I/home/simark/src/binutils-gdb/sim/bfin -I../common -I/home/simark/src/binutils-gdb/sim/bfin/../common -I../../include -I/home/simark/src/binutils-gdb/sim/bfin/../../include -I../../bfd -I/home/simark/src/binutils-gdb/sim/bfin/../../bfd -I../../opcodes -I/home/simark/src/binutils-gdb/sim/bfin/../../opcodes  -I/usr/include/SDL -D_GNU_SOURCE=1 -D_REENTRANT  -DHAVE_SDL -g3 -O0 -fsanitize=address -fmax-errors=1     -c -o dv-bfin_otp.o -MT dv-bfin_otp.o -MMD -MP -MF .deps/dv-bfin_otp.Tpo /home/simark/src/binutils-gdb/sim/bfin/dv-bfin_otp.c
>> /home/simark/src/binutils-gdb/sim/bfin/dv-bfin_otp.c: In function ‘bfin_otp_write_page’:
>> /home/simark/src/binutils-gdb/sim/bfin/dv-bfin_otp.c:94:3: error: ‘bfin_otp_write_page_val’ accessing 16 bytes in a region of size 4 [-Werror=stringop-overflow=]
>>    94 |   bfin_otp_write_page_val (otp, page, (void *)&otp->data0);
>>       |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> /home/simark/src/binutils-gdb/sim/bfin/dv-bfin_otp.c:94:3: note: referencing argument 3 of type ‘bu64 *’ {aka ‘long unsigned int *’}
>> /home/simark/src/binutils-gdb/sim/bfin/dv-bfin_otp.c:81:1: note: in a call to function ‘bfin_otp_write_page_val’
>>    81 | bfin_otp_write_page_val (struct bfin_otp *otp, bu16 page, bu64 val[2])
>>       | ^~~~~~~~~~~~~~~~~~~~~~~
>>
>> It's not immediately obvious to me why it says that.
> 
> gcc really wants its pointer types to be in harmony.  i cheated here.
> 
> write_page_val wants a pointer to an array of 2 64-bit values.  i know the
> otp struct has "bu64 data0, data1, data2, data3;", and taking the address
> of data0 has the same memory layout as if it were "bu64 data[3];".  but with
> the fortify work gcc has long been doing, they've stopped accepting these
> kinds of hacks.
> 
> this code is not perf sensitive, so i can be less "clever" while keeping the
> compiler happy.
> -mike

Ah, I see.  Well if what you want is make sure the fields are
contiguous, why not make that an array of four bu32 instead?

Simon


More information about the Gdb-patches mailing list