kpatch/kpatch-build
Vasily Gorbik c6d0b5450b lookup: fix symtab parsing
symtab_read tries to skip '.dynsym' symbol table and only
read '.symtab' symbol table. Newer readelf from binutils 2.37
now adds section names (see the diff):

--- vmlinux.symtab      2022-02-18 02:10:06.691220932 +0100
+++ vmlinux.symtab.new  2022-02-18 01:16:06.161210458 +0100
Symbol table '.dynsym' contains 1541 entries:
   Num:    Value          Size Type    Bind   Vis      Ndx Name
     0: 0000000000000000     0 NOTYPE  LOCAL  DEFAULT  UND
     1: 0000000000100000     0 SECTION LOCAL  DEFAULT    1 .text
     2: 00000000017a3ac0     4 OBJECT  GLOBAL DEFAULT   19 sclp_console_pages
Symbol table '.symtab' contains 159980 entries:
   Num:    Value          Size Type    Bind   Vis      Ndx Name
-    41: 0000000001a93600     0 SECTION LOCAL  DEFAULT   41
-    42: 0000000001a9c678     0 SECTION LOCAL  DEFAULT   42
...
+    41: 0000000001a93600     0 SECTION LOCAL  DEFAULT   41 .dynsym
+    42: 0000000001a9c678     0 SECTION LOCAL  DEFAULT   42 .rela.dyn
...
     54: 0000000000000000     0 FILE    LOCAL  DEFAULT  ABS main.c

Simple matching of ".dynsym" in the line buffer is not enough anymore,
because it hits not just

Symbol table '.dynsym' contains 1541 entries:

line, but also

    41: 0000000001a93600     0 SECTION LOCAL  DEFAULT   41 .dynsym

skipping the rest of the file and leading to an error:

create-diff-object: ERROR: *.o: find_local_syms: 189: couldn't find matching
*.c local symbols in vmlinux symbol table

Limit matching only to lines containing "Symbol table" header.
This works with readelf from the binutils, as well as readelf from
elfutils (its output looks slightly different).

Symbol table [41] '.dynsym' contains 1541 entries:

Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
2022-05-20 15:50:29 +02:00
..
gcc-plugins gcc-plugin: GCC 10 - update local/non local insn names 2020-06-12 13:27:06 +05:30
insn
create-diff-object.c create-diff-object: fix endianness in kpatch_no_sibling_calls_ppc64le() 2022-05-17 19:28:56 -07:00
create-klp-module.c create-diff-object: rename "sec" -> "relasec" for rela sections 2022-05-11 17:00:25 -07:00
create-kpatch-module.c kpatch-elf: pass new ELF output file mode to kpatch_write_output_elf() 2020-09-25 09:30:13 -04:00
kpatch-build Merge pull request #1269 from jpoimboe/reloc-addend 2022-05-19 18:25:52 -05:00
kpatch-cc kpatch-build: clang support 2021-02-17 12:59:51 +01:00
kpatch-elf.c create-diff-object: fix string extraction 2022-05-17 19:28:55 -07:00
kpatch-elf.h create-diff-object: move addend math to a new function 2022-05-11 17:02:04 -07:00
kpatch-intermediate.h lookup: rename 'pos' to 'sympos' 2020-04-06 15:18:58 -05:00
kpatch.h kpatch-build: add exit status enum 2018-06-15 07:11:48 -04:00
list.h new .fixup group size algorithm 2014-09-15 14:54:57 -05:00
log.h kpatch-build: add exit status enum 2018-06-15 07:11:48 -04:00
lookup.c lookup: fix symtab parsing 2022-05-20 15:50:29 +02:00
lookup.h Switch to per-file lookup table pointers. 2021-08-17 09:37:44 +02:00
Makefile create-diff-object: move addend math to a new function 2022-05-11 17:02:04 -07:00