]> xenbits.xensource.com Git - livepatch-build-tools.git/commitdiff
create-diff-object: Ignore .init sections
authorPawel Wieczorkiewicz <wipawel@amazon.de>
Tue, 3 Dec 2019 07:57:09 +0000 (07:57 +0000)
committerRoss Lagerwall <ross.lagerwall@citrix.com>
Wed, 4 Dec 2019 13:54:11 +0000 (13:54 +0000)
The .init sections must not be considered for patching regardless of
whether they are CHANGED or NEW.
Explicitely detect and ignore all such sections, before marking
ignored sections as SAME.

Signed-off-by: Pawel Wieczorkiewicz <wipawel@amazon.de>
Reviewed-by: Ross Lagerwall <ross.lagerwall@citrix.com>
common.c
common.h
create-diff-object.c

index 8f553eaf893528e288ac4df7f3296b5abaf7bed3..68a71f75ac7bed76ae7bd25198c1c53deef93370 100644 (file)
--- a/common.c
+++ b/common.c
@@ -256,6 +256,13 @@ int is_rodata_section(struct section *sec)
               !strncmp(sec->name, ".rodata", 7);
 }
 
+int is_init_section(struct section *sec)
+{
+       return sec->sh.sh_type == SHT_PROGBITS &&
+              (sec->sh.sh_flags & SHF_ALLOC) &&
+              !strncmp(sec->name, ".init", 5);
+}
+
 int is_debug_section(struct section *sec)
 {
        char *name;
index 300e508343b8719e9e8c92df7a36c7e4ff5d9143..2122b93ae9ec26ff5e0c553bd84da8f7d6e26514 100644 (file)
--- a/common.h
+++ b/common.h
@@ -149,6 +149,7 @@ struct symbol *find_symbol_by_name(struct list_head *list, const char *name);
 
 int is_text_section(struct section *sec);
 int is_rodata_section(struct section *sec);
+int is_init_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);
index 8d63940cdb4e380709f37ac78c4e0ffd693cb943..bfe86e4cfe4f629d2c2e473cec9b49217b0d2706 100644 (file)
@@ -881,6 +881,19 @@ static void kpatch_mark_ignored_functions_same(struct kpatch_elf *kelf)
        }
 }
 
+static void livepatch_ignore_init_sections(struct kpatch_elf *kelf)
+{
+       struct section *sec;
+
+       list_for_each_entry(sec, &kelf->sections, list) {
+               if (is_init_section(sec)) {
+                       log_normal("WARNING: Explicitly ignoring .init section: %s\n",
+                                  sec->name);
+                       sec->ignore = 1;
+               }
+       }
+}
+
 static void kpatch_mark_ignored_sections(struct kpatch_elf *kelf)
 {
        struct section *sec, *strsec, *ignoresec;
@@ -2278,6 +2291,8 @@ int main(int argc, char *argv[])
         * We access its sections via the twin pointers in the
         * section, symbol, and rela lists of kelf_patched.
         */
+       log_debug("Ignore .init sections\n");
+       livepatch_ignore_init_sections(kelf_patched);
        log_debug("Mark ignored sections\n");
        kpatch_mark_ignored_sections(kelf_patched);
        log_debug("Compare correlated elements\n");