[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [PATCH livepatch-build-tools v2] 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 <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
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |