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 <casey.connolly@linaro.org>
This commit is contained in:
Casey Connolly
2026-04-01 16:15:19 +02:00
committed by Tom Rini
parent f5e96fdffc
commit 139f5292e7
4 changed files with 65 additions and 0 deletions

View File

@@ -104,6 +104,8 @@ size_t strcspn(const char *s, const char *reject);
#ifndef __HAVE_ARCH_STRDUP
extern char * strdup(const char *);
extern char * strndup(const char *, size_t);
extern const char *strdup_const(const char *s);
extern void kfree_const(const void *x);
#endif
#ifndef __HAVE_ARCH_STRSWAB
extern char * strswab(const char *);