pc-bios/s390-ccw: Silence GCC 11 stringop-overflow warning
PATCH 1/1 pc-bios/s390-ccw: Silence GCC 11 stringop-overflow warning
When building on Fedora 34 (gcc version 11.0.0 20210210) we get:
In file included from pc-bios/s390-ccw/main.c:11:
In function ‘memset’,
inlined from ‘boot_setup’ at pc-bios/s390-ccw/main.c:185:5,
inlined from ‘main’ at pc-bios/s390-ccw/main.c:288:5:
pc-bios/s390-ccw/libc.h:28:14: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=]
28 | p[i] = c;
| ~~~~~^~~The offending code is:
memset((char *)S390EP, 0, 6);
where S390EP is a const address:
#define S390EP 0x10008
The compiler doesn't now how big that pointed area is, so assume its length is zero. This has been reported as BZ#99578 to GCC:
"gcc-11 -Warray-bounds or -Wstringop-overread warning when accessing a pointer from integer literal"
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99578
As this warning does us more harm than good in the BIOS code (where lot of direct accesses to low memory are done), silence this warning for all BIOS objects.
Re-introduce the cc-c-option macro (see commit 036999e93e4) to check whether the compiler supports this warning or not.
--- pc-bios/s390-ccw/Makefile | 3 +++ 1 file changed, 3 insertions(+)
pc-bios/s390-ccw/Makefile +3 -0
@@ -8,6 +8,8 @@ CFLAGS = -O2 -g quiet-command = $(if $(V),$1,$(if $(2),@printf " %-7s %s\n" $2 $3 && $1, @$1)) cc-option = $(if $(shell $(CC) $1 -S -o /dev/null -xc /dev/null > /dev/null \ 2>&1 && echo OK), $1, $2) +cc-c-option = $(if $(shell $(CC) $1 $2 -c -o /dev/null -xc /dev/null \ + >/dev/null 2>&1 && echo OK), $2, $3) VPATH_SUFFIXES = %.c %.h %.S %.m %.mak %.sh %.rc Kconfig% %.json.in set-vpath = $(if $1,$(foreach PATTERN,$(VPATH_SUFFIXES),$(eval vpath $(PATTERN) $1)))
@@ -30,6 +32,7 @@ OBJECTS = start.o main.o bootmap.o jump2ipl.o sclp.o menu.o \ virtio.o virtio-scsi.o virtio-blkdev.o libc.o cio.o dasd-ipl.o QEMU_CFLAGS := -Wall $(filter -W%, $(QEMU_CFLAGS)) +QEMU_CFLAGS += $(call cc-c-option, $(QEMU_CFLAGS), -Wno-stringop-overflow) QEMU_CFLAGS += -ffreestanding -fno-delete-null-pointer-checks -fno-common -fPIE QEMU_CFLAGS += -fwrapv -fno-strict-aliasing -fno-asynchronous-unwind-tables QEMU_CFLAGS += $(call cc-option, $(QEMU_CFLAGS), -fno-stack-protector)
Signature · 1 line
2.26.3
Quoted 28 lines · Philippe Mathieu-Daudé
When building on Fedora 34 (gcc version 11.0.0 20210210) we get:
In file included from pc-bios/s390-ccw/main.c:11: In function ‘memset’, inlined from ‘boot_setup’ at pc-bios/s390-ccw/main.c:185:5, inlined from ‘main’ at pc-bios/s390-ccw/main.c:288:5: pc-bios/s390-ccw/libc.h:28:14: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=] 28 | p[i] = c; | ~~~~~^~~The offending code is:
memset((char *)S390EP, 0, 6);where S390EP is a const address:
#define S390EP 0x10008The compiler doesn't now how big that pointed area is, so assume its length is zero. This has been reported as BZ#99578 to GCC:
"gcc-11 -Warray-bounds or -Wstringop-overread warning when accessing a pointer from integer literal"
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99578As this warning does us more harm than good in the BIOS code (where lot of direct accesses to low memory are done), silence this warning for all BIOS objects.
Quoted 5 lines
Re-introduce the cc-c-option macro (see commit
036999e93e4) to check whether the compiler supports this warning or not.Suggested-by Thomas Huth <[email protected]>Signed-off-by Philippe Mathieu-Daudé <[email protected]>
untested, but
Quoted 26 lines
--- pc-bios/s390-ccw/Makefile | 3 +++ 1 file changed, 3 insertions(+)pc-bios/s390-ccw/Makefile +3
-0@@ -8,6 +8,8 @@ CFLAGS = -O2 -g quiet-command = $(if $(V),$1,$(if $(2),@printf " %-7s %s\n" $2 $3 && $1, @$1)) cc-option = $(if $(shell $(CC) $1 -S -o /dev/null -xc /dev/null > /dev/null \ 2>&1 && echo OK), $1, $2) +cc-c-option = $(if $(shell $(CC) $1 $2 -c -o /dev/null -xc /dev/null \ + >/dev/null 2>&1 && echo OK), $2, $3) VPATH_SUFFIXES = %.c %.h %.S %.m %.mak %.sh %.rc Kconfig% %.json.in set-vpath = $(if $1,$(foreach PATTERN,$(VPATH_SUFFIXES),$(eval vpath $(PATTERN) $1)))@@ -30,6 +32,7 @@ OBJECTS = start.o main.o bootmap.o jump2ipl.o sclp.o menu.o \ virtio.o virtio-scsi.o virtio-blkdev.o libc.o cio.o dasd-ipl.o QEMU_CFLAGS := -Wall $(filter -W%, $(QEMU_CFLAGS)) +QEMU_CFLAGS += $(call cc-c-option, $(QEMU_CFLAGS), -Wno-stringop-overflow) QEMU_CFLAGS += -ffreestanding -fno-delete-null-pointer-checks -fno-common -fPIE QEMU_CFLAGS += -fwrapv -fno-strict-aliasing -fno-asynchronous-unwind-tables QEMU_CFLAGS += $(call cc-option, $(QEMU_CFLAGS), -fno-stack-protector)
Quoted 51 lines · Philippe Mathieu-Daudé
When building on Fedora 34 (gcc version 11.0.0 20210210) we get:
In file included from pc-bios/s390-ccw/main.c:11: In function ‘memset’, inlined from ‘boot_setup’ at pc-bios/s390-ccw/main.c:185:5, inlined from ‘main’ at pc-bios/s390-ccw/main.c:288:5: pc-bios/s390-ccw/libc.h:28:14: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=] 28 | p[i] = c; | ~~~~~^~~The offending code is:
memset((char *)S390EP, 0, 6);where S390EP is a const address:
#define S390EP 0x10008The compiler doesn't now how big that pointed area is, so assume its length is zero. This has been reported as BZ#99578 to GCC:
"gcc-11 -Warray-bounds or -Wstringop-overread warning when accessing a pointer from integer literal"
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99578As this warning does us more harm than good in the BIOS code (where lot of direct accesses to low memory are done), silence this warning for all BIOS objects.
Re-introduce the cc-c-option macro (see commit
036999e93e4) to check whether the compiler supports this warning or not.Suggested-by Thomas Huth <[email protected]>Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- pc-bios/s390-ccw/Makefile | 3 +++ 1 file changed, 3 insertions(+)pc-bios/s390-ccw/Makefile +2
-0@@ -8,6 +8,8 @@ CFLAGS = -O2 -g quiet-command = $(if $(V),$1,$(if $(2),@printf " %-7s %s\n" $2 $3 && $1, @$1)) cc-option = $(if $(shell $(CC) $1 -S -o /dev/null -xc /dev/null > /dev/null \ 2>&1 && echo OK), $1, $2) +cc-c-option = $(if $(shell $(CC) $1 $2 -c -o /dev/null -xc /dev/null \ + >/dev/null 2>&1 && echo OK), $2, $3) VPATH_SUFFIXES = %.c %.h %.S %.m %.mak %.sh %.rc Kconfig% %.json.in set-vpath = $(if $1,$(foreach PATTERN,$(VPATH_SUFFIXES),$(eval vpath $(PATTERN) $1)))
pc-bios/s390-ccw/Makefile OBJECTS = start.o main.o bootmap.o jump2ipl.o sclp.o menu.o \ · line 35
Quoted 4 lines
pc-bios/s390-ccw/Makefile +1
-0@@ -30,6 +32,7 @@ OBJECTS = start.o main.o bootmap.o jump2ipl.o sclp.o menu.o \ virtio.o virtio-scsi.o virtio-blkdev.o libc.o cio.o dasd-ipl.o QEMU_CFLAGS := -Wall $(filter -W%, $(QEMU_CFLAGS)) +QEMU_CFLAGS += $(call cc-c-option, $(QEMU_CFLAGS), -Wno-stringop-overflow)
Hi Philippe,
looking at this patch again, I wonder whether it's really necessary to introduce the "cc-c-option" macro here? Wouldn't this work with the existing "cc-option" macro, too, since it's only about a flag that is used for the compiler, and not at the assembler stage?
Thomas
Quoted 58 lines · Thomas Huth
Quoted 51 lines · Philippe Mathieu-Daudé
When building on Fedora 34 (gcc version 11.0.0 20210210) we get:
In file included from
pc-bios/s390-ccw/main.c:11:
In function ‘memset’,
inlined from ‘boot_setup’ atpc-bios/s390-ccw/main.c:185:5,
inlined from ‘main’ atpc-bios/s390-ccw/main.c:288:5:
pc-bios/s390-ccw/libc.h:28:14: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=] 28 | p[i] = c;
| ~~~~~^~~The offending code is:
memset((char *)S390EP, 0, 6);where S390EP is a const address:
#define S390EP
0x10008The compiler doesn't now how big that pointed area is, so assume its length is zero. This has been reported as BZ#99578 to GCC:
"gcc-11 -Warray-bounds or -Wstringop-overread warning when accessing a pointer from integer literal"
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99578As this warning does us more harm than good in the BIOS code (where lot of direct accesses to low memory are done), silence this warning for all BIOS objects.
Re-introduce the cc-c-option macro (see commit
036999e93e4) to check whether the compiler supports this warning or not.Suggested-by Thomas Huth <[email protected]>Signed-off-by Philippe Mathieu-Daudé <[email protected]>---
pc-bios/s390-ccw/Makefile | 3 +++1 file changed, 3 insertions(+)pc-bios/s390-ccw/Makefile +2
-0@@ -8,6 +8,8 @@ CFLAGS = -O2 -g quiet-command = $(if $(V),$1,$(if $(2),@printf " %-7s %s\n" $2 $3 && $1, @$1)) cc-option = $(if $(shell $(CC) $1 -S -o /dev/null -xc /dev/null > /dev/null \ 2>&1 && echo OK), $1, $2) +cc-c-option = $(if $(shell $(CC) $1 $2 -c -o /dev/null -xc /dev/null \ + >/dev/null 2>&1 && echo OK), $2, $3)
VPATH_SUFFIXES= %.c %.h %.S %.m %.mak %.sh %.rc Kconfig% %.json.in set-vpath = $(if $1,$(foreach PATTERN,$(VPATH_SUFFIXES),$(eval vpath $(PATTERN) $1)))pc-bios/s390-ccw/Makefile +0
-0@@ -30,6 +32,7 @@ OBJECTS = start.o main.o bootmap.o jump2ipl.o sclp.o menu.o \Quoted 3 lines
virtio.o virtio-scsi.o virtio-blkdev.o libc.o cio.o dasd-ipl.o
QEMU_CFLAGS:= -Wall $(filter -W%, $(QEMU_CFLAGS)) +QEMU_CFLAGS += $(call cc-c-option, $(QEMU_CFLAGS), -Wno-stringop-overflow)Hi Philippe,
Quoted 1 line
looking at this patch again, I wonder whether it's really necessary to introduce the "cc-c-option" macro here? Wouldn't this work with the existing "cc-option" macro, too, since it's only about a flag that is used for the compiler, and not at the assembler stage?
Darn, that old cc-option macro seems to be broken ... needs to be fixed first ... I'll try to come up with a patch.
Thomas