create-diff-object.c | 6 ++++++ 1 file changed, 6 insertions(+)
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@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
<div class="elementToProof" style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">> From: Frediano Ziglio </div><div class="elementToProof" style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">> Sent: Thursday, September 18, 2025 10:51 AM</div><div class="elementToProof" style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">> To: xen-devel@lists.xenproject.org </div><div class="elementToProof" style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">> Cc: Frediano Ziglio ; Ross Lagerwall ; Konrad Rzeszutek Wilk ; Andrew Cooper ; Roger Pau Monne </div><div class="elementToProof" style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">> Subject: [PATCH livepatch-build-tools] Treat constant sections as string sections</div><div class="elementToProof" style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">> </div><div class="elementToProof" style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">> Newer compiler can put some constant strings inside constant</div><div class="elementToProof" style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">> sections (.rodata.cstXX) instead of string sections (.rodata.str1.XX).</div><div class="elementToProof" style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">> This causes the produced live patch to not apply when such</div><div class="elementToProof" style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">> strings are produced.</div><div class="elementToProof" style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">> So treat the constant sections as string ones.</div><div class="elementToProof" style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);"><br></div><div class="elementToProof" style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">Are you sure it was a string and not something else? As far as I can</div><div class="elementToProof" style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">tell GCC chooses the section in categorize_decl_for_section() which</div><div class="elementToProof" style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">doesn't appear to ever put constant strings in .rodata.cst.</div><div class="elementToProof" style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);"><br></div><div class="elementToProof" style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">In any case if we have a reference to a constant in .rodata.cst then the</div><div class="elementToProof" style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">section _does_ need to be included in its entirety, though it makes me</div><div class="elementToProof" style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">wonder if is_rodata_str_section is the best place for this check.</div><div class="elementToProof" style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);"><br></div><div class="elementToProof" style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">> </div><div class="elementToProof" style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">> Signed-off-by: Frediano Ziglio </div><div class="elementToProof" style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">> ---</div><div class="elementToProof" style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">> create-diff-object.c | 6 ++++++</div><div class="elementToProof" style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">> 1 file changed, 6 insertions(+)</div><div class="elementToProof" style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">> </div><div class="elementToProof" style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">> diff --git a/create-diff-object.c b/create-diff-object.c</div><div class="elementToProof" style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">> index 7e6138b..7acaf88 100644</div><div class="elementToProof" style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">> --- a/create-diff-object.c</div><div class="elementToProof" style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">> +++ b/create-diff-object.c</div><div class="elementToProof" style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">> @@ -1446,11 +1446,16 @@ static bool is_rodata_str_section(const char *name)</div><div class="elementToProof" style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);"><br></div><div class="elementToProof" style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">Can you update the comment at the top of this function?</div><div class="elementToProof" style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);"><br></div><div class="elementToProof" style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">> {</div><div class="elementToProof" style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">> #define GCC_5_SECTION_NAME ".rodata.str1."</div><div class="elementToProof" style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">> #define GCC_6_SECTION_NAME ".str1."</div><div class="elementToProof" style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">> +#define GCC_CSTR ".rodata.cst"</div><div class="elementToProof" style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);"><br></div><div class="elementToProof" style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">What does CSTR stand for? May call it GCC_CONSTANT_SECTION_NAME instead?</div><div class="elementToProof" style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);"><br></div><div class="elementToProof" style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">Ross</div>
> > From: Frediano Ziglio
> > Sent: Thursday, September 18, 2025 10:51 AM
> > To: xen-devel@xxxxxxxxxxxxxxxxxxxx
> > Cc: Frediano Ziglio ; Ross Lagerwall ; Konrad Rzeszutek Wilk ; Andrew Cooper ; Roger Pau Monne
> > Subject: [PATCH livepatch-build-tools] 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.
>
>
> Are you sure it was a string and not something else? As far as I can
> tell GCC chooses the section in categorize_decl_for_section() which
> doesn't appear to ever put constant strings in .rodata.cst.
>
In the specific case it was a "h" string (used for continuation).
>
> In any case if we have a reference to a constant in .rodata.cst then the
> section _does_ need to be included in its entirety, though it makes me
> wonder if is_rodata_str_section is the best place for this check.
>
>
> >
> > Signed-off-by: Frediano Ziglio
> > ---
> > 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)
>
>
> Can you update the comment at the top of this function?
>
I'll do it.
>
> > {
> > #define GCC_5_SECTION_NAME ".rodata.str1."
> > #define GCC_6_SECTION_NAME ".str1."
> > +#define GCC_CSTR ".rodata.cst"
>
>
> What does CSTR stand for? May call it GCC_CONSTANT_SECTION_NAME instead?
>
It makes sense, I'll change it.
>
> Ross
Frediano
On Thu, Sep 18, 2025 at 10:51:58AM +0100, Frediano Ziglio wrote: > 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@citrix.com> Reviewed-by: Roger Pau Monné <roger.pau@citrix.com> Thanks, Roger.
© 2016 - 2026 Red Hat, Inc.