Re: [PATCH 2/2] scripts: ftrace - move the nop-processing in ftrace_init to compile time

From: kernel test robot
Date: Sat Sep 11 2021 - 14:10:05 EST


Hi Yinan,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on tip/perf/core]
[also build test ERROR on kbuild/for-next trace/for-next linus/master v5.14 next-20210910]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url: https://github.com/0day-ci/linux/commits/Yinan-Liu/ftrace-improve-ftrace-during-compiling/20210911-215230
base: https://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git 4034fb207e302cc0b1f304084d379640c1fb1436
config: powerpc-randconfig-r023-20210911 (attached as .config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project 261cbe98c38f8c1ee1a482fe76511110e790f58a)
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# install powerpc cross compiling tool for clang build
# apt-get install binutils-powerpc-linux-gnu
# https://github.com/0day-ci/linux/commit/54d68f2f4f2f10bb9939f8f532615295bf52ce96
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Yinan-Liu/ftrace-improve-ftrace-during-compiling/20210911-215230
git checkout 54d68f2f4f2f10bb9939f8f532615295bf52ce96
# save the attached .config to linux build tree
mkdir build_dir
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross O=build_dir ARCH=powerpc olddefconfig

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@xxxxxxxxx>

All errors (new ones prefixed by >>):

In file included from scripts/sorttable.c:191:
scripts/sorttable.h:372:6: warning: variable 'mcount_sort_thread' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
if (!mstruct.init_data_sec || !_start_mcount_loc || !_stop_mcount_loc) {
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
scripts/sorttable.h:469:6: note: uninitialized use occurs here
if (mcount_sort_thread) {
^~~~~~~~~~~~~~~~~~
scripts/sorttable.h:372:2: note: remove the 'if' if its condition is always false
if (!mstruct.init_data_sec || !_start_mcount_loc || !_stop_mcount_loc) {
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
scripts/sorttable.h:372:6: warning: variable 'mcount_sort_thread' is used uninitialized whenever '||' condition is true [-Wsometimes-uninitialized]
if (!mstruct.init_data_sec || !_start_mcount_loc || !_stop_mcount_loc) {
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
scripts/sorttable.h:469:6: note: uninitialized use occurs here
if (mcount_sort_thread) {
^~~~~~~~~~~~~~~~~~
scripts/sorttable.h:372:6: note: remove the '||' if its condition is always false
if (!mstruct.init_data_sec || !_start_mcount_loc || !_stop_mcount_loc) {
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
scripts/sorttable.h:372:6: warning: variable 'mcount_sort_thread' is used uninitialized whenever '||' condition is true [-Wsometimes-uninitialized]
if (!mstruct.init_data_sec || !_start_mcount_loc || !_stop_mcount_loc) {
^~~~~~~~~~~~~~~~~~~~~~
scripts/sorttable.h:469:6: note: uninitialized use occurs here
if (mcount_sort_thread) {
^~~~~~~~~~~~~~~~~~
scripts/sorttable.h:372:6: note: remove the '||' if its condition is always false
if (!mstruct.init_data_sec || !_start_mcount_loc || !_stop_mcount_loc) {
^~~~~~~~~~~~~~~~~~~~~~~~~
scripts/sorttable.h:286:30: note: initialize the variable 'mcount_sort_thread' to silence this warning
pthread_t mcount_sort_thread;
^
= 0
In file included from scripts/recordmcount.c:423:
>> scripts/recordmcount.h:450:49: error: too many arguments to function call, expected 2, have 3
ulseek(fd_map, (void *)relp - (void *)ehdr, SEEK_SET);
~~~~~~ ^~~~~~~~
/usr/include/stdio.h:109:18: note: expanded from macro 'SEEK_SET'
#define SEEK_SET 0 /* Seek from beginning of file. */
^
scripts/recordmcount.c:81:14: note: 'ulseek' declared here
static off_t ulseek(off_t const offset, int const whence)
^
In file included from scripts/sorttable.c:193:
scripts/sorttable.h:372:6: warning: variable 'mcount_sort_thread' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
if (!mstruct.init_data_sec || !_start_mcount_loc || !_stop_mcount_loc) {
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
scripts/sorttable.h:469:6: note: uninitialized use occurs here
if (mcount_sort_thread) {
^~~~~~~~~~~~~~~~~~
scripts/sorttable.h:372:2: note: remove the 'if' if its condition is always false
if (!mstruct.init_data_sec || !_start_mcount_loc || !_stop_mcount_loc) {
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
scripts/sorttable.h:372:6: warning: variable 'mcount_sort_thread' is used uninitialized whenever '||' condition is true [-Wsometimes-uninitialized]
if (!mstruct.init_data_sec || !_start_mcount_loc || !_stop_mcount_loc) {
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
scripts/sorttable.h:469:6: note: uninitialized use occurs here
if (mcount_sort_thread) {
^~~~~~~~~~~~~~~~~~
scripts/sorttable.h:372:6: note: remove the '||' if its condition is always false
if (!mstruct.init_data_sec || !_start_mcount_loc || !_stop_mcount_loc) {
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
scripts/sorttable.h:372:6: warning: variable 'mcount_sort_thread' is used uninitialized whenever '||' condition is true [-Wsometimes-uninitialized]
if (!mstruct.init_data_sec || !_start_mcount_loc || !_stop_mcount_loc) {
^~~~~~~~~~~~~~~~~~~~~~
scripts/sorttable.h:469:6: note: uninitialized use occurs here
if (mcount_sort_thread) {
^~~~~~~~~~~~~~~~~~
scripts/sorttable.h:372:6: note: remove the '||' if its condition is always false
if (!mstruct.init_data_sec || !_start_mcount_loc || !_stop_mcount_loc) {
^~~~~~~~~~~~~~~~~~~~~~~~~
scripts/sorttable.h:286:30: note: initialize the variable 'mcount_sort_thread' to silence this warning
pthread_t mcount_sort_thread;
^
= 0
In file included from scripts/recordmcount.c:423:
scripts/recordmcount.h:451:26: error: too many arguments to function call, expected 2, have 3
uwrite(fd_map, &rel, sizeof(rel));
~~~~~~ ^~~~~~~~~~~
scripts/recordmcount.c:101:16: note: 'uwrite' declared here
static ssize_t uwrite(void const *const buf, size_t const count)
^
In file included from scripts/recordmcount.c:425:
>> scripts/recordmcount.h:450:49: error: too many arguments to function call, expected 2, have 3
ulseek(fd_map, (void *)relp - (void *)ehdr, SEEK_SET);
~~~~~~ ^~~~~~~~
/usr/include/stdio.h:109:18: note: expanded from macro 'SEEK_SET'
#define SEEK_SET 0 /* Seek from beginning of file. */
^
scripts/recordmcount.c:81:14: note: 'ulseek' declared here
static off_t ulseek(off_t const offset, int const whence)
^
In file included from scripts/recordmcount.c:425:
scripts/recordmcount.h:451:26: error: too many arguments to function call, expected 2, have 3
uwrite(fd_map, &rel, sizeof(rel));
~~~~~~ ^~~~~~~~~~~
scripts/recordmcount.c:101:16: note: 'uwrite' declared here
static ssize_t uwrite(void const *const buf, size_t const count)
^
4 errors generated.
make[2]: *** [scripts/Makefile.host:95: scripts/recordmcount] Error 1
6 warnings generated.
/usr/bin/ld: /tmp/sorttable-29bd51.o: in function `main':
sorttable.c:(.text+0x716): undefined reference to `pthread_create'
/usr/bin/ld: sorttable.c:(.text+0xb2c): undefined reference to `pthread_create'
/usr/bin/ld: sorttable.c:(.text+0xe90): undefined reference to `pthread_join'
clang-14: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [scripts/Makefile.host:95: scripts/sorttable] Error 1
make[2]: Target '__build' not remade because of errors.
make[1]: *** [Makefile:1196: scripts] Error 2
make[1]: Target 'modules_prepare' not remade because of errors.
make: *** [Makefile:220: __sub-make] Error 2
make: Target 'modules_prepare' not remade because of errors.
--
scripts/genksyms/parse.y: warning: 9 shift/reduce conflicts [-Wconflicts-sr]
scripts/genksyms/parse.y: warning: 5 reduce/reduce conflicts [-Wconflicts-rr]
In file included from scripts/sorttable.c:191:
scripts/sorttable.h:372:6: warning: variable 'mcount_sort_thread' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
if (!mstruct.init_data_sec || !_start_mcount_loc || !_stop_mcount_loc) {
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
scripts/sorttable.h:469:6: note: uninitialized use occurs here
if (mcount_sort_thread) {
^~~~~~~~~~~~~~~~~~
scripts/sorttable.h:372:2: note: remove the 'if' if its condition is always false
if (!mstruct.init_data_sec || !_start_mcount_loc || !_stop_mcount_loc) {
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
scripts/sorttable.h:372:6: warning: variable 'mcount_sort_thread' is used uninitialized whenever '||' condition is true [-Wsometimes-uninitialized]
if (!mstruct.init_data_sec || !_start_mcount_loc || !_stop_mcount_loc) {
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
scripts/sorttable.h:469:6: note: uninitialized use occurs here
if (mcount_sort_thread) {
^~~~~~~~~~~~~~~~~~
scripts/sorttable.h:372:6: note: remove the '||' if its condition is always false
if (!mstruct.init_data_sec || !_start_mcount_loc || !_stop_mcount_loc) {
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
scripts/sorttable.h:372:6: warning: variable 'mcount_sort_thread' is used uninitialized whenever '||' condition is true [-Wsometimes-uninitialized]
if (!mstruct.init_data_sec || !_start_mcount_loc || !_stop_mcount_loc) {
^~~~~~~~~~~~~~~~~~~~~~
scripts/sorttable.h:469:6: note: uninitialized use occurs here
if (mcount_sort_thread) {
^~~~~~~~~~~~~~~~~~
scripts/sorttable.h:372:6: note: remove the '||' if its condition is always false
In file included from scripts/recordmcount.c:423:
>> scripts/recordmcount.h:450:49: error: too many arguments to function call, expected 2, have 3
ulseek(fd_map, (void *)relp - (void *)ehdr, SEEK_SET);
~~~~~~ ^~~~~~~~
/usr/include/stdio.h:109:18: note: expanded from macro 'SEEK_SET'
#define SEEK_SET 0 /* Seek from beginning of file. */
^
scripts/recordmcount.c:81:14: note: 'ulseek' declared here
static off_t ulseek(off_t const offset, int const whence)
^
In file included from scripts/recordmcount.c:423:
scripts/recordmcount.h:451:26: error: too many arguments to function call, expected 2, have 3
uwrite(fd_map, &rel, sizeof(rel));
~~~~~~ ^~~~~~~~~~~
scripts/recordmcount.c:101:16: note: 'uwrite' declared here
static ssize_t uwrite(void const *const buf, size_t const count)
^
if (!mstruct.init_data_sec || !_start_mcount_loc || !_stop_mcount_loc) {
^~~~~~~~~~~~~~~~~~~~~~~~~
scripts/sorttable.h:286:30: note: initialize the variable 'mcount_sort_thread' to silence this warning
pthread_t mcount_sort_thread;
^
= 0
In file included from scripts/sorttable.c:193:
scripts/sorttable.h:372:6: warning: variable 'mcount_sort_thread' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
if (!mstruct.init_data_sec || !_start_mcount_loc || !_stop_mcount_loc) {
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
scripts/sorttable.h:469:6: note: uninitialized use occurs here
if (mcount_sort_thread) {
^~~~~~~~~~~~~~~~~~
scripts/sorttable.h:372:2: note: remove the 'if' if its condition is always false
if (!mstruct.init_data_sec || !_start_mcount_loc || !_stop_mcount_loc) {
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
scripts/sorttable.h:372:6: warning: variable 'mcount_sort_thread' is used uninitialized whenever '||' condition is true [-Wsometimes-uninitialized]
if (!mstruct.init_data_sec || !_start_mcount_loc || !_stop_mcount_loc) {
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
scripts/sorttable.h:469:6: note: uninitialized use occurs here
if (mcount_sort_thread) {
^~~~~~~~~~~~~~~~~~
scripts/sorttable.h:372:6: note: remove the '||' if its condition is always false
if (!mstruct.init_data_sec || !_start_mcount_loc || !_stop_mcount_loc) {
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
scripts/sorttable.h:372:6: warning: variable 'mcount_sort_thread' is used uninitialized whenever '||' condition is true [-Wsometimes-uninitialized]
if (!mstruct.init_data_sec || !_start_mcount_loc || !_stop_mcount_loc) {
^~~~~~~~~~~~~~~~~~~~~~
scripts/sorttable.h:469:6: note: uninitialized use occurs here
if (mcount_sort_thread) {
^~~~~~~~~~~~~~~~~~
scripts/sorttable.h:372:6: note: remove the '||' if its condition is always false
if (!mstruct.init_data_sec || !_start_mcount_loc || !_stop_mcount_loc) {
^~~~~~~~~~~~~~~~~~~~~~~~~
scripts/sorttable.h:286:30: note: initialize the variable 'mcount_sort_thread' to silence this warning
pthread_t mcount_sort_thread;
^
= 0
In file included from scripts/recordmcount.c:425:
>> scripts/recordmcount.h:450:49: error: too many arguments to function call, expected 2, have 3
ulseek(fd_map, (void *)relp - (void *)ehdr, SEEK_SET);
~~~~~~ ^~~~~~~~
/usr/include/stdio.h:109:18: note: expanded from macro 'SEEK_SET'
#define SEEK_SET 0 /* Seek from beginning of file. */
^
scripts/recordmcount.c:81:14: note: 'ulseek' declared here
static off_t ulseek(off_t const offset, int const whence)
^
In file included from scripts/recordmcount.c:425:
scripts/recordmcount.h:451:26: error: too many arguments to function call, expected 2, have 3
uwrite(fd_map, &rel, sizeof(rel));
~~~~~~ ^~~~~~~~~~~
scripts/recordmcount.c:101:16: note: 'uwrite' declared here
static ssize_t uwrite(void const *const buf, size_t const count)
^
4 errors generated.
make[2]: *** [scripts/Makefile.host:95: scripts/recordmcount] Error 1
6 warnings generated.
/usr/bin/ld: /tmp/sorttable-df0121.o: in function `main':
sorttable.c:(.text+0x716): undefined reference to `pthread_create'
/usr/bin/ld: sorttable.c:(.text+0xb2c): undefined reference to `pthread_create'
/usr/bin/ld: sorttable.c:(.text+0xe90): undefined reference to `pthread_join'
clang-14: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [scripts/Makefile.host:95: scripts/sorttable] Error 1
make[2]: Target '__build' not remade because of errors.
make[1]: *** [Makefile:1196: scripts] Error 2
make[1]: Target 'prepare' not remade because of errors.
make: *** [Makefile:220: __sub-make] Error 2
make: Target 'prepare' not remade because of errors.


vim +450 scripts/recordmcount.h

394
395 /*
396 * Look at the relocations in order to find the calls to mcount.
397 * Accumulate the section offsets that are found, and their relocation info,
398 * onto the end of the existing arrays.
399 */
400 static uint_t *sift_rel_mcount(uint_t *mlocp,
401 unsigned const offbase,
402 Elf_Rel **const mrelpp,
403 Elf_Shdr const *const relhdr,
404 Elf_Ehdr const *const ehdr,
405 unsigned const recsym,
406 uint_t const recval,
407 unsigned const reltype)
408 {
409 Elf_Shdr *const shdr0 = (Elf_Shdr *)(_w(ehdr->e_shoff) + (void *)ehdr);
410 Elf_Shdr const *const shdr = &shdr0[w(relhdr->sh_info)];
411 uint_t *const mloc0 = mlocp;
412 Elf_Rel *mrelp = *mrelpp;
413 Elf_Sym const *sym0;
414 char const *str0;
415 Elf_Rel const *relp;
416 unsigned rel_entsize = _w(relhdr->sh_entsize);
417 unsigned const nrel = _w(relhdr->sh_size) / rel_entsize;
418 unsigned mcountsym = 0;
419 unsigned t;
420
421 get_sym_str_and_relp(relhdr, ehdr, &sym0, &str0, &relp);
422
423 for (t = nrel; t; --t) {
424 int ret = -1;
425 if (!mcountsym)
426 mcountsym = get_mcountsym(sym0, relp, str0);
427
428 if (mcountsym && mcountsym == Elf_r_sym(relp) &&
429 !is_fake_mcount(relp)) {
430 uint_t const addend =
431 _w(_w(relp->r_offset) - recval + mcount_adjust);
432 mrelp->r_offset = _w(offbase
433 + ((void *)mlocp - (void *)mloc0));
434 Elf_r_info(mrelp, recsym, reltype);
435 if (rel_entsize == sizeof(Elf_Rela)) {
436 ((Elf_Rela *)mrelp)->r_addend = addend;
437 *mlocp++ = 0;
438 } else
439 *mlocp++ = addend;
440
441 mrelp = (Elf_Rel *)(rel_entsize + (void *)mrelp);
442 /* convert mcount into nop */
443 if (make_nop)
444 ret = make_nop((void *)ehdr,
445 _w(shdr->sh_offset) + _w(relp->r_offset));
446 if (!ret) {
447 Elf_Rel rel;
448 rel = *(Elf_Rel *)relp;
449 Elf_r_info(&rel, Elf_r_sym(relp), rel_type_nop);
> 450 ulseek(fd_map, (void *)relp - (void *)ehdr, SEEK_SET);
451 uwrite(fd_map, &rel, sizeof(rel));
452 }
453 }
454 relp = (Elf_Rel const *)(rel_entsize + (void *)relp);
455 }
456 *mrelpp = mrelp;
457 return mlocp;
458 }
459

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@xxxxxxxxxxxx

Attachment: .config.gz
Description: application/gzip