From 5049f910aec254b9656dafe6c4cf7dd3d8b91d5c Mon Sep 17 00:00:00 2001 From: Quentin Schulz Date: Thu, 31 Oct 2024 16:38:25 +0100 Subject: [PATCH 010/159] fix(rk3399): m0: Makefile: fix outside array bounds warning Both GCC and clang actually complain about: """ In file included from src/dram.c:12: src/dram.c: In function 'm0_main': include/rk3399_mcu.h:15:34: warning: array subscript 0 is outside array bounds of 'volatile unsigned int[0]' [-Warray-bounds=] 15 | (*(volatile unsigned int *)(c)); __v; }) | ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ include/rk3399_mcu.h:16:69: note: in definition of macro 'mmio_write_32' 16 | #define mmio_write_32(c, v) ((*(volatile unsigned int *)(c)) = (v)) | ^ src/dram.c:67:23: note: in expansion of macro 'mmio_read_32' 67 | mmio_read_32(PARAM_ADDR + PARAM_FREQ_SELECT)); | ^~~~~~~~~~~~ cc1: note: source object is likely at address zero In function 'ddr_set_pll', inlined from 'm0_main' at src/dram.c:71:2: include/rk3399_mcu.h:14:40: warning: array subscript 0 is outside array bounds of 'volatile unsigned int[0]' [-Warray-bounds=] 14 | #define mmio_read_32(c) ({unsigned int __v = \ | ^~~ include/rk3399_mcu.h:16:69: note: in definition of macro 'mmio_write_32' 16 | #define mmio_write_32(c, v) ((*(volatile unsigned int *)(c)) = (v)) | ^ src/dram.c:47:23: note: in expansion of macro 'mmio_read_32' 47 | mmio_read_32(PARAM_ADDR + PARAM_DPLL_CON0)); | ^~~~~~~~~~~~ In function 'm0_main': cc1: note: source object is likely at address zero In function 'ddr_set_pll', inlined from 'm0_main' at src/dram.c:71:2: include/rk3399_mcu.h:14:40: warning: array subscript 0 is outside array bounds of 'volatile unsigned int[0]' [-Warray-bounds=] 14 | #define mmio_read_32(c) ({unsigned int __v = \ | ^~~ include/rk3399_mcu.h:16:69: note: in definition of macro 'mmio_write_32' 16 | #define mmio_write_32(c, v) ((*(volatile unsigned int *)(c)) = (v)) | ^ src/dram.c:49:23: note: in expansion of macro 'mmio_read_32' 49 | mmio_read_32(PARAM_ADDR + PARAM_DPLL_CON1)); | ^~~~~~~~~~~~ In function 'm0_main': cc1: note: source object is likely at address zero include/rk3399_mcu.h:16:35: warning: array subscript 0 is outside array bounds of 'volatile unsigned int[0]' [-Warray-bounds=] 16 | #define mmio_write_32(c, v) ((*(volatile unsigned int *)(c)) = (v)) | ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ src/dram.c:80:9: note: in expansion of macro 'mmio_write_32' 80 | mmio_write_32(PARAM_ADDR + PARAM_M0_DONE, M0_DONE_FLAG); | ^~~~~~~~~~~~~ cc1: note: source object is likely at address zero """ The global Makefile defines --param=min-pagesize=0 already, so let's just apply the same fix for the m0 part of the RK3399 binary. Suggested-by: Boyan Karatotev Signed-off-by: Quentin Schulz Change-Id: I4f29a579b9e4b01aa2540746ef46e2a382f0012e --- plat/rockchip/rk3399/drivers/m0/Makefile | 3 +++ 1 file changed, 3 insertions(+) Index: arm-trusted-firmware/plat/rockchip/rk3399/drivers/m0/Makefile =================================================================== --- arm-trusted-firmware.orig/plat/rockchip/rk3399/drivers/m0/Makefile +++ arm-trusted-firmware/plat/rockchip/rk3399/drivers/m0/Makefile @@ -5,6 +5,7 @@ # include ../../../../../make_helpers/common.mk +include ../../../../../make_helpers/build_macros.mk include ../../../../../make_helpers/toolchain.mk # Cross Compile @@ -31,6 +32,8 @@ C_SOURCES_PMU := src/suspend.c # Flags definition COMMON_FLAGS := -g -mcpu=$(ARCH) -mthumb -Wall -O3 -nostdlib -mfloat-abi=soft CFLAGS := -ffunction-sections -fdata-sections -fomit-frame-pointer -fno-common +# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105523 +CFLAGS += $(call cc_option, --param=min-pagesize=0) ASFLAGS := -Wa,--gdwarf-2 LDFLAGS := -Wl,--gc-sections -Wl,--build-id=none