diff options
author | Joanna Farley <joanna.farley@arm.com> | 2023-05-11 13:12:06 +0200 |
---|---|---|
committer | TrustedFirmware Code Review <review@review.trustedfirmware.org> | 2023-05-11 13:12:06 +0200 |
commit | 3011e1afeb351c46fc6fa39db51f99b5e3fca6ee (patch) | |
tree | 07b42054eb690555cddd887cb73c7c1a8d6b9cbb | |
parent | 3331c33d03ec1cc361f6908044930d3178eeeb5f (diff) | |
parent | 44d9706e5428d8e3588d04565c7cd738ffc1e472 (diff) | |
download | arm-trusted-firmware-3011e1afeb351c46fc6fa39db51f99b5e3fca6ee.tar.gz |
Merge changes from topic "ms/external_deps" into integration
* changes:
feat(libc): add %c to printf/snprintf
feat(compiler-rt): update source files
chore(libfdt): update to v1.7.0 source files
-rw-r--r-- | lib/compiler-rt/builtins/assembly.h | 2 | ||||
-rw-r--r-- | lib/compiler-rt/builtins/int_types.h | 2 | ||||
-rw-r--r-- | lib/libc/printf.c | 7 | ||||
-rw-r--r-- | lib/libc/snprintf.c | 6 | ||||
-rw-r--r-- | lib/libfdt/fdt.c | 20 |
5 files changed, 25 insertions, 12 deletions
diff --git a/lib/compiler-rt/builtins/assembly.h b/lib/compiler-rt/builtins/assembly.h index 69a3d8620..169d49683 100644 --- a/lib/compiler-rt/builtins/assembly.h +++ b/lib/compiler-rt/builtins/assembly.h @@ -267,7 +267,7 @@ #define DEFINE_COMPILERRT_FUNCTION_ALIAS(name, target) \ .globl SYMBOL_NAME(name) SEPARATOR \ SYMBOL_IS_FUNC(SYMBOL_NAME(name)) SEPARATOR \ - DECLARE_SYMBOL_VISIBILITY(SYMBOL_NAME(name)) SEPARATOR \ + DECLARE_SYMBOL_VISIBILITY(name) SEPARATOR \ .set SYMBOL_NAME(name), SYMBOL_NAME(target) SEPARATOR #if defined(__ARM_EABI__) diff --git a/lib/compiler-rt/builtins/int_types.h b/lib/compiler-rt/builtins/int_types.h index 7a72de480..e94d3154c 100644 --- a/lib/compiler-rt/builtins/int_types.h +++ b/lib/compiler-rt/builtins/int_types.h @@ -64,7 +64,7 @@ typedef union { } udwords; #if defined(__LP64__) || defined(__wasm__) || defined(__mips64) || \ - defined(__riscv) || defined(_WIN64) + defined(__SIZEOF_INT128__) || defined(_WIN64) #define CRT_HAS_128BIT #endif diff --git a/lib/libc/printf.c b/lib/libc/printf.c index e52cbed73..faccfdff4 100644 --- a/lib/libc/printf.c +++ b/lib/libc/printf.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014-2021, ARM Limited and Contributors. All rights reserved. + * Copyright (c) 2014-2023, Arm Limited and Contributors. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ @@ -81,6 +81,7 @@ static int unsigned_num_print(unsigned long long int unum, unsigned int radix, * %x - hexadecimal format * %s - string format * %d or %i - signed decimal format + * %c - character format * %u - unsigned decimal format * %p - pointer format * @@ -130,6 +131,10 @@ loop: count += unsigned_num_print(unum, 10, padc, padn); break; + case 'c': + (void)putchar(va_arg(args, int)); + count++; + break; case 's': str = va_arg(args, char *); count += string_print(str); diff --git a/lib/libc/snprintf.c b/lib/libc/snprintf.c index 0e3256cde..21d34168f 100644 --- a/lib/libc/snprintf.c +++ b/lib/libc/snprintf.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2022, ARM Limited and Contributors. All rights reserved. + * Copyright (c) 2017-2023, Arm Limited and Contributors. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ @@ -85,6 +85,7 @@ static void unsigned_num_print(char **s, size_t n, size_t *chars_printed, * * %x (or %X) - hexadecimal format * %d or %i - signed decimal format + * %c - character format * %s - string format * %u - unsigned decimal format * %p - pointer format @@ -181,6 +182,9 @@ loop: unsigned_num_print(&s, n, &chars_printed, unum, 10, padc, padn, false); break; + case 'c': + CHECK_AND_PUT_CHAR(s, n, chars_printed, va_arg(args, int)); + break; case 's': str = va_arg(args, char *); string_print(&s, n, &chars_printed, str); diff --git a/lib/libfdt/fdt.c b/lib/libfdt/fdt.c index 9fe7cf4b7..20c6415b9 100644 --- a/lib/libfdt/fdt.c +++ b/lib/libfdt/fdt.c @@ -106,7 +106,6 @@ int fdt_check_header(const void *fdt) } hdrsize = fdt_header_size(fdt); if (!can_assume(VALID_DTB)) { - if ((fdt_totalsize(fdt) < hdrsize) || (fdt_totalsize(fdt) > INT_MAX)) return -FDT_ERR_TRUNCATED; @@ -115,9 +114,7 @@ int fdt_check_header(const void *fdt) if (!check_off_(hdrsize, fdt_totalsize(fdt), fdt_off_mem_rsvmap(fdt))) return -FDT_ERR_TRUNCATED; - } - if (!can_assume(VALID_DTB)) { /* Bounds check structure block */ if (!can_assume(LATEST) && fdt_version(fdt) < 17) { if (!check_off_(hdrsize, fdt_totalsize(fdt), @@ -165,7 +162,7 @@ const void *fdt_offset_ptr(const void *fdt, int offset, unsigned int len) uint32_t fdt_next_tag(const void *fdt, int startoffset, int *nextoffset) { const fdt32_t *tagp, *lenp; - uint32_t tag; + uint32_t tag, len, sum; int offset = startoffset; const char *p; @@ -191,12 +188,19 @@ uint32_t fdt_next_tag(const void *fdt, int startoffset, int *nextoffset) lenp = fdt_offset_ptr(fdt, offset, sizeof(*lenp)); if (!can_assume(VALID_DTB) && !lenp) return FDT_END; /* premature end */ + + len = fdt32_to_cpu(*lenp); + sum = len + offset; + if (!can_assume(VALID_DTB) && + (INT_MAX <= sum || sum < (uint32_t) offset)) + return FDT_END; /* premature end */ + /* skip-name offset, length and value */ - offset += sizeof(struct fdt_property) - FDT_TAGSIZE - + fdt32_to_cpu(*lenp); + offset += sizeof(struct fdt_property) - FDT_TAGSIZE + len; + if (!can_assume(LATEST) && - fdt_version(fdt) < 0x10 && fdt32_to_cpu(*lenp) >= 8 && - ((offset - fdt32_to_cpu(*lenp)) % 8) != 0) + fdt_version(fdt) < 0x10 && len >= 8 && + ((offset - len) % 8) != 0) offset += 4; break; |