ftrace: Have recordmcount use w8 to read relp->r_info in arm64_is_fake_mcount
authorChen Jun <chenjun102@huawei.com>
Mon, 22 Feb 2021 13:58:40 +0000 (13:58 +0000)
committerSteven Rostedt (VMware) <rostedt@goodmis.org>
Tue, 2 Mar 2021 22:27:18 +0000 (17:27 -0500)
commit999340d51174ce4141dd723105d4cef872b13ee9
treece1bec2d1cefe4c2969d7fb23ce71de5e076d3d5
parentfe07bfda2fb9cdef8a4d4008a409bb02f35f1bd8
ftrace: Have recordmcount use w8 to read relp->r_info in arm64_is_fake_mcount

On little endian system, Use aarch64_be(gcc v7.3) downloaded from
linaro.org to build image with CONFIG_CPU_BIG_ENDIAN = y,
CONFIG_FTRACE = y, CONFIG_DYNAMIC_FTRACE = y.

gcc will create symbols of _mcount but recordmcount can not create
mcount_loc for *.o.
aarch64_be-linux-gnu-objdump -r fs/namei.o | grep mcount
00000000000000d0 R_AARCH64_CALL26  _mcount
...
0000000000007190 R_AARCH64_CALL26  _mcount

The reason is than funciton arm64_is_fake_mcount can not work correctly.
A symbol of _mcount in *.o compiled with big endian compiler likes:
00 00 00 2d 00 00 01 1b
w(rp->r_info) will return 0x2d instead of 0x011b. Because w() takes
uint32_t as parameter, which truncates rp->r_info.

Use w8() instead w() to read relp->r_info

Link: https://lkml.kernel.org/r/20210222135840.56250-1-chenjun102@huawei.com
Fixes: ea0eada45632 ("recordmcount: only record relocation of type R_AARCH64_CALL26 on arm64.")
Acked-by: Will Deacon <will@kernel.org>
Signed-off-by: Chen Jun <chenjun102@huawei.com>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
scripts/recordmcount.c