OSDN Git Service

powerpc64/module: Tighten detection of mcount call sites with -mprofile-kernel
authorNaveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
Thu, 19 Apr 2018 07:04:07 +0000 (12:34 +0530)
committerMichael Ellerman <mpe@ellerman.id.au>
Thu, 3 May 2018 12:32:28 +0000 (22:32 +1000)
commit250122baed29d90c643be8809d75274336b98fb0
treee0a7d2db2f5a404013780461f72414788ee5f49d
parent88b1a8547f4c00e55d54e081fc15e3980debf5c1
powerpc64/module: Tighten detection of mcount call sites with -mprofile-kernel

For R_PPC64_REL24 relocations, we suppress emitting instructions for TOC
load/restore in the relocation stub if the relocation is for _mcount()
call when using -mprofile-kernel ABI.

To detect this, we check if the preceding instructions are per the
standard set of instructions emitted by gcc: either the two instruction
sequence of 'mflr r0; std r0,16(r1)', or the more optimized variant of a
single 'mflr r0'. This is not sufficient since nothing prevents users
from hand coding sequences involving a 'mflr r0' followed by a 'bl'.

For removing the toc save instruction from the stub, we additionally
check if the symbol is "_mcount". Add the same check here as well.

Also rename is_early_mcount_callsite() to is_mprofile_mcount_callsite()
since that is what is being checked. The use of "early" is misleading
since there is nothing involving this function that qualifies as early.

Fixes: 153086644fd1f ("powerpc/ftrace: Add support for -mprofile-kernel ftrace ABI")
Signed-off-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
arch/powerpc/kernel/module_64.c