mirror of
https://github.com/dynup/kpatch
synced 2024-12-26 07:12:03 +00:00
Merge pull request #396 from spartacus06/include-new-symbols
Include new symbols
This commit is contained in:
commit
4cd66aa713
@ -1293,6 +1293,22 @@ void kpatch_include_force_elements(struct kpatch_elf *kelf)
|
||||
sym->include = 0;
|
||||
}
|
||||
|
||||
int kpatch_include_new_globals(struct kpatch_elf *kelf)
|
||||
{
|
||||
struct symbol *sym;
|
||||
int nr = 0;
|
||||
|
||||
list_for_each_entry(sym, &kelf->symbols, list) {
|
||||
if (sym->bind == STB_GLOBAL && sym->sec &&
|
||||
sym->status == NEW) {
|
||||
kpatch_include_symbol(sym, 0);
|
||||
nr++;
|
||||
}
|
||||
}
|
||||
|
||||
return nr;
|
||||
}
|
||||
|
||||
int kpatch_include_changed_functions(struct kpatch_elf *kelf)
|
||||
{
|
||||
struct symbol *sym;
|
||||
@ -2588,7 +2604,7 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
struct kpatch_elf *kelf_base, *kelf_patched, *kelf_out;
|
||||
struct arguments arguments;
|
||||
int num_changed, hooks_exist;
|
||||
int num_changed, hooks_exist, new_globals_exist;
|
||||
struct lookup_table *lookup;
|
||||
struct section *sec, *symtab;
|
||||
struct symbol *sym;
|
||||
@ -2638,12 +2654,13 @@ int main(int argc, char *argv[])
|
||||
kpatch_include_debug_sections(kelf_patched);
|
||||
hooks_exist = kpatch_include_hook_elements(kelf_patched);
|
||||
kpatch_include_force_elements(kelf_patched);
|
||||
new_globals_exist = kpatch_include_new_globals(kelf_patched);
|
||||
kpatch_dump_kelf(kelf_patched);
|
||||
kpatch_verify_patchability(kelf_patched);
|
||||
|
||||
if (!num_changed) {
|
||||
if (hooks_exist)
|
||||
log_normal("no changed functions were found, but hooks exist\n");
|
||||
if (hooks_exist || new_globals_exist)
|
||||
log_normal("no changed functions were found, but hooks or new globals exist\n");
|
||||
else {
|
||||
log_normal("no changed functions were found\n");
|
||||
return 3; /* 1 is ERROR, 2 is DIFF_FATAL */
|
||||
|
36
test/integration/new-globals.patch
Normal file
36
test/integration/new-globals.patch
Normal file
@ -0,0 +1,36 @@
|
||||
Index: src/fs/proc/cmdline.c
|
||||
===================================================================
|
||||
--- src.orig/fs/proc/cmdline.c
|
||||
+++ src/fs/proc/cmdline.c
|
||||
@@ -27,3 +27,10 @@ static int __init proc_cmdline_init(void
|
||||
return 0;
|
||||
}
|
||||
fs_initcall(proc_cmdline_init);
|
||||
+
|
||||
+#include <linux/printk.h>
|
||||
+void kpatch_print_message(void)
|
||||
+{
|
||||
+ if (!jiffies)
|
||||
+ printk("hello there!\n");
|
||||
+}
|
||||
Index: src/fs/proc/meminfo.c
|
||||
===================================================================
|
||||
--- src.orig/fs/proc/meminfo.c
|
||||
+++ src/fs/proc/meminfo.c
|
||||
@@ -16,6 +16,8 @@
|
||||
#include <asm/pgtable.h>
|
||||
#include "internal.h"
|
||||
|
||||
+void kpatch_print_message(void);
|
||||
+
|
||||
void __attribute__((weak)) arch_report_meminfo(struct seq_file *m)
|
||||
{
|
||||
}
|
||||
@@ -85,6 +87,7 @@ static int meminfo_proc_show(struct seq_
|
||||
/*
|
||||
* Tagged format, for easy grepping and expansion.
|
||||
*/
|
||||
+ kpatch_print_message();
|
||||
seq_printf(m,
|
||||
"MemTotal: %8lu kB\n"
|
||||
"MemFree: %8lu kB\n"
|
Loading…
Reference in New Issue
Block a user