kernel-ark/scripts
Wu Zhangjin 412910cd04 ftrace/MIPS: Add module support for C version of recordmcount
Since MIPS modules' address space differs from the core kernel space, to access
the _mcount in the core kernel, the kernel functions in modules must use long
call (-mlong-calls): load the _mcount address into one register and jump to the
address stored by the register:

 c:  3c030000        lui     v1,0x0  <-------->  b label
           c: R_MIPS_HI16  _mcount
           c: R_MIPS_NONE  *ABS*
           c: R_MIPS_NONE  *ABS*
10:  64630000        daddiu  v1,v1,0
          10: R_MIPS_LO16 _mcount
          10: R_MIPS_NONE *ABS*
          10: R_MIPS_NONE *ABS*
14:	03e0082d 	move	at,ra
18:	0060f809 	jalr	v1
label:

In the old Perl version of recordmcount, we only need to record the position of
the 1st R_MIPS_HI16 type of _mcount, and later, in ftrace_make_nop(), replace
the instruction in this position by a "b label" and in ftrace_make_call(),
replace it back.

But, the default C version of recordmcount records all of the _mcount symbols,
so, we must filter the 2nd _mcount like the Perl version of recordmcount does.

The C version of recordmcount copes with the symbols before they are linked, So
It doesn't know the type of the symbols and therefore can not filter the
symbols as the Perl version of recordmcount does. But as we can see above, the
2nd _mcount symbols of the long call alawys follows the 1st _mcount symbol of
the same long call, which means the offset from the 1st to the 2nd is fixed, it
is 0x10-0xc = 4 here, 4 is the length of the 1st load instruciton, for MIPS has
fixed length of instructions, this offset is always 4.

And as we know, the _mcount is inserted into the entry of every kernel
function, the offset between the other _mcount's is expected to be always
bigger than 4. So, to filter the 2ns _mcount symbol of the long call, we can
simply check the offset between two _mcount symbols, If it is 4, then, filter
the 2nd _mcount symbol.

To avoid touching too much code, an 'empty' function fn_is_fake_mcount() is
added for all of the archs, and the specific archs can override it via chaning
the function pointer: is_fake_mcount in do_file() with the e_machine. e.g. This
patch adds MIPS_is_fake_mcount() to override the default fn_is_fake_mcount()
pointed by is_fake_mcount.

This fn_is_fake_mcount() checks if the _mcount symbol is fake, e.g. the 2nd
_mcount symbol of the long call is fake, for there are 2 _mcount symbols mapped
to one real mcount call, so, one of them is fake and must be filtered.

This fn_is_fake_mcount() is called in sift_rel_mcount() after finding the
_mcount symbols and before adding the _mcount symbol into mrelp, so, it can
prevent the fake mcount symbol going into the last __mcount_loc table.

Signed-off-by: Wu Zhangjin <wuzhangjin@gmail.com>
LKML-Reference: <b866f0138224340a132d31861fa3f9300dee30ac.1288176026.git.wuzhangjin@gmail.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
2010-10-29 19:08:55 +01:00
..
basic Merge branch 'misc' of git://git.kernel.org/pub/scm/linux/kernel/git/mmarek/kbuild-2.6 2010-10-28 16:18:59 -07:00
coccinelle Coccinelle: Find doubled arguments to boolean or bit operators. 2010-10-28 00:32:23 +02:00
dtc scripts/dtc: Fix a resource leak 2010-07-02 13:51:11 +02:00
genksyms genksyms: close ref_file after use 2010-02-02 14:33:55 +01:00
kconfig Merge branch 'message-callback' into kbuild/kconfig 2010-10-28 00:54:25 +02:00
ksymoops
mod Merge branch 'kbuild' of git://git.kernel.org/pub/scm/linux/kernel/git/mmarek/kbuild-2.6 2010-10-28 15:13:55 -07:00
package Merge branch 'packaging' of git://git.kernel.org/pub/scm/linux/kernel/git/mmarek/kbuild-2.6 2010-10-28 16:19:38 -07:00
rt-tester scripts: change scripts to use system python instead of env 2010-02-02 14:33:56 +01:00
selinux selinux: fix warning in genheaders 2010-03-16 08:47:36 +11:00
tracing
.gitignore
bin2c.c
bloat-o-meter
bootgraph.pl
checkincludes.pl checkincludes: fix perlcritic warnings 2010-03-07 21:19:57 +01:00
checkkconfigsymbols.sh checkkconfigsymbols.sh: Kconfig symbols sometimes have lowercase letters 2010-06-03 10:39:39 +02:00
checkpatch.pl scripts/checkpatch.pl: add check for declaration of pci_device_id 2010-10-26 16:52:21 -07:00
checkstack.pl scripts: improve checkstack 2010-03-07 21:19:09 +01:00
checksyscalls.sh Add wait4() back to the set of <asm-generic/unistd.h> syscalls. 2010-06-25 14:54:16 -04:00
checkversion.pl checkversion: perl cleanup 2010-03-07 21:22:56 +01:00
cleanfile
cleanpatch
coccicheck Coccinelle: Add contextual message 2010-10-28 00:32:23 +02:00
config
conmakehash.c
decodecode scripts: decodecode: remove bashisms 2010-06-04 10:26:35 +02:00
diffconfig
export_report.pl export_report: fix perl warnings 2010-03-07 21:41:04 +01:00
extract-ikconfig scripts/extract-ikconfig: add support for bzip2, lzma and lzo 2010-10-28 00:22:17 +02:00
gcc-goto.sh jump label: Fix GCC feature check when distcc is used 2010-09-24 09:12:25 +02:00
gcc-version.sh
gcc-x86_32-has-stack-protector.sh
gcc-x86_64-has-stack-protector.sh
gen_initramfs_list.sh Merge branch 'for-35' of git://repo.or.cz/linux-kbuild 2010-06-01 08:55:52 -07:00
get_maintainer.pl scripts/get_maintainer.pl: don't deduplicate unnamed addresses ie: mailing lists 2010-10-26 16:52:17 -07:00
gfp-translate tree-wide: Assorted spelling fixes 2010-02-09 11:13:56 +01:00
headerdep.pl headerdep: perlcritic warning 2010-03-23 12:26:38 +01:00
headers_check.pl headers_check: fix perl warnings 2010-03-07 21:43:07 +01:00
headers_install.pl headers_install: use local file handles 2010-03-07 21:43:49 +01:00
headers.sh kbuild: do not check for include/asm-$ARCH 2009-12-12 13:08:14 +01:00
kallsyms.c scripts/kallsyms: Enable error messages while hush up unnecessary warnings 2010-09-29 16:18:27 +02:00
Kbuild.include kbuild: generate modules.builtin 2009-12-12 13:08:16 +01:00
kernel-doc docbook: warn on unused doc entries 2010-09-11 16:49:21 -07:00
Lindent
Makefile ftrace/x86: Add support for C version of recordmcount 2010-10-14 16:52:41 -04:00
Makefile.build Merge branch 'devel' of master.kernel.org:/home/rmk/linux-2.6-arm 2010-10-21 16:42:32 -07:00
Makefile.clean kbuild: Really don't clean bounds.h and asm-offsets.h 2010-03-11 11:15:22 +01:00
Makefile.fwinst
Makefile.headersinst kbuild: drop unifdef-y support 2010-08-14 22:26:52 +02:00
Makefile.help Add a target to use the Coccinelle checker 2010-06-12 00:00:29 +02:00
Makefile.host
Makefile.lib Merge branch 'kbuild' of git://git.kernel.org/pub/scm/linux/kernel/git/mmarek/kbuild-2.6 2010-10-28 15:13:55 -07:00
Makefile.modbuiltin kbuild: Create output directory in Makefile.modbuiltin 2010-06-10 12:23:08 +02:00
Makefile.modinst
Makefile.modpost trivial: fix a typo in a filename 2010-08-03 14:59:50 +02:00
makelst
markup_oops.pl Merge branch 'for-35' of git://repo.or.cz/linux-kbuild 2010-06-01 08:55:52 -07:00
mkcompile_h scripts/mkcompile_h: don't test for hardcoded paths 2010-02-02 14:33:56 +01:00
mkmakefile fixes for using make 3.82 2010-08-17 11:47:40 +02:00
mksysmap
mkuboot.sh
mkversion
module-common.lds
namespace.pl Revert "namespace: add source file location exceptions" 2010-10-28 00:59:56 +02:00
patch-kernel
pnmtologo.c
profile2linkerlist.pl profile2linkerlist: fix perl warnings 2010-03-07 21:39:33 +01:00
recordmcount.c ftrace/MIPS: Add module support for C version of recordmcount 2010-10-29 19:08:55 +01:00
recordmcount.h ftrace/MIPS: Add module support for C version of recordmcount 2010-10-29 19:08:55 +01:00
recordmcount.pl ARM: 6319/1: ftrace: add Thumb-2 support to dynamic ftrace 2010-09-02 15:28:43 +01:00
setlocalversion Merge branch 'kbuild' of git://git.kernel.org/pub/scm/linux/kernel/git/mmarek/kbuild-2.6 2010-10-28 15:13:55 -07:00
show_delta scripts: change scripts to use system python instead of env 2010-02-02 14:33:56 +01:00
tags.sh Revert "kbuild: specify absolute paths for cscope" 2010-03-08 10:26:22 +01:00
unifdef.c unifdef: update to upstream revision 1.190 2009-12-12 13:08:16 +01:00
ver_linux