[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH livepatch-build-tools v2] Treat constant sections as string sections


  • To: xen-devel@xxxxxxxxxxxxxxxxxxxx
  • From: Frediano Ziglio <frediano.ziglio@xxxxxxxxxx>
  • Date: Tue, 7 Oct 2025 13:38:55 +0100
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=JzXBy9q2rZHz5Leac3PtUcTLC31gSKUmboThEqNAc7g=; b=afQQx5lmXXA6YQo2IlgRSgQzF+LM11oupjXn8IkpX+obV/nDFB4dPJTYUimLNsZwzOlPts45rzXrX9O2R8XxhHC14ZLFKh0qLTWi1J/Wu5ys3OV+sQUG78m8YqqGsPxOWP4Mm3BD4jSke5suJstVBT8XCj3/G5eQkybltApIk2qybkx9HVl35ihmLDQ+HINpjorG4RkU2plGQqTm5TrNLbTBhSQ6YZ5AvulmtlzrCPdHLjAbbljmROolr09VXgX9Hk4MeoT1lizzzly8jqydag/kXGDvlO3IH3Jqs+m4J3GRZxXIJ/LFiLtAzg30yZGmcpvv4QNyyS8W6jAHIRuCYQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=VkhQdx1M6ujOWxgBXptKreGT7k2Zy8FCF/uTXRz1pWrTcpaUKEOYzElWzcDKu3mpCxSLJbp3auhBDgHkTgEVNdZXBmXWaslSDF6JzCnkqhSTv58xZvf0n5mBqpkKMhZwUfoTFS9X8fOBsSAtR3wwkrI+cNextfY39V8SpjWGAvW0iR6wVuwU76sA1godqhoPgYAqyQdQD/gANJOE7zQujAHFUNB0qRPNcOIIOVHAFsTHnJcubQ1rtYBis3kaODT53WHT+OcRZwaVIclKBMMOlrcDiqA4WxoXOK5hJxeXGJSp7YDxiBQymClkQN3h4IVXmK3W/UvwvqVZbuJrMLbuaw==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com;
  • Cc: Frediano Ziglio <frediano.ziglio@xxxxxxxxxx>, "Ross Lagerwall" <ross.lagerwall@xxxxxxxxxx>, "Konrad Rzeszutek Wilk" <konrad.wilk@xxxxxxxxxx>, "Andrew Cooper" <andrew.cooper3@xxxxxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • Delivery-date: Tue, 07 Oct 2025 12:39:30 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

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@xxxxxxxxxx>
---
 create-diff-object.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/create-diff-object.c b/create-diff-object.c
index 7e6138b..8104017 100644
--- a/create-diff-object.c
+++ b/create-diff-object.c
@@ -1441,16 +1441,24 @@ static bool is_number(const char *s)
  * or .rodata.str1.[0-9]+ (older versions of GCC)
  * For the new format we only include the needed strings sections.
  * For the old format all string sections are always included.
+ * We also treat constant sections .rodata.cst[0-9]+ as string
+ * sections as newer compilers put some strings on them.
  */
 static bool is_rodata_str_section(const char *name)
 {
 #define GCC_5_SECTION_NAME ".rodata.str1."
 #define GCC_6_SECTION_NAME ".str1."
+#define GCC_CONSTANT_SECTION_NAME ".rodata.cst"
        const char *s;
 
        if (strncmp(name, ".rodata.", 8))
                return false;
 
+       /* Check if name matches ".rodata.cst[0-9]+" */
+       if (!strncmp(name, GCC_CONSTANT_SECTION_NAME,
+                    strlen(GCC_CONSTANT_SECTION_NAME)))
+               return is_number(name + strlen(GCC_CONSTANT_SECTION_NAME));
+
        /* 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 +1470,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_CONSTANT_SECTION_NAME
 }
 
 static void kpatch_include_standard_elements(struct kpatch_elf *kelf)
-- 
2.51.0




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.