dtc: backport patch to fix gcc11 compilation error

We still need to use this downgraded version of dtc to be able to build
U-Boot v2017.03, so backport this patch to be able to build dtc with the latest
version of gcc

https://onedigi.atlassian.net/browse/DEL-8540

Signed-off-by: Gabriel Valcazar <gabriel.valcazar@digi.com>
This commit is contained in:
Gabriel Valcazar 2023-05-23 17:55:23 +02:00
parent c0ef35cd95
commit d2ec905166
2 changed files with 54 additions and 0 deletions

View File

@ -0,0 +1,53 @@
From: David Gibson <david@gibson.dropbear.id.au>
Date: Wed, 6 Jan 2021 14:52:26 +1100
Subject: [PATCH] fdtdump: Fix gcc11 warning
In one place, fdtdump abuses fdt_set_magic(), passing it just a small char
array instead of the full fdt header it expects. That's relying on the
fact that in fact fdt_set_magic() will only actually access the first 4
bytes of the buffer.
This trips a new warning in GCC 11 - and it's entirely possible it was
always UB. So, don't do that.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
(cherry picked from commit ca16a723fa9dde9c5da80dba567f48715000e77c)
---
fdtdump.c | 2 +-
libfdt/libfdt.h | 10 ++++++++++
2 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/fdtdump.c b/fdtdump.c
index fa3b561..072c0af 100644
--- a/fdtdump.c
+++ b/fdtdump.c
@@ -214,7 +214,7 @@ int main(int argc, char *argv[])
char *p = buf;
char *endp = buf + len;
- fdt_set_magic(smagic, FDT_MAGIC);
+ fdt32_st(smagic, FDT_MAGIC);
/* poor man's memmem */
while ((endp - p) >= FDT_MAGIC_SIZE) {
diff --git a/libfdt/libfdt.h b/libfdt/libfdt.h
index 313c72a..8795f10 100644
--- a/libfdt/libfdt.h
+++ b/libfdt/libfdt.h
@@ -153,6 +153,16 @@ static inline void *fdt_offset_ptr_w(void *fdt, int offset, int checklen)
uint32_t fdt_next_tag(const void *fdt, int offset, int *nextoffset);
+static inline void fdt32_st(void *property, uint32_t value)
+{
+ uint8_t *bp = (uint8_t *)property;
+
+ bp[0] = value >> 24;
+ bp[1] = (value >> 16) & 0xff;
+ bp[2] = (value >> 8) & 0xff;
+ bp[3] = value & 0xff;
+}
+
/**********************************************************************/
/* Traversal functions */
/**********************************************************************/

View File

@ -9,6 +9,7 @@ SRCREV = "22a65c5331c22979d416738eb756b9541672e00d"
SRC_URI:append = " \ SRC_URI:append = " \
file://0001-Remove-redundant-YYLOC-global-declaration.patch \ file://0001-Remove-redundant-YYLOC-global-declaration.patch \
file://0001-fdtdump-Fix-gcc11-warning.patch \
" "
S = "${WORKDIR}/git" S = "${WORKDIR}/git"