All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH livepatch-build-tools] Treat constant sections as string sections
@ 2025-09-18  9:51 Frediano Ziglio
  2025-10-03 10:28 ` Roger Pau Monné
  2025-10-06 16:49 ` Ross Lagerwall
  0 siblings, 2 replies; 4+ messages in thread
From: Frediano Ziglio @ 2025-09-18  9:51 UTC (permalink / raw)
  To: xen-devel
  Cc: Frediano Ziglio, Ross Lagerwall, Konrad Rzeszutek Wilk,
	Andrew Cooper, Roger Pau Monné

Newer compiler can put some constant strings inside constant
sections (.rodata.cstXX) instead of string sections (.rodata.str1.XX).
This causes the produced live patch to not apply when such
strings are produced.
So treat the constant sections as string ones.

Signed-off-by: Frediano Ziglio <frediano.ziglio@citrix.com>
---
 create-diff-object.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/create-diff-object.c b/create-diff-object.c
index 7e6138b..7acaf88 100644
--- a/create-diff-object.c
+++ b/create-diff-object.c
@@ -1446,11 +1446,16 @@ static bool is_rodata_str_section(const char *name)
 {
 #define GCC_5_SECTION_NAME ".rodata.str1."
 #define GCC_6_SECTION_NAME ".str1."
+#define GCC_CSTR ".rodata.cst"
 	const char *s;
 
 	if (strncmp(name, ".rodata.", 8))
 		return false;
 
+	/* Check if name matches ".rodata.cst[0-9]+" */
+	if (!strncmp(name, GCC_CSTR, strlen(GCC_CSTR)))
+		return is_number(name + strlen(GCC_CSTR));
+
 	/* Check if name matches ".rodata.str1.[0-9]+" */
 	if (!strncmp(name, GCC_5_SECTION_NAME, strlen(GCC_5_SECTION_NAME)))
 		return is_number(name + strlen(GCC_5_SECTION_NAME));
@@ -1462,6 +1467,7 @@ static bool is_rodata_str_section(const char *name)
 	return is_number(s + strlen(GCC_6_SECTION_NAME));
 #undef GCC_5_SECTION_NAME
 #undef GCC_6_SECTION_NAME
+#undef GCC_CSTR
 }
 
 static void kpatch_include_standard_elements(struct kpatch_elf *kelf)
-- 
2.51.0



^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-10-07 10:49 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-18  9:51 [PATCH livepatch-build-tools] Treat constant sections as string sections Frediano Ziglio
2025-10-03 10:28 ` Roger Pau Monné
2025-10-06 16:49 ` Ross Lagerwall
2025-10-07 10:48   ` Frediano Ziglio

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.