kpatch/kpatch-build
Kamalesh Babulal 7b4efd1509 create-diff-object: ppc64le - Fix wrong addend value for switch labels
Commit f0518ef58a ("create-diff-object: fix ppc64le
kpatch_replace_sections_syms() bundling assumption"), subtracted
sym.st_value for all bundled symbols on ppc64le and GCC6+ irrespective
of function or switch label.

As a side effect the addend for switch labels were incorrect and call
to local function executed TOC setup code. Fallback to the original
behaviour of subtracting sym.st_value only for the dynrela.

Example of wrong switch label:
------------------------------
0000000000000008 <register_netdevice>:
...
 31c:   05 00 85 2b     cmplwi  cr7,r5,5
 320:   7c 02 9d 41     bgt     cr7,59c <register_netdevice+0x594>
 324:   00 00 e2 3c     addis   r7,r2,0
                        324: R_PPC64_TOC16_HA   .toc+0x580
 328:   64 17 a5 78     rldicr  r5,r5,2,61
 32c:   00 00 47 e9     ld      r10,0(r7)
                        32c: R_PPC64_TOC16_LO_DS        .toc+0x580
 330:   aa 2a 2a 7d     lwax    r9,r10,r5
 334:   14 52 29 7d     add     r9,r9,r10
 338:   a6 03 29 7d     mtctr   r9
 33c:   20 04 80 4e     bctr
 340:   44 02 00 00     .long 0x244
 344:   f0 01 00 00     .long 0x1f0
 348:   20 02 00 00     .long 0x220
 34c:   38 02 00 00     .long 0x238
 350:   2c 02 00 00     .long 0x22c
 354:   50 02 00 00     .long 0x250
 358:   00 00 00 60     nop

Before Patch (.toc section):
Offset Info             Type           Symbol's Value  Symbol's Name + Addend
...
0x580  0000008200000026 R_PPC64_ADDR64 0000000000000008 register_netdevice + 338

After Patch (.toc section):
Offset Info             Type           Symbol's Value  Symbol's Name + Addend
...
0x580  0000008200000026 R_PPC64_ADDR64 0000000000000008 register_netdevice + 340

Example of localentry addend removed:
------------------------------------
Before Patch (.toc section):
Offset Info             Type           Symbol's Value  Symbol's Name + Addend
...
0x48   0000002c00000026 R_PPC64_ADDR64 0000000000000008 cmdline_proc_show + 0

After Patch (.toc section):
Offset Info             Type           Symbol's Value   Symbol's Name + Addend
...
0x48   0000002c00000026 R_PPC64_ADDR64 0000000000000008 cmdline_proc_show + 8

Fixes: f0518ef58a ("create-diff-object: fix ppc64le kpatch_replace_sections_syms() bundling assumption")
Cc: Josh Poimboeuf <jpoimboe@redhat.com>
Signed-off-by: Kamalesh Babulal <kamalesh@linux.vnet.ibm.com>
2018-03-06 20:40:16 +05:30
..
gcc-plugins gcc-plugin: create a ppc64le GCC plugin which inserts nops after local calls 2017-11-10 09:17:00 -06:00
insn insn: get it to compile in create-diff-object 2014-05-30 15:19:57 -05:00
create-diff-object.c create-diff-object: ppc64le - Fix wrong addend value for switch labels 2018-03-06 20:40:16 +05:30
create-klp-module.c create-diff-object: don't convert relocation destinations to symbols 2017-11-09 19:16:14 -06:00
create-kpatch-module.c create-kpatch-module: support unbundled symbols 2017-09-20 23:57:24 -05:00
kpatch-build Merge pull request #757 from jpoimboe/TODO-ppc-fix 2017-12-20 23:02:48 -06:00
kpatch-elf.c kpatch-build: clear Elf_Data d_buf buffer on allocation 2017-10-03 16:42:28 -04:00
kpatch-elf.h kpatch-build: Support gcc-6 function prologue 2017-07-27 12:56:00 +05:30
kpatch-gcc kpatch-build: Add additional debug modes 2017-11-17 15:04:11 +01:00
kpatch-intermediate.h create-klp-module: get rid of redundant kpatch_relocation.offset field 2017-11-09 19:16:14 -06:00
list.h new .fixup group size algorithm 2014-09-15 14:54:57 -05:00
log.h log: include error.h 2017-01-23 12:42:35 -08:00
lookup.c lookup: allow local symbols to be in any order 2017-07-06 12:44:50 -05:00
lookup.h support dup file+symbol 2017-02-04 09:37:18 +08:00
Makefile gcc-plugin: create a ppc64le GCC plugin which inserts nops after local calls 2017-11-10 09:17:00 -06:00