0002-LF-7968-01-fix-Makefile-Suppress-array-bounds-error.patch 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. From b2a94de52ae4a940a87d569815b19d3fa92dd32a Mon Sep 17 00:00:00 2001
  2. From: Tom Hochstein <tom.hochstein@nxp.com>
  3. Date: Mon, 16 May 2022 13:45:16 -0500
  4. Subject: [PATCH] LF-7968-01 fix(Makefile): Suppress array-bounds error
  5. The array-bounds error is triggered now in cases where it was silent
  6. before, causing errors like:
  7. ```
  8. plat/imx/imx8m/hab.c: In function 'imx_hab_handler':
  9. plat/imx/imx8m/hab.c:64:57: error: array subscript 0 is outside array bounds of 'uint32_t[0]' {aka 'unsigned int[]'} [-Werror=array-bounds]
  10. 64 | #define HAB_RVT_CHECK_TARGET_ARM64 ((unsigned long)*(uint32_t *)(HAB_RVT_BASE + 0x18))
  11. | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  12. ```
  13. The error is a false-positive and is entered as a bug [1]. The problem
  14. is fixed partially in GCC 12 and fully in GCC 13 [2].
  15. The partial fix does not work here because the constant addresses used
  16. are less than the 4kB boundary chosen for the partial fix, so suppress
  17. the error until GCC is upgraded to 13.
  18. [1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99578
  19. [2] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99578#c39
  20. Upstream-Status: Inappropriate [other]
  21. Signed-off-by: Tom Hochstein <tom.hochstein@nxp.com>
  22. Signed-off-by: Jacky Bai <ping.bai@nxp.com>
  23. Reviewed-by: Ye Li <ye.li@nxp.com>
  24. Signed-off-by: Brandon Maier <brandon.maier@collins.com>
  25. Upstream: https://github.com/nxp-imx/imx-atf/commit/058bf0f104115037d03e277f079825ef3659c5b9
  26. ---
  27. Makefile | 2 +-
  28. 1 file changed, 1 insertion(+), 1 deletion(-)
  29. diff --git a/Makefile b/Makefile
  30. index c87c3ae08..2d6b90f47 100644
  31. --- a/Makefile
  32. +++ b/Makefile
  33. @@ -346,7 +346,7 @@ WARNINGS += -Wshift-overflow -Wshift-sign-overflow \
  34. endif
  35. ifneq (${E},0)
  36. -ERRORS := -Werror
  37. +ERRORS := -Werror -Wno-error=array-bounds
  38. endif
  39. CPPFLAGS = ${DEFINES} ${INCLUDES} ${MBEDTLS_INC} -nostdinc \
  40. --
  41. 2.41.0