ecc81e3312
The Linux kernel dynamically patches in __fentry__ calls in and out at runtime. This allows using function tracing for debugging in production kernels without (significant) performance penalty. For this it needs a table pointing to each __fentry__ call. The way it is currently implemented is that a special perl script scans the object file, generates the table in a special section. When the kernel boots up it nops the calls, and then later patches in the calls again as needed. The recordmcount.pl script in the kernel works, but it seems cleaner and faster to support the code generation of the patch table directly in gcc. This also allows to nop the calls directly at code generation time, which allows to skip a patching step at kernel boot. I also expect that a patchable production tracing facility is also useful for other applications. For example it could be used in ftracer (https://github.com/andikleen/ftracer) Having a nop area at the beginning of each function can be also also useful for other things. For example it can be used to patch functions at runtime to point to different functions, to do binary updates without restarting the program (like ksplice or similar) This patch implements two new options for the i386 target: -mrecord-mcount Generate a __mcount_loc section entry for each __fentry__ or mcount call. The section is compatible with the kernel convention and the data is put into a section loaded at runtime. -mnop-mcount Generate the mcount/__fentry__ call as 5 byte nop that can be patched in later. The nop is generated as a single instruction, as the Linux kernel run time patching relies on this. Limitations: - I didn't implement -mnop-mcount for -fPIC. This would need a good single instruction 6 byte NOP and it seems a bit pointless, as the patching would prevent text sharing. - I didn't implement noping for targets that pass a variable to mcount. - The facility could be useful on architectures too. Currently the mcount code is target specific, so I made it a i386 option. gcc/: 2014-09-25 Andi Kleen <ak@linux.intel.com> * config/i386/i386.c (x86_print_call_or_nop): New function. (x86_function_profiler): Support -mnop-mcount and -mrecord-mcount. * config/i386/i386.opt (-mnop-mcount, -mrecord-mcount): Add * doc/invoke.texi: Document -mnop-mcount, -mrecord-mcount. gcc/testsuite: 2014-09-25 Andi Kleen <ak@linux.intel.com> * gcc.target/i386/nop-mcount.c: New file. * gcc.target/i386/record-mcount.c: New file. From-SVN: r215629 |
||
---|---|---|
boehm-gc | ||
config | ||
contrib | ||
fixincludes | ||
gcc | ||
gnattools | ||
include | ||
INSTALL | ||
intl | ||
libada | ||
libatomic | ||
libbacktrace | ||
libcilkrts | ||
libcpp | ||
libdecnumber | ||
libffi | ||
libgcc | ||
libgfortran | ||
libgo | ||
libgomp | ||
libiberty | ||
libitm | ||
libjava | ||
libobjc | ||
libquadmath | ||
libsanitizer | ||
libssp | ||
libstdc++-v3 | ||
libvtv | ||
lto-plugin | ||
maintainer-scripts | ||
zlib | ||
.dir-locals.el | ||
.gitignore | ||
ABOUT-NLS | ||
ChangeLog | ||
ChangeLog.tree-ssa | ||
compile | ||
config-ml.in | ||
config.guess | ||
config.rpath | ||
config.sub | ||
configure | ||
configure.ac | ||
COPYING | ||
COPYING3 | ||
COPYING3.LIB | ||
COPYING.LIB | ||
COPYING.RUNTIME | ||
depcomp | ||
install-sh | ||
libtool-ldflags | ||
libtool.m4 | ||
lt~obsolete.m4 | ||
ltgcc.m4 | ||
ltmain.sh | ||
ltoptions.m4 | ||
ltsugar.m4 | ||
ltversion.m4 | ||
MAINTAINERS | ||
Makefile.def | ||
Makefile.in | ||
Makefile.tpl | ||
missing | ||
mkdep | ||
mkinstalldirs | ||
move-if-change | ||
README | ||
symlink-tree | ||
ylwrap |
This directory contains the GNU Compiler Collection (GCC). The GNU Compiler Collection is free software. See the files whose names start with COPYING for copying permission. The manuals, and some of the runtime libraries, are under different terms; see the individual source files for details. The directory INSTALL contains copies of the installation information as HTML and plain text. The source of this information is gcc/doc/install.texi. The installation information includes details of what is included in the GCC sources and what files GCC installs. See the file gcc/doc/gcc.texi (together with other files that it includes) for usage and porting information. An online readable version of the manual is in the files gcc/doc/gcc.info*. See http://gcc.gnu.org/bugs/ for how to report bugs usefully. Copyright years on GCC source files may be listed using range notation, e.g., 1987-2012, indicating that every year in the range, inclusive, is a copyrightable year that could otherwise be listed individually.