Le 03/05/2022 à 18:25, Steven Rostedt a écrit : > On Tue, 3 May 2022 11:20:22 +0000 > Christophe Leroy <christophe.le...@csgroup.eu> wrote: > >> Maybe I misunderstood. When you say 'after linking', do you mean vmlinux >> or vmlinux.o ? > > Whichever ;-) > >> >> In vmlinux, the addresses to be saved in __mcount_loc table might not >> contain anymore a call to _mcount but a call to a trampoline that jumps >> to _mcount, in case _mcount is too far from the said location at link >> time. That's what I meant. > > But how is that different than what is done today? And at linking, > everything still calls mcount. It's not until runtime things change.
Everything call _mcount but not directly. In vmlinux, relocations are resolved, trampolines are installed for unreachable destinations and you don't anymore have a section with all the relocations to mcount. It means 'recordmcount' or whatever tool we use will have to read the code to find all direct calls to mcount, then find all trampolines to mcount then find all calls to those trampolines. See below some code extracted from vmlinux on a allyesconfig powerpc64le build: c000000000012300 <__traceiter_initcall_level>: c000000000012300: 4c 1a 4c 3c addis r2,r12,6732 c000000000012304: 00 be 42 38 addi r2,r2,-16896 c000000000012308: a6 02 08 7c mflr r0 c00000000001230c: 4d 60 0d 48 bl c0000000000e8358 <_mcount> c000000000012310: a6 02 08 7c mflr r0 ... c0000000020e8740 <get_cur_path>: c0000000020e8740: 3e 18 4c 3c addis r2,r12,6206 c0000000020e8744: c0 59 42 38 addi r2,r2,22976 c0000000020e8748: a6 02 08 7c mflr r0 c0000000020e874c: c5 ff 7c 48 bl c0000000028b8710 <0003af2b.plt_branch._mcount> c0000000020e8750: a6 02 08 7c mflr r0 ... c0000000028b8710 <0003af2b.plt_branch._mcount>: c0000000028b8710: ff ff 82 3d addis r12,r2,-1 c0000000028b8714: 98 8e 8c e9 ld r12,-29032(r12) c0000000028b8718: a6 03 89 7d mtctr r12 c0000000028b871c: 20 04 80 4e bctr ... c0000000044bdcc0 <handle_lcd_irq.isra.0>: c0000000044bdcc0: 01 16 4c 3c addis r2,r12,5633 c0000000044bdcc4: 40 04 42 38 addi r2,r2,1088 c0000000044bdcc8: a6 02 08 7c mflr r0 c0000000044bdccc: fd 2d c0 49 bl c0000000060c0ac8 <000a751f.plt_branch._mcount> c0000000044bdcd0: a6 02 08 7c mflr r0 ... c0000000060c0ac8 <000a751f.plt_branch._mcount>: c0000000060c0ac8: ff ff 82 3d addis r12,r2,-1 c0000000060c0acc: 98 8e 8c e9 ld r12,-29032(r12) c0000000060c0ad0: a6 03 89 7d mtctr r12 c0000000060c0ad4: 20 04 80 4e bctr ... Christophe