Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

symbols with same (empty) name but different type #202

Closed
jstancek opened this issue May 23, 2014 · 2 comments · Fixed by #215
Closed

symbols with same (empty) name but different type #202

jstancek opened this issue May 23, 2014 · 2 comments · Fixed by #215

Comments

@jstancek
Copy link
Contributor

I came across a kpatch-build error, while trying following patch:

# cat tp_trivial_change_to_function_with_tp.patch
diff --git a/kernel/signal.c b/kernel/signal.c
index 50e4107..2a69b78 100644
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -2196,6 +2196,9 @@ int get_signal_to_deliver(siginfo_t *info, struct k_sigaction *return_ka,
    struct signal_struct *signal = current->signal;
    int signr;

+   if (!current)
+       return 0;
+
    if (unlikely(current->task_works))
        task_work_run();

$ kpatch-build tp_trivial_change_to_function_with_tp.patch -s /root/rpmbuild/BUILD/kernel-3.10.0-123.el7/linux-3.10.0-123.el7.x86_64 --debug
DEBUG mode enabled
Copying source to /root/.kpatch/src
Testing patch file
checking file kernel/signal.c
Building original kernel
Building patched kernel
Detecting changed objects
Rebuilding changed objects
Extracting new and modified ELF sections
signal.o: symbol info mismatch: 
/usr/local/libexec/kpatch/create-diff-object: unreconcilable difference
ERROR: kpatch build failed. Check /tmp/kpatch-build-1400832771.log for more details.

$ tail /tmp/kpatch-build-1400832771.log
  CHK     include/generated/uapi/linux/version.h
  CHK     include/generated/utsrelease.h
  CALL    /root/.kpatch/src/scripts/checksyscalls.sh
  CC      scripts/mod/devicetable-offsets.s
  GEN     scripts/mod/devicetable-offsets.h
  HOSTCC  scripts/mod/file2alias.o
  HOSTLD  scripts/mod/modpost
  CC      kernel/signal.o
signal.o: symbol info mismatch: 
/usr/local/libexec/kpatch/create-diff-object: unreconcilable difference

Looking at debug output of patched object, I could see 2 symbols with same (empty) name ""
but different type:

=== symbol list (751 entries) ===
sym 00, type 0, bind 0, ndx 00, name 
...
sym 425, type 4, bind 0, ndx 65521, name 

I tried following change, which allowed me to progress further:

diff --git a/kpatch-build/create-diff-object.c b/kpatch-build/create-diff-object.c
index 655b05d..9e2a57a 100644
--- a/kpatch-build/create-diff-object.c
+++ b/kpatch-build/create-diff-object.c
@@ -601,7 +601,7 @@ void kpatch_correlate_symbols(struct list_head *symlist1, struct list_head *syml

        list_for_each_entry(sym1, symlist1, list) {
                list_for_each_entry(sym2, symlist2, list) {
-                       if (!strcmp(sym1->name, sym2->name)) {
+                       if (!strcmp(sym1->name, sym2->name) && (sym1->type == sym2->type)) {
                                sym1->twin = sym2;
                                sym2->twin = sym1;
                                /* set initial status, might change */

Debug output:

sym 00, type 0, bind 0, ndx 00, name  (SAME)
...
sym 425, type 4, bind 0, ndx 65521, name  (SAME)
...
signal.o: changed function: do_rt_tgsigqueueinfo
signal.o: changed function: do_rt_sigqueueinfo
signal.o: changed function: get_signal_to_deliver
signal.o: signal.o: changed section .rela__jump_table not selected for inclusion
signal.o: 1 unsupported section change(s)
/root/kpatch/kpatch-build/create-diff-object: unreconcilable difference

but then I hit change in jump_table, which looks unsupported at the moment, according to commit 1622123.

@jstancek
Copy link
Contributor Author

Here is simpler reproducer, with base kernel containing kernel/test3.c with content:

#include <linux/init.h>
#include <linux/export.h>

static int dummy;

void test_function30(void)
{
    dummy = 1;
}

void test_function31(void)
{
    dummy = 2;
}

EXPORT_SYMBOL(test_function30);
EXPORT_SYMBOL(test_function31);

and kpatch patch:

diff --git a/kernel/test3.c b/kernel/test3.c
index 50d3c86..91a43a1 100644
--- a/kernel/test3.c
+++ b/kernel/test3.c
@@ -5,7 +5,9 @@ static int dummy;

 void test_function30(void)
 {
-   dummy = 1;
+   int i;
+   for (i = 0; i < 10; i++)
+       dummy += i;
 }

 void test_function31(void)
# /usr/local/libexec/kpatch/create-diff-object orig/kernel/test3.o patched/kernel/test3.o /root/vmlinux output/kernel/test3.o
=== section list (22) ===
ndx 01, type: 1, data (nil), size 0, name .text
ndx 02, type: 1, data 0x7fd4e9fff040, size 21, name .text.test_function30
ndx 03, type: 4, data 0x7fd4e9fffb88, size 48, name .rela.text.test_function30
ndx 04, type: 1, data 0x7fd4e9fff060, size 21, name .text.test_function31
ndx 05, type: 4, data 0x7fd4e9fffbb8, size 48, name .rela.text.test_function31
ndx 06, type: 1, data 0x7fd4e9fff080, size 16, name ___ksymtab+test_function31
ndx 07, type: 4, data 0x7fd4e9fffbe8, size 48, name .rela___ksymtab+test_function31
ndx 08, type: 1, data 0x7fd4e9fff090, size 32, name __ksymtab_strings
ndx 09, type: 1, data 0x7fd4e9fff0b0, size 8, name ___kcrctab+test_function31
ndx 10, type: 4, data 0x7fd4e9fffc18, size 24, name .rela___kcrctab+test_function31
ndx 11, type: 1, data 0x7fd4e9fff0c0, size 16, name ___ksymtab+test_function30
ndx 12, type: 4, data 0x7fd4e9fffc30, size 48, name .rela___ksymtab+test_function30
ndx 13, type: 1, data 0x7fd4e9fff0d0, size 8, name ___kcrctab+test_function30
ndx 14, type: 4, data 0x7fd4e9fffc60, size 24, name .rela___kcrctab+test_function30
ndx 15, type: 1, data (nil), size 0, name .data
ndx 16, type: 8, data (nil), size 0, name .bss
ndx 17, type: 8, data (nil), size 4, name .bss.dummy
ndx 18, type: 1, data 0x7fd4e9fff0d8, size 46, name .comment
ndx 19, type: 1, data (nil), size 0, name .note.GNU-stack
ndx 20, type: 3, data 0x7fd4e9fff106, size 280, name .shstrtab
ndx 21, type: 2, data 0x7fd4e9fff7e0, size 672, name .symtab
ndx 22, type: 3, data 0x7fd4e9fffa80, size 258, name .strtab

=== symbol list (28 entries) ===
sym 00, type 0, bind 0, ndx 00, name 
sym 01, type 3, bind 0, ndx 08, name __ksymtab_strings -> __ksymtab_strings
sym 02, type 3, bind 0, ndx 17, name .bss.dummy -> .bss.dummy
sym 03, type 4, bind 0, ndx 65521, name test3.c
sym 04, type 1, bind 0, ndx 17, name dummy -> .bss.dummy
sym 05, type 1, bind 0, ndx 06, name __ksymtab_test_function31 -> ___ksymtab+test_function31
sym 06, type 1, bind 0, ndx 08, name __kstrtab_test_function31 -> __ksymtab_strings
sym 07, type 1, bind 0, ndx 09, name __kcrctab_test_function31 -> ___kcrctab+test_function31
sym 08, type 1, bind 0, ndx 11, name __ksymtab_test_function30 -> ___ksymtab+test_function30
sym 09, type 1, bind 0, ndx 08, name __kstrtab_test_function30 -> __ksymtab_strings
sym 10, type 1, bind 0, ndx 13, name __kcrctab_test_function30 -> ___kcrctab+test_function30
sym 11, type 4, bind 0, ndx 65521, name 
sym 12, type 3, bind 0, ndx 01, name .text -> .text
sym 13, type 3, bind 0, ndx 02, name .text.test_function30 -> .text.test_function30
sym 14, type 3, bind 0, ndx 04, name .text.test_function31 -> .text.test_function31
sym 15, type 3, bind 0, ndx 06, name ___ksymtab+test_function31 -> ___ksymtab+test_function31
sym 16, type 3, bind 0, ndx 09, name ___kcrctab+test_function31 -> ___kcrctab+test_function31
sym 17, type 3, bind 0, ndx 11, name ___ksymtab+test_function30 -> ___ksymtab+test_function30
sym 18, type 3, bind 0, ndx 13, name ___kcrctab+test_function30 -> ___kcrctab+test_function30
sym 19, type 3, bind 0, ndx 15, name .data -> .data
sym 20, type 3, bind 0, ndx 16, name .bss -> .bss
sym 21, type 3, bind 0, ndx 18, name .comment -> .comment
sym 22, type 3, bind 0, ndx 19, name .note.GNU-stack -> .note.GNU-stack
sym 23, type 2, bind 1, ndx 04, name test_function31 -> .text.test_function31
sym 24, type 0, bind 1, ndx 65521, name __crc_test_function30
sym 25, type 0, bind 1, ndx 00, name __fentry__
sym 26, type 0, bind 1, ndx 65521, name __crc_test_function31
sym 27, type 2, bind 1, ndx 02, name test_function30 -> .text.test_function30

=== rela list for .text.test_function30 (2 entries) ===
offset 1, type 0, __fentry__ - 4
offset 8, type 2, .bss.dummy - 8

=== rela list for .text.test_function31 (2 entries) ===
offset 1, type 0, __fentry__ - 4
offset 8, type 2, .bss.dummy - 8

=== rela list for ___ksymtab+test_function31 (2 entries) ===
offset 0, type 1, test_function31 + 0
offset 8, type 1, __ksymtab_strings + 0

=== rela list for ___kcrctab+test_function31 (1 entries) ===
offset 0, type 1, __crc_test_function31 + 0

=== rela list for ___ksymtab+test_function30 (2 entries) ===
offset 0, type 1, test_function30 + 0
offset 8, type 1, __ksymtab_strings + 16

=== rela list for ___kcrctab+test_function30 (1 entries) ===
offset 0, type 1, __crc_test_function30 + 0
=== section list (22) ===
ndx 01, type: 1, data (nil), size 0, name .text
ndx 02, type: 1, data 0x7fd4e9ffd040, size 42, name .text.test_function30
ndx 03, type: 4, data 0x7fd4e9ffdb98, size 72, name .rela.text.test_function30
ndx 04, type: 1, data 0x7fd4e9ffd070, size 21, name .text.test_function31
ndx 05, type: 4, data 0x7fd4e9ffdbe0, size 48, name .rela.text.test_function31
ndx 06, type: 1, data 0x7fd4e9ffd090, size 16, name ___ksymtab+test_function31
ndx 07, type: 4, data 0x7fd4e9ffdc10, size 48, name .rela___ksymtab+test_function31
ndx 08, type: 1, data 0x7fd4e9ffd0a0, size 32, name __ksymtab_strings
ndx 09, type: 1, data 0x7fd4e9ffd0c0, size 8, name ___kcrctab+test_function31
ndx 10, type: 4, data 0x7fd4e9ffdc40, size 24, name .rela___kcrctab+test_function31
ndx 11, type: 1, data 0x7fd4e9ffd0d0, size 16, name ___ksymtab+test_function30
ndx 12, type: 4, data 0x7fd4e9ffdc58, size 48, name .rela___ksymtab+test_function30
ndx 13, type: 1, data 0x7fd4e9ffd0e0, size 8, name ___kcrctab+test_function30
ndx 14, type: 4, data 0x7fd4e9ffdc88, size 24, name .rela___kcrctab+test_function30
ndx 15, type: 1, data (nil), size 0, name .data
ndx 16, type: 8, data (nil), size 0, name .bss
ndx 17, type: 8, data (nil), size 4, name .bss.dummy
ndx 18, type: 1, data 0x7fd4e9ffd0e8, size 46, name .comment
ndx 19, type: 1, data (nil), size 0, name .note.GNU-stack
ndx 20, type: 3, data 0x7fd4e9ffd116, size 280, name .shstrtab
ndx 21, type: 2, data 0x7fd4e9ffd7f0, size 672, name .symtab
ndx 22, type: 3, data 0x7fd4e9ffda90, size 258, name .strtab

=== symbol list (28 entries) ===
sym 00, type 0, bind 0, ndx 00, name 
sym 01, type 3, bind 0, ndx 08, name __ksymtab_strings -> __ksymtab_strings
sym 02, type 3, bind 0, ndx 17, name .bss.dummy -> .bss.dummy
sym 03, type 4, bind 0, ndx 65521, name test3.c
sym 04, type 1, bind 0, ndx 17, name dummy -> .bss.dummy
sym 05, type 1, bind 0, ndx 06, name __ksymtab_test_function31 -> ___ksymtab+test_function31
sym 06, type 1, bind 0, ndx 08, name __kstrtab_test_function31 -> __ksymtab_strings
sym 07, type 1, bind 0, ndx 09, name __kcrctab_test_function31 -> ___kcrctab+test_function31
sym 08, type 1, bind 0, ndx 11, name __ksymtab_test_function30 -> ___ksymtab+test_function30
sym 09, type 1, bind 0, ndx 08, name __kstrtab_test_function30 -> __ksymtab_strings
sym 10, type 1, bind 0, ndx 13, name __kcrctab_test_function30 -> ___kcrctab+test_function30
sym 11, type 4, bind 0, ndx 65521, name 
sym 12, type 3, bind 0, ndx 01, name .text -> .text
sym 13, type 3, bind 0, ndx 02, name .text.test_function30 -> .text.test_function30
sym 14, type 3, bind 0, ndx 04, name .text.test_function31 -> .text.test_function31
sym 15, type 3, bind 0, ndx 06, name ___ksymtab+test_function31 -> ___ksymtab+test_function31
sym 16, type 3, bind 0, ndx 09, name ___kcrctab+test_function31 -> ___kcrctab+test_function31
sym 17, type 3, bind 0, ndx 11, name ___ksymtab+test_function30 -> ___ksymtab+test_function30
sym 18, type 3, bind 0, ndx 13, name ___kcrctab+test_function30 -> ___kcrctab+test_function30
sym 19, type 3, bind 0, ndx 15, name .data -> .data
sym 20, type 3, bind 0, ndx 16, name .bss -> .bss
sym 21, type 3, bind 0, ndx 18, name .comment -> .comment
sym 22, type 3, bind 0, ndx 19, name .note.GNU-stack -> .note.GNU-stack
sym 23, type 2, bind 1, ndx 04, name test_function31 -> .text.test_function31
sym 24, type 0, bind 1, ndx 65521, name __crc_test_function30
sym 25, type 0, bind 1, ndx 00, name __fentry__
sym 26, type 0, bind 1, ndx 65521, name __crc_test_function31
sym 27, type 2, bind 1, ndx 02, name test_function30 -> .text.test_function30

=== rela list for .text.test_function30 (3 entries) ===
offset 1, type 0, __fentry__ - 4
offset 7, type 2, .bss.dummy - 4
offset 36, type 2, .bss.dummy - 4

=== rela list for .text.test_function31 (2 entries) ===
offset 1, type 0, __fentry__ - 4
offset 8, type 2, .bss.dummy - 8

=== rela list for ___ksymtab+test_function31 (2 entries) ===
offset 0, type 1, test_function31 + 0
offset 8, type 1, __ksymtab_strings + 0

=== rela list for ___kcrctab+test_function31 (1 entries) ===
offset 0, type 1, __crc_test_function31 + 0

=== rela list for ___ksymtab+test_function30 (2 entries) ===
offset 0, type 1, test_function30 + 0
offset 8, type 1, __ksymtab_strings + 16

=== rela list for ___kcrctab+test_function30 (1 entries) ===
offset 0, type 1, __crc_test_function30 + 0
section .text.test_function30 has changed
section .rela.text.test_function30 has changed
section .symtab has changed
test3.o: symbol info mismatch: 
/usr/local/libexec/kpatch/create-diff-object: unreconcilable difference

@sjenning
Copy link
Contributor

I can't recreate the "symbol info mismatch" issue with the latest master 6aee215. I do get the:

signal.o: signal.o: changed section .rela__jump_table not selected for inclusion
signal.o: 1 unsupported section change(s)

which is being track in issue #157. Can you confirm?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants