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

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


  • To: xen-devel@xxxxxxxxxxxxxxxxxxxx
  • From: Frediano Ziglio <frediano.ziglio@xxxxxxxxxx>
  • Date: Thu, 18 Sep 2025 10:51:58 +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=ktzx6CKOqAF7tJgOGNm+G3PydSf4daiAaHEhq+rcEzI=; b=V6mZSpDQjzRNsUn07H1IQyYI40PEyK/zGTcIIRjQj6FJphOejv78PsidwzGb+xkx7tgNxW2jowoY+ZBrOY7dKAaBsvZU/GHgycmtUKT+HOh+hQD/ZSOegfHQPiyTtSrO4L0Xn4ZJVsHTimBYuLPd/O2Ik7Rkz3fchyFjaX9Ll+IbgeVTUthmfPZPXL57HAK6B6gdzKhtGCy/RA0EzZjBl8Sr7OYNcUDGakLu/54tWksxLK/l5gGfdZlNh513VEHqAZNyJ+YImpNpZwlAK00fX+SZ/6YqDVovCEYB3Db5CzrNBMVhh2OeaoKAVeGSD+NWr9kNZV38nMNMxoGBXUOUmg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=g/TSds8bJKj2ewlyGJYBcU06Fn/zLwKMloIEwOze9b6YkN9WfduI3FH+fDGZ9IAl+EOrBhWpzIoh9ZS5osXjPPQAyw036ZmdxfleKhLsK8qEK0z2EALbJFCnFVoVNAZ08ZTpV5/5/bTm11GPFioqU66/SbKWmpSDk0pxBP5Od/b5EkE+IQgoRsFcW4NNNfGPwboNmMp4Wo0m+k20QRU+kZ4gJ++/nMeijJFj+OIyU5bIEDGiJZySJxQQ4CdcRrBFfWrrkGk5C8LR/MtBtMRbnPRlSRVC40/pUWxlGyVG8aKx3pIxbep0Pc+3Sp6QU5j6UMWQB+qaJPrazKvLqzeffA==
  • 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: Thu, 18 Sep 2025 10:01:40 +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 | 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




 


Rackspace

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