Module Name: src
Committed By: mrg
Date: Thu Aug 3 08:16:31 UTC 2023
Modified Files:
src/sys/arch/evbarm/gumstix: gumstix_machdep.c
src/sys/arch/evbarm/ixm1200: ixm1200_machdep.c
src/sys/arch/hpcarm/hpcarm: pxa2x0_hpc_machdep.c sa11x0_hpc_machdep.c
src/sys/arch/hppa/stand: Makefile.buildboot
src/sys/arch/m68k/m68k: regdump.c
src/sys/arch/macppc/macppc: cpu.c
Log Message:
ignore "-Warray-bounds" for various low level platform code that knows
how something is setup but technically is undefined behaviour. the
most common here is "extern int end;" and then using offsets of "&end"
that are outside the bounds of this 4-byte integer.
these uses are almost certainly all OK in reality.
found by GCC 12.
To generate a diff of this commit:
cvs rdiff -u -r1.73 -r1.74 src/sys/arch/evbarm/gumstix/gumstix_machdep.c
cvs rdiff -u -r1.67 -r1.68 src/sys/arch/evbarm/ixm1200/ixm1200_machdep.c
cvs rdiff -u -r1.31 -r1.32 src/sys/arch/hpcarm/hpcarm/pxa2x0_hpc_machdep.c
cvs rdiff -u -r1.22 -r1.23 src/sys/arch/hpcarm/hpcarm/sa11x0_hpc_machdep.c
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/hppa/stand/Makefile.buildboot
cvs rdiff -u -r1.14 -r1.15 src/sys/arch/m68k/m68k/regdump.c
cvs rdiff -u -r1.72 -r1.73 src/sys/arch/macppc/macppc/cpu.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/arch/evbarm/gumstix/gumstix_machdep.c
diff -u src/sys/arch/evbarm/gumstix/gumstix_machdep.c:1.73 src/sys/arch/evbarm/gumstix/gumstix_machdep.c:1.74
--- src/sys/arch/evbarm/gumstix/gumstix_machdep.c:1.73 Thu Apr 20 08:28:04 2023
+++ src/sys/arch/evbarm/gumstix/gumstix_machdep.c Thu Aug 3 08:16:30 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: gumstix_machdep.c,v 1.73 2023/04/20 08:28:04 skrll Exp $ */
+/* $NetBSD: gumstix_machdep.c,v 1.74 2023/08/03 08:16:30 mrg Exp $ */
/*
* Copyright (C) 2005, 2006, 2007 WIDE Project and SOUM Corporation.
* All rights reserved.
@@ -467,6 +467,13 @@ read_system_serial(void)
char system_serial[GUMSTIX_SYSTEM_SERIAL_SIZE], *src;
char x;
+/*
+ * XXXGCC12.
+ * This accesses beyond what "char *src" is known to supply.
+ */
+#pragma GCC push_options
+#pragma GCC diagnostic ignored "-Warray-bounds"
+
src = (char *)(FLASH_OFFSET_USER_PROTECTION * 2 /*word*/);
*(volatile uint16_t *)0 = FLASH_CMD_READ_ID;
memcpy(system_serial,
@@ -487,6 +494,7 @@ read_system_serial(void)
* gumstix_serial_hash(system_serial);
*/
}
+#pragma GCC pop_options
system_serial_high = system_serial[0] << 24 | system_serial[1] << 16 |
system_serial[2] << 8 | system_serial[3];
system_serial_low = system_serial[4] << 24 | system_serial[5] << 16 |
Index: src/sys/arch/evbarm/ixm1200/ixm1200_machdep.c
diff -u src/sys/arch/evbarm/ixm1200/ixm1200_machdep.c:1.67 src/sys/arch/evbarm/ixm1200/ixm1200_machdep.c:1.68
--- src/sys/arch/evbarm/ixm1200/ixm1200_machdep.c:1.67 Thu Apr 20 08:28:05 2023
+++ src/sys/arch/evbarm/ixm1200/ixm1200_machdep.c Thu Aug 3 08:16:31 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: ixm1200_machdep.c,v 1.67 2023/04/20 08:28:05 skrll Exp $ */
+/* $NetBSD: ixm1200_machdep.c,v 1.68 2023/08/03 08:16:31 mrg Exp $ */
/*
* Copyright (c) 2002, 2003
@@ -61,7 +61,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ixm1200_machdep.c,v 1.67 2023/04/20 08:28:05 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ixm1200_machdep.c,v 1.68 2023/08/03 08:16:31 mrg Exp $");
#include "opt_arm_debug.h"
#include "opt_console.h"
@@ -344,7 +344,14 @@ initarm(void *arg)
#if NKSYMS || defined(DDB) || defined(MODULAR)
if (! memcmp(&end, "\177ELF", 4)) {
+/*
+ * XXXGCC12.
+ * This accesses beyond what "int end" technically supplies.
+ */
+#pragma GCC push_options
+#pragma GCC diagnostic ignored "-Warray-bounds"
sh = (Elf_Shdr *)((char *)&end + ((Elf_Ehdr *)&end)->e_shoff);
+#pragma GCC pop_options
loop = ((Elf_Ehdr *)&end)->e_shnum;
for(; loop; loop--, sh++)
if (sh->sh_offset > 0 &&
Index: src/sys/arch/hpcarm/hpcarm/pxa2x0_hpc_machdep.c
diff -u src/sys/arch/hpcarm/hpcarm/pxa2x0_hpc_machdep.c:1.31 src/sys/arch/hpcarm/hpcarm/pxa2x0_hpc_machdep.c:1.32
--- src/sys/arch/hpcarm/hpcarm/pxa2x0_hpc_machdep.c:1.31 Thu Apr 20 08:28:06 2023
+++ src/sys/arch/hpcarm/hpcarm/pxa2x0_hpc_machdep.c Thu Aug 3 08:16:31 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: pxa2x0_hpc_machdep.c,v 1.31 2023/04/20 08:28:06 skrll Exp $ */
+/* $NetBSD: pxa2x0_hpc_machdep.c,v 1.32 2023/08/03 08:16:31 mrg Exp $ */
/*
* Copyright (c) 1994-1998 Mark Brinicombe.
@@ -40,7 +40,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pxa2x0_hpc_machdep.c,v 1.31 2023/04/20 08:28:06 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pxa2x0_hpc_machdep.c,v 1.32 2023/08/03 08:16:31 mrg Exp $");
#include "opt_ddb.h"
#include "opt_dram_pages.h"
@@ -267,8 +267,15 @@ init_pxa2x0(int argc, char **argv, struc
symbolsize = 0;
#if NKSYMS || defined(DDB) || defined(MODULAR)
if (!memcmp(&end, "\177ELF", 4)) {
+/*
+ * XXXGCC12.
+ * This accesses beyond what "int end" technically supplies.
+ */
+#pragma GCC push_options
+#pragma GCC diagnostic ignored "-Warray-bounds"
sh = (Elf_Shdr *)((char *)&end + ((Elf_Ehdr *)&end)->e_shoff);
loop = ((Elf_Ehdr *)&end)->e_shnum;
+#pragma GCC pop_options
for (; loop; loop--, sh++)
if (sh->sh_offset > 0 &&
(sh->sh_offset + sh->sh_size) > symbolsize)
Index: src/sys/arch/hpcarm/hpcarm/sa11x0_hpc_machdep.c
diff -u src/sys/arch/hpcarm/hpcarm/sa11x0_hpc_machdep.c:1.22 src/sys/arch/hpcarm/hpcarm/sa11x0_hpc_machdep.c:1.23
--- src/sys/arch/hpcarm/hpcarm/sa11x0_hpc_machdep.c:1.22 Thu Apr 20 08:28:06 2023
+++ src/sys/arch/hpcarm/hpcarm/sa11x0_hpc_machdep.c Thu Aug 3 08:16:31 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: sa11x0_hpc_machdep.c,v 1.22 2023/04/20 08:28:06 skrll Exp $ */
+/* $NetBSD: sa11x0_hpc_machdep.c,v 1.23 2023/08/03 08:16:31 mrg Exp $ */
/*
* Copyright (c) 1994-1998 Mark Brinicombe.
@@ -40,7 +40,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sa11x0_hpc_machdep.c,v 1.22 2023/04/20 08:28:06 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sa11x0_hpc_machdep.c,v 1.23 2023/08/03 08:16:31 mrg Exp $");
#include "opt_ddb.h"
#include "opt_dram_pages.h"
@@ -206,7 +206,14 @@ init_sa11x0(int argc, char **argv, struc
symbolsize = 0;
#if NKSYMS || defined(DDB) || defined(MODULAR)
if (!memcmp(&end, "\177ELF", 4)) {
+/*
+ * XXXGCC12.
+ * This accesses beyond what "int end" technically supplies.
+ */
+#pragma GCC push_options
+#pragma GCC diagnostic ignored "-Warray-bounds"
sh = (Elf_Shdr *)((char *)&end + ((Elf_Ehdr *)&end)->e_shoff);
+#pragma GCC pop_options
loop = ((Elf_Ehdr *)&end)->e_shnum;
for (; loop; loop--, sh++)
if (sh->sh_offset > 0 &&
Index: src/sys/arch/hppa/stand/Makefile.buildboot
diff -u src/sys/arch/hppa/stand/Makefile.buildboot:1.6 src/sys/arch/hppa/stand/Makefile.buildboot:1.7
--- src/sys/arch/hppa/stand/Makefile.buildboot:1.6 Tue Nov 13 21:22:37 2018
+++ src/sys/arch/hppa/stand/Makefile.buildboot Thu Aug 3 08:16:31 2023
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile.buildboot,v 1.6 2018/11/13 21:22:37 skrll Exp $
+# $NetBSD: Makefile.buildboot,v 1.7 2023/08/03 08:16:31 mrg Exp $
NOPIE=yes
NOSSP=yes
@@ -70,5 +70,8 @@ ${PROG}: ${OBJS} ${LIBSA} ${LIBZ} ${LIBK
@${SIZE} ${PROG}
@echo ${PROG} total size should not exceed XXXX bytes
+# GCC 12 and newer thinks this is bad (accessing page 0?)
+COPTS.itecons.c+= -Wno-array-bounds
+
.include <bsd.prog.mk>
.include <bsd.klinks.mk>
Index: src/sys/arch/m68k/m68k/regdump.c
diff -u src/sys/arch/m68k/m68k/regdump.c:1.14 src/sys/arch/m68k/m68k/regdump.c:1.15
--- src/sys/arch/m68k/m68k/regdump.c:1.14 Sat Apr 6 03:06:26 2019
+++ src/sys/arch/m68k/m68k/regdump.c Thu Aug 3 08:16:31 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: regdump.c,v 1.14 2019/04/06 03:06:26 thorpej Exp $ */
+/* $NetBSD: regdump.c,v 1.15 2023/08/03 08:16:31 mrg Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@@ -38,7 +38,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: regdump.c,v 1.14 2019/04/06 03:06:26 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: regdump.c,v 1.15 2023/08/03 08:16:31 mrg Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -85,6 +85,12 @@ regdump(struct trapframe *tf, int sbytes
for (i = 0; i < 8; i++)
printf(" %s", hexstr(tf->tf_regs[i+8], 8));
if (sbytes > 0) {
+/*
+ * XXXGCC12.
+ * This accesses beyond what "trapframe *tf" technically supplies.
+ */
+#pragma GCC push_options
+#pragma GCC diagnostic ignored "-Warray-bounds"
if (tf->tf_sr & PSL_S) {
printf("\n\nKernel stack (%s):",
hexstr((int)(((int *)(void *)&tf)-1), 8));
@@ -94,6 +100,7 @@ regdump(struct trapframe *tf, int sbytes
hexstr(tf->tf_regs[SP], 8));
dumpmem((int *)tf->tf_regs[SP], sbytes, 1);
}
+#pragma GCC pop_options
}
doingdump = 0;
splx(s);
Index: src/sys/arch/macppc/macppc/cpu.c
diff -u src/sys/arch/macppc/macppc/cpu.c:1.72 src/sys/arch/macppc/macppc/cpu.c:1.73
--- src/sys/arch/macppc/macppc/cpu.c:1.72 Sat Feb 15 07:20:41 2020
+++ src/sys/arch/macppc/macppc/cpu.c Thu Aug 3 08:16:31 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: cpu.c,v 1.72 2020/02/15 07:20:41 skrll Exp $ */
+/* $NetBSD: cpu.c,v 1.73 2023/08/03 08:16:31 mrg Exp $ */
/*-
* Copyright (c) 2001 Tsubai Masanari.
@@ -33,7 +33,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.72 2020/02/15 07:20:41 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.73 2023/08/03 08:16:31 mrg Exp $");
#include "opt_ppcparam.h"
#include "opt_multiprocessor.h"
@@ -235,9 +235,17 @@ md_setup_trampoline(volatile struct cpu_
u_int node, off;
char cpupath[32];
+/*
+ * XXXGCC12 has:
+ * macppc/cpu.c:239:17: error: array subscript 0 is outside array bounds
+ * of 'u_int[0]' {aka 'unsigned int[]'} [-Werror=array-bounds]
+ */
+#pragma GCC push_options
+#pragma GCC diagnostic ignored "-Warray-bounds"
/* construct an absolute branch instruction */
*(u_int *)EXC_RST = /* ba cpu_spinup_trampoline */
0x48000002 | (u_int)cpu_spinup_trampoline;
+#pragma GCC pop_options
__syncicache((void *)EXC_RST, 0x100);
h->hatch_running = -1;