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

Re: [Xen-devel] [livepatch-build-tools part2 3/6] create-diff-object: Add is_special_section() helper function



On 4/16/19 1:07 PM, Pawel Wieczorkiewicz wrote:
This function determines, based on the given section name, if the
sections belongs to the special sections category.
It treats a name from the special_sections array as a prefix. Any
sections whose name starts with special section prefix is considered
a special section.

Signed-off-by: Pawel Wieczorkiewicz <wipawel@xxxxxxxxx>
Reviewed-by: Andra-Irina Paraschiv <andraprs@xxxxxxxxxx>
Reviewed-by: Bjoern Doebel <doebel@xxxxxxxxx>
Reviewed-by: Norbert Manthey <nmanthey@xxxxxxxxx>
---
  common.c | 23 +++++++++++++++++++++++
  common.h |  1 +
  2 files changed, 24 insertions(+)

diff --git a/common.c b/common.c
index c968299..a2c860b 100644
--- a/common.c
+++ b/common.c
@@ -290,6 +290,29 @@ int is_referenced_section(const struct section *sec, const 
struct kpatch_elf *ke
        return false;
  }
+int is_special_section(struct section *sec)

const for the parameter?

+{
+       static struct special_section_names {
+               const char *name;
+       } names[] = {
+               { .name         = ".bug_frames"                 },
+               { .name         = ".fixup"                      },
+               { .name         = ".ex_table"                   },
+               { .name         = ".altinstructions"            },
+               { .name         = ".altinstr_replacement"       },
+               { .name         = ".livepatch.hooks"            },
+               { .name         = NULL                          },
+       };
+       struct special_section_names *special;

Wouldn't it be better to reuse the existing special_sections array rather than partially duplicating it here?

+
+       for (special = names; special->name; special++) {
+               if (!strncmp(sec->name, special->name, strlen(special->name)))
+                       return true;

This check is not as precise as it could be, since ".altinstructionsfoo" would be considered special when it actually means nothing to this tool.

--
Ross Lagerwall

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel

 


Rackspace

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