Treat constant sections as string sections
PATCH v2 1/1 Treat constant sections as string sections
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 <[email protected]>
--- create-diff-object.c | 9 +++++++++ 1 file changed, 9 insertions(+)
create-diff-object.c +9 -0
@@ -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)
Signature · 1 line
2.51.0
Quoted 7 lines
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 <[email protected]>
Reviewed-by Ross Lagerwall <[email protected]>
Thanks,
Ross