From 139f5292e7985d0326a1d18eee88720255e423dc Mon Sep 17 00:00:00 2001 From: Casey Connolly Date: Wed, 1 Apr 2026 16:15:19 +0200 Subject: string: add strdup_const and kstrdup_const Extend Linux compat by adding kstrdup_const(), backed by lib/string.c. This leverages U-Boots .rodata section on ARM64 to avoid pointlessly duplicating const strings. This is used by the Linux CCF_FULL port and may be useful elsewhere in U-Boot. Signed-off-by: Casey Connolly --- include/asm-generic/sections.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'include/asm-generic') diff --git a/include/asm-generic/sections.h b/include/asm-generic/sections.h index d59787948fd..48bd4fa8604 100644 --- a/include/asm-generic/sections.h +++ b/include/asm-generic/sections.h @@ -9,6 +9,7 @@ #define _ASM_GENERIC_SECTIONS_H_ #include +#include /* References to section boundaries */ @@ -62,6 +63,24 @@ static inline int arch_is_kernel_data(unsigned long addr) } #endif +/** + * is_kernel_rodata - checks if the pointer address is located in the + * .rodata section + * + * @addr: address to check + * + * Returns: true if the address is located in .rodata, false otherwise. + */ +static inline bool is_kernel_rodata(unsigned long addr) +{ +#ifdef CONFIG_ARM64 + return addr >= (unsigned long)__start_rodata && + addr < (unsigned long)__end_rodata; +#else + return false; +#endif +} + /* U-Boot-specific things begin here */ /* Start of U-Boot text region */ -- cgit v1.2.3