From: John Reiser <jreiser@bitwagon.com>
To: Steven Rostedt <srostedt@redhat.com>,
Steven Rostedt <rostedt@goodmis.org>
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: recordmcount commutes with "ld -r"
Date: Mon, 10 Aug 2009 08:46:32 -0700 [thread overview]
Message-ID: <4A8040D8.8020504@bitwagon.com> (raw)
Executing recordmcount.pl for each *.o is adding minutes to the duration
of my full kernel builds. Here is a way to recoup most of those minutes.
recordmcount commutes with "ld -r". Run "ld -r" on the outputs from
running recordmcount on each *.o, or run recordmcount on the output from
aggregating the original *.o using "ld -r". Either way, the final
__mcount_loc section contains a list of locations of calls to mcount.
The ELF32_R_SYM (ELF64_R_SYM) of the relocations may be different, but
they will be equivalent. Subsequent static binding (ld without -r)
will produce identical results. Instead of running recordmcount on each
*.o input file that is part of built-in.o or <module>.ko, then
just run recordmcount on built-in.o or <module>.ko that is constructed
from the original compiler-generated *.o.
There is a special case for building vmlinux, namely the archive
libraries lib/lib.a and arch/$ARCH/lib/lib.a. recordmcount must be run
on each member individually. Alternately, recordmcount could be run
on vmlinux.o (exactly once per build; not on any built-in.o)
if vmlinux.o is then used to build vmlinux.
I noticed another property. Logically, recordmcount could modify a
.o file in place. Both /bin/ld and the kernel module loader ignore
bytes that are not designated by the ElfXX_Shdr[]. The __mcount_loc
section and its relocations can be appended to the original file, then
"activated" by rewriting the ElfXX_Ehdr fields .e_shnum and .e_shoff.
This avoids some file operations as well as several fork+exec that are
performed by recordmcount.pl. recordmcount becomes very fast.
The bytes for the old ElfXX_Shdr[] remain as uncollected "garbage",
typically a few kilobytes in each built-in.o or <module>.ko.
If desired then the garbage may be excised quickly by running "ld -r".
I have written recordmcount.c which does such modify-in-place for all
architectures supported by recordcmount, and tested it successfully on
i686, x86_64, and 32-bit PowerPC, including cross-platform processing
of *.o from any architecture. The differing data structures between
Elf32 and Elf64 require parallel code in many places, so the C file is
900 lines. That might be too long for a mailing list, so I will defer
posting the file.
--
next reply other threads:[~2009-08-10 15:46 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-08-10 15:46 John Reiser [this message]
2009-08-17 14:33 ` recordmcount commutes with "ld -r" Steven Rostedt
2009-08-17 15:52 ` John Reiser
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4A8040D8.8020504@bitwagon.com \
--to=jreiser@bitwagon.com \
--cc=linux-kernel@vger.kernel.org \
--cc=rostedt@goodmis.org \
--cc=srostedt@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.