]> xenbits.xensource.com Git - livepatch-build-tools.git/commitdiff
common: Add is_standard_section() helper function
authorPawel Wieczorkiewicz <wipawel@amazon.de>
Wed, 21 Aug 2019 08:20:41 +0000 (08:20 +0000)
committerRoss Lagerwall <ross.lagerwall@citrix.com>
Thu, 22 Aug 2019 14:27:25 +0000 (15:27 +0100)
Detect standard (always to be included) sections via their section
header type. The standard sections: ".shstrtab", ".symtab", ".strtab"
are either of type SHT_SYMTAB or SHT_STRTAB.

Signed-off-by: Pawel Wieczorkiewicz <wipawel@amazon.de>
Reviewed-by: Andra-Irina Paraschiv <andraprs@amazon.com>
Reviewed-by: Bjoern Doebel <doebel@amazon.de>
Reviewed-by: Norbert Manthey <nmanthey@amazon.de>
Reviewed-by: Ross Lagerwall <ross.lagerwall@citrix.com>
Signed-off-by: Ross Lagerwall <ross.lagerwall@citrix.com>
common.c
common.h
create-diff-object.c

index bc639550b419adc2d0029be312b2f6cf47a6ae10..1fb07cb848214fc940630f059d554cf494847a7e 100644 (file)
--- a/common.c
+++ b/common.c
@@ -5,6 +5,7 @@
 #include <sys/stat.h>
 #include <fcntl.h>
 #include <unistd.h>
+#include <stdbool.h>
 #include <gelf.h>
 
 #include "list.h"
@@ -258,6 +259,17 @@ int is_debug_section(struct section *sec)
        return !strncmp(name, ".debug_", 7);
 }
 
+int is_standard_section(struct section *sec)
+{
+       switch (sec->sh.sh_type) {
+       case SHT_STRTAB:
+       case SHT_SYMTAB:
+               return true;
+       default:
+               return false;
+       }
+}
+
 /* returns the offset of the string in the string table */
 int offset_of_string(struct list_head *list, char *name)
 {
index 7599fe76422b450898b5e332991d37db993afa01..cda690d5b32bf87e2ce3376b7d637da45c224dab 100644 (file)
--- a/common.h
+++ b/common.h
@@ -150,6 +150,7 @@ struct symbol *find_symbol_by_name(struct list_head *list, const char *name);
 int is_text_section(struct section *sec);
 int is_debug_section(struct section *sec);
 int is_rela_section(struct section *sec);
+int is_standard_section(struct section *sec);
 int is_local_sym(struct symbol *sym);
 
 void rela_insn(struct section *sec, struct rela *rela, struct insn *insn);
index 82f777eef83b05cad5896b647495cf7326038556..4699ba026a0dad81d4badd89243a0408c7e2a3ec 100644 (file)
@@ -1278,9 +1278,7 @@ static void kpatch_include_standard_elements(struct kpatch_elf *kelf)
 
        list_for_each_entry(sec, &kelf->sections, list) {
                /* include these sections even if they haven't changed */
-               if (!strcmp(sec->name, ".shstrtab") ||
-                   !strcmp(sec->name, ".strtab") ||
-                   !strcmp(sec->name, ".symtab") ||
+               if (is_standard_section(sec) ||
                    should_include_str_section(sec->name)) {
                        sec->include = 1;
                        if (sec->secsym)