FROMLIST: BACKPORT: kbuild: fix dynamic ftrace with clang LTO
With CONFIG_LTO_CLANG enabled, LLVM IR won't be compiled into object files until modpost_link. This change postpones calls to recordmcount until after this step. In order to exclude ftrace_process_locs from inspection, we add a new code section .text..ftrace, which we tell recordmcount to ignore, and a __norecordmcount attribute for moving functions to this section. Bug: 62093296 Bug: 67506682 Change-Id: Iba2c053968206acf533fadab1eb34a743b5088ee (am from https://patchwork.kernel.org/patch/10060327/) Signed-off-by: Sami Tolvanen <samitolvanen@google.com>
This commit is contained in:
parent
475bdd7d35
commit
7bd125e57b
9 changed files with 52 additions and 7 deletions
|
@ -113,6 +113,19 @@ modpost_link()
|
|||
${LD} ${LDFLAGS} -r -o ${1} $(modversions) ${objects}
|
||||
}
|
||||
|
||||
# If CONFIG_LTO_CLANG is selected, we postpone running recordmcount until
|
||||
# we have compiled LLVM IR to an object file.
|
||||
recordmcount()
|
||||
{
|
||||
if [ -z "${CONFIG_LTO_CLANG}" ]; then
|
||||
return
|
||||
fi
|
||||
|
||||
if [ -n "${CONFIG_FTRACE_MCOUNT_RECORD}" ]; then
|
||||
scripts/recordmcount ${RECORDMCOUNT_FLAGS} $*
|
||||
fi
|
||||
}
|
||||
|
||||
# Link of vmlinux
|
||||
# ${1} - optional extra .o files
|
||||
# ${2} - output file
|
||||
|
@ -282,6 +295,9 @@ if [ -n "${CONFIG_LTO_CLANG}" ]; then
|
|||
# vmlinux_link
|
||||
KBUILD_VMLINUX_INIT=
|
||||
KBUILD_VMLINUX_MAIN=vmlinux.o
|
||||
|
||||
# Call recordmcount if needed
|
||||
recordmcount vmlinux.o
|
||||
fi
|
||||
|
||||
kallsymso=""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue