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

Re: [Xen-devel] [PATCH LIVEPATCH-BUILD-TOOLS] Fix patch creation with GCC 6.1+



On November 24, 2016 4:49:20 AM EST, Ross Lagerwall <ross.lagerwall@xxxxxxxxxx> 
wrote:
>GCC 6.1+ fixed https://gcc.gnu.org/bugzilla/show_bug.cgi?id=192 which
>means that .rodata.str* sections are now split by function.  We could
>probably be smarter about including just the sections we need, but for
>now, include all .rodata.str* sections as is done for previous versions
>of GCC.
>

Here you say .str*

But the code only does this for .str1.*

Did you mean to make it.more generic for say .rodata.*.str[0-9].*

?


>This manifests itself as symbol error. E.g.:
>(XEN)  Unknown symbol: .LC0
>
>Signed-off-by: Ross Lagerwall <ross.lagerwall@xxxxxxxxxx>
>Reported-by: M A Young <m.a.young@xxxxxxxxxxxx>
>---
> create-diff-object.c | 39 ++++++++++++++++++++++++++++++++++++++-
> 1 file changed, 38 insertions(+), 1 deletion(-)
>
>diff --git a/create-diff-object.c b/create-diff-object.c
>index 69bcd88..b0d1348 100644
>--- a/create-diff-object.c
>+++ b/create-diff-object.c
>@@ -1184,6 +1184,43 @@ static void
>kpatch_process_special_sections(struct kpatch_elf *kelf)
>       }
> }
> 
>+/* Returns true if s is a string of only numbers with length > 0. */
>+static int isnumber(const char *s)
>+{
>+      do {
>+              if (!*s || !isdigit(*s))
>+                      return 0;
>+      } while (*++s);
>+
>+      return 1;
>+}
>+
>+/*
>+ * String sections are always included even if unchanged.
>+ * The format is either:
>+ * .rodata.<func>.str1.[0-9]+ (new in GCC 6.1.0)
>+ * or .rodata.str1.[0-9]+ (older versions of GCC)
>+ * For the new format we could be smarter and only include the needed
>+ * strings sections.
>+ */
>+static int should_include_str_section(const char *name)
>+{
>+      const char *s;
>+
>+      if (strncmp(name, ".rodata.", 8))
>+              return 0;
>+
>+      /* Check if name matches ".rodata.str1.[0-9]+" */
>+      if (!strncmp(name, ".rodata.str1.", 13))
>+              return isnumber(name + 13);
>+
>+      /* Check if name matches ".rodata.<func>.str1.[0-9]+" */
>+      s = strstr(name, ".str1.");
>+      if (!s)
>+              return 0;
>+      return isnumber(s + 6);
>+}
>+
> static void kpatch_include_standard_elements(struct kpatch_elf *kelf)
> {
>       struct section *sec;
>@@ -1193,7 +1230,7 @@ static void
>kpatch_include_standard_elements(struct kpatch_elf *kelf)
>               if (!strcmp(sec->name, ".shstrtab") ||
>                   !strcmp(sec->name, ".strtab") ||
>                   !strcmp(sec->name, ".symtab") ||
>-                  !strncmp(sec->name, ".rodata.str1.", 13)) {
>+                  should_include_str_section(sec->name)) {
>                       sec->include = 1;
>                       if (sec->secsym)
>                               sec->secsym->include = 1;


Thanks!


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
https://lists.xen.org/xen-devel

 


Rackspace

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