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.zig...@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


Reply via email to