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 - 13:16:34 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: sparc-allyesconfig (attached as .config)
compiler: sparc64-linux-gcc (GCC) 11.2.0
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
# 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=gcc-11.2.0 make.cross O=build_dir ARCH=sparc olddefconfig

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

All error/warnings (new ones prefixed by >>):

In file included from scripts/recordmcount.c:423:
scripts/recordmcount.h: In function 'sift32_rel_mcount':
>> scripts/recordmcount.h:450:5: error: too many arguments to function 'ulseek'
450 | ulseek(fd_map, (void *)relp - (void *)ehdr, SEEK_SET);
| ^~~~~~
scripts/recordmcount.c:81:14: note: declared here
81 | static off_t ulseek(off_t const offset, int const whence)
| ^~~~~~
In file included from scripts/recordmcount.c:423:
>> scripts/recordmcount.h:451:12: warning: passing argument 1 of 'uwrite' makes pointer from integer without a cast [-Wint-conversion]
451 | uwrite(fd_map, &rel, sizeof(rel));
| ^~~~~~
| |
| int
scripts/recordmcount.c:101:41: note: expected 'const void * const' but argument is of type 'int'
101 | static ssize_t uwrite(void const *const buf, size_t const count)
| ~~~~~~~~~~~~~~~~~~^~~
In file included from scripts/recordmcount.c:423:
>> scripts/recordmcount.h:451:20: warning: passing argument 2 of 'uwrite' makes integer from pointer without a cast [-Wint-conversion]
451 | uwrite(fd_map, &rel, sizeof(rel));
| ^~~~
| |
| Elf32_Rel *
scripts/recordmcount.c:101:59: note: expected 'size_t' {aka 'const long unsigned int'} but argument is of type 'Elf32_Rel *'
101 | static ssize_t uwrite(void const *const buf, size_t const count)
| ~~~~~~~~~~~~~^~~~~
In file included from scripts/recordmcount.c:423:
>> scripts/recordmcount.h:451:5: error: too many arguments to function 'uwrite'
451 | uwrite(fd_map, &rel, sizeof(rel));
| ^~~~~~
scripts/recordmcount.c:101:16: note: declared here
101 | static ssize_t uwrite(void const *const buf, size_t const count)
| ^~~~~~
In file included from scripts/recordmcount.c:425:
scripts/recordmcount.h: In function 'sift64_rel_mcount':
>> scripts/recordmcount.h:450:5: error: too many arguments to function 'ulseek'
450 | ulseek(fd_map, (void *)relp - (void *)ehdr, SEEK_SET);
| ^~~~~~
scripts/recordmcount.c:81:14: note: declared here
81 | static off_t ulseek(off_t const offset, int const whence)
| ^~~~~~
In file included from scripts/recordmcount.c:425:
>> scripts/recordmcount.h:451:12: warning: passing argument 1 of 'uwrite' makes pointer from integer without a cast [-Wint-conversion]
451 | uwrite(fd_map, &rel, sizeof(rel));
| ^~~~~~
| |
| int
scripts/recordmcount.c:101:41: note: expected 'const void * const' but argument is of type 'int'
101 | static ssize_t uwrite(void const *const buf, size_t const count)
| ~~~~~~~~~~~~~~~~~~^~~
In file included from scripts/recordmcount.c:425:
>> scripts/recordmcount.h:451:20: warning: passing argument 2 of 'uwrite' makes integer from pointer without a cast [-Wint-conversion]
451 | uwrite(fd_map, &rel, sizeof(rel));
| ^~~~
| |
| Elf64_Rel *
scripts/recordmcount.c:101:59: note: expected 'size_t' {aka 'const long unsigned int'} but argument is of type 'Elf64_Rel *'
101 | static ssize_t uwrite(void const *const buf, size_t const count)
| ~~~~~~~~~~~~~^~~~~
In file included from scripts/recordmcount.c:425:
>> scripts/recordmcount.h:451:5: error: too many arguments to function 'uwrite'
451 | uwrite(fd_map, &rel, sizeof(rel));
| ^~~~~~
scripts/recordmcount.c:101:16: note: declared here
101 | static ssize_t uwrite(void const *const buf, size_t const count)
| ^~~~~~
make[2]: *** [scripts/Makefile.host:95: scripts/recordmcount] 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.
--
In file included from scripts/recordmcount.c:423:
scripts/recordmcount.h: In function 'sift32_rel_mcount':
>> scripts/recordmcount.h:450:5: error: too many arguments to function 'ulseek'
450 | ulseek(fd_map, (void *)relp - (void *)ehdr, SEEK_SET);
| ^~~~~~
scripts/recordmcount.c:81:14: note: declared here
81 | static off_t ulseek(off_t const offset, int const whence)
| ^~~~~~
In file included from scripts/recordmcount.c:423:
>> scripts/recordmcount.h:451:12: warning: passing argument 1 of 'uwrite' makes pointer from integer without a cast [-Wint-conversion]
451 | uwrite(fd_map, &rel, sizeof(rel));
| ^~~~~~
| |
| int
scripts/recordmcount.c:101:41: note: expected 'const void * const' but argument is of type 'int'
101 | static ssize_t uwrite(void const *const buf, size_t const count)
| ~~~~~~~~~~~~~~~~~~^~~
In file included from scripts/recordmcount.c:423:
>> scripts/recordmcount.h:451:20: warning: passing argument 2 of 'uwrite' makes integer from pointer without a cast [-Wint-conversion]
451 | uwrite(fd_map, &rel, sizeof(rel));
| ^~~~
| |
| Elf32_Rel *
scripts/recordmcount.c:101:59: note: expected 'size_t' {aka 'const long unsigned int'} but argument is of type 'Elf32_Rel *'
101 | static ssize_t uwrite(void const *const buf, size_t const count)
| ~~~~~~~~~~~~~^~~~~
In file included from scripts/recordmcount.c:423:
>> scripts/recordmcount.h:451:5: error: too many arguments to function 'uwrite'
451 | uwrite(fd_map, &rel, sizeof(rel));
| ^~~~~~
scripts/recordmcount.c:101:16: note: declared here
101 | static ssize_t uwrite(void const *const buf, size_t const count)
| ^~~~~~
In file included from scripts/recordmcount.c:425:
scripts/recordmcount.h: In function 'sift64_rel_mcount':
>> scripts/recordmcount.h:450:5: error: too many arguments to function 'ulseek'
450 | ulseek(fd_map, (void *)relp - (void *)ehdr, SEEK_SET);
| ^~~~~~
scripts/recordmcount.c:81:14: note: declared here
81 | static off_t ulseek(off_t const offset, int const whence)
| ^~~~~~
In file included from scripts/recordmcount.c:425:
>> scripts/recordmcount.h:451:12: warning: passing argument 1 of 'uwrite' makes pointer from integer without a cast [-Wint-conversion]
451 | uwrite(fd_map, &rel, sizeof(rel));
| ^~~~~~
| |
| int
scripts/recordmcount.c:101:41: note: expected 'const void * const' but argument is of type 'int'
101 | static ssize_t uwrite(void const *const buf, size_t const count)
| ~~~~~~~~~~~~~~~~~~^~~
In file included from scripts/recordmcount.c:425:
>> scripts/recordmcount.h:451:20: warning: passing argument 2 of 'uwrite' makes integer from pointer without a cast [-Wint-conversion]
451 | uwrite(fd_map, &rel, sizeof(rel));
| ^~~~
| |
| Elf64_Rel *
scripts/recordmcount.c:101:59: note: expected 'size_t' {aka 'const long unsigned int'} but argument is of type 'Elf64_Rel *'
101 | static ssize_t uwrite(void const *const buf, size_t const count)
| ~~~~~~~~~~~~~^~~~~
In file included from scripts/recordmcount.c:425:
>> scripts/recordmcount.h:451:5: error: too many arguments to function 'uwrite'
451 | uwrite(fd_map, &rel, sizeof(rel));
| ^~~~~~
scripts/recordmcount.c:101:16: note: declared here
101 | static ssize_t uwrite(void const *const buf, size_t const count)
| ^~~~~~
make[2]: *** [scripts/Makefile.host:95: scripts/recordmcount] 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 +/ulseek +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