From: Matt Helsley <mhelsley@vmware.com>
To: Julien Thierry <jthierry@redhat.com>
Cc: <linux-kernel@vger.kernel.org>,
Josh Poimboeuf <jpoimboe@redhat.com>,
Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@redhat.com>,
Steven Rostedt <rostedt@goodmis.org>,
Miroslav Benes <mbenes@suse.cz>
Subject: Re: [RFC][PATCH 03/36] objtool: Enable compilation of objtool for all architectures
Date: Tue, 14 Apr 2020 13:56:03 -0700 [thread overview]
Message-ID: <20200414205603.GC118458@rlwimi.vmware.com> (raw)
In-Reply-To: <e8a52162-dd38-6092-7217-cc5c088abadc@redhat.com>
On Tue, Apr 14, 2020 at 08:39:23AM +0100, Julien Thierry wrote:
> Hi Matt,
>
> On 4/10/20 8:35 PM, Matt Helsley wrote:
> > objtool currently only compiles for x86 architectures. This is
> > fine as it presently does not support tooling for other
> > architectures. However, we would like to be able to convert other
> > kernel tools to run as objtool sub commands because they too
> > process ELF object files. This will allow us to convert tools
> > such as recordmcount to use objtool's ELF code.
> >
> > Since much of recordmcount's ELF code is copy-paste code to/from
> > a variety of other kernel tools (look at modpost for example) this
> > means that if we can convert recordmcount we can convert more.
> >
> > We define a "missing" architecture which contains weak definitions
> > for tools that do not exist on all architectures. In this case the
> > "check" and "orc" tools do not exist on all architectures.
> >
> > To test building for other architectures ($arch below):
> >
> > cd tools/objtool/arch
> > ln -s missing $arch
> > make O=build-$arch ARCH=$arch tools/objtool
> >
> > This uses the weak, no-op definitions of the "check" and "orc"
> > commands for the newly-supported architecture. Presently these
> > exit with 127 to indicate that the subcommands are missing.
> > Subsequent patches can then be made to determine if the weak
> > definitions are used and explicitly report a missing command,
> > and even to list which subcommands are supported (perhaps if
> > no subcommand is specified it can list the supported subcommands).
> >
> > objtool is not currently wired in to KConfig to be built for other
> > architectures because it's not needed for those architectures and
> > there are no commands it supports other than those for x86.
> >
> > This commit allows us to demonstrate the pattern of adding
> > architecture support and isolates moving the various files from
> > adding support for more objtool subcommands.
> >
> > Signed-off-by: Matt Helsley <mhelsley@vmware.com>
> > ---
> > tools/objtool/Build | 4 ---
> > tools/objtool/arch/missing/Build | 3 ++
> > tools/objtool/arch/missing/check.c | 14 +++++++++
> > tools/objtool/arch/missing/orc_dump.c | 11 +++++++
> > tools/objtool/arch/missing/orc_gen.c | 16 ++++++++++
> > tools/objtool/arch/x86/Build | 4 +++
> > tools/objtool/{ => arch/x86}/arch.h | 42 ++++++++++++++++++++++++-
> > tools/objtool/{ => arch/x86}/cfi.h | 0
> > tools/objtool/{ => arch/x86}/check.c | 11 ++++---
> > tools/objtool/arch/x86/decode.c | 2 +-
> > tools/objtool/{ => arch/x86}/orc_dump.c | 5 +--
> > tools/objtool/{ => arch/x86}/orc_gen.c | 9 ++++--
> > tools/objtool/{ => arch/x86}/special.c | 4 +--
> > tools/objtool/{ => arch/x86}/special.h | 2 +-
> > tools/objtool/builtin-orc.c | 2 +-
> > tools/objtool/check.h | 37 ----------------------
> > tools/objtool/objtool.h | 2 +-
> > tools/objtool/orc.h | 2 --
> > 18 files changed, 110 insertions(+), 60 deletions(-)
> > create mode 100644 tools/objtool/arch/missing/Build
> > create mode 100644 tools/objtool/arch/missing/check.c
> > create mode 100644 tools/objtool/arch/missing/orc_dump.c
> > create mode 100644 tools/objtool/arch/missing/orc_gen.c
> > rename tools/objtool/{ => arch/x86}/arch.h (59%)
> > rename tools/objtool/{ => arch/x86}/cfi.h (100%)
> > rename tools/objtool/{ => arch/x86}/check.c (99%)
> > rename tools/objtool/{ => arch/x86}/orc_dump.c (98%)
> > rename tools/objtool/{ => arch/x86}/orc_gen.c (96%)
> > rename tools/objtool/{ => arch/x86}/special.c (98%)
> > rename tools/objtool/{ => arch/x86}/special.h (95%)
> >
>
> My concern with this it that most of the structures and code in arch.h and
> check.c can/should be reused across architectures. So, when providing
> support for a new architecutre, the first thing that will be needed is to
> move those back under tools/objtool whithout disturbing the arches that
> don't yet provide support for "check" subcommand.
Agreed. I tried to note this in my cover letter but perhaps I could have
written it better.
I still included it because I think the check.c portion of this RFC shows
what it would look like to add a hypothetical objtool subcommand implemented
for only one architecture (which "check" is, currently, an example of). I
don't think this RFC shows what should happen to check.c in particular.
You folks have been working on that here and I don't wish to disturb your
work.
>
> So, if it is decided that recordmcount should be an objtool subcommand, the
> code itself should probably stay under tools/objtool and then have different
> compilation configurations for objtool depending on the architecture (e.g.
> HAVE_OBJTOOL_CHECK, HAVE_OBJTOOL_ORC) or something of the sort.
Yeah. HAVE_C_RECORDMCOUNT is used in the Makefiles to select building
an running objtool mcount versus recordmcount.pl (which is another piece
that needs some attention -- my preference is to slowly move arch
support from there into recordmcount.c. So far it looks like s390 and mips
are the ones needing a little special attention there..)
My recollection is Josh wanted to avoid a bunch of architecture/config
checks in the code if I recall. It leaks into the code that implements the
subcommand tables, for example, and that's why I chose to use weak symbols --
we can unconditionally add the table entries and we don't need to play
linker script + macro games to build the array.
As for managing minor architectural variations in a single subcommand, either
those can use more weak symbols via arch/foo/subcmd.[ch] files or via explicit
checks in the code (see the arch, endian, and class switches in recordmcount.c
for the latter). If folks are OK with using weak symbols I'm curious what
preferences are on choosing when to use which method -- the RFC reflects
mine of course but I want to know what makes it more maintainable for
other folks.
Cheers,
-Matt Helsley
next prev parent reply other threads:[~2020-04-14 20:56 UTC|newest]
Thread overview: 52+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-10 19:35 [RFC][PATCH 00/36] objtool: Make recordmcount a subcommand Matt Helsley
2020-04-10 19:35 ` [RFC][PATCH 01/36] objtool: Exit successfully when requesting help Matt Helsley
2020-04-10 19:35 ` [RFC][PATCH 02/36] objtool: Move struct objtool_file into arch-independent header Matt Helsley
2020-04-10 19:35 ` [RFC][PATCH 03/36] objtool: Enable compilation of objtool for all architectures Matt Helsley
2020-04-14 7:39 ` Julien Thierry
2020-04-14 13:41 ` Steven Rostedt
2020-04-14 14:01 ` Julien Thierry
2020-04-14 20:56 ` Matt Helsley [this message]
2020-04-15 7:05 ` Julien Thierry
2020-04-10 19:35 ` [RFC][PATCH 04/36] objtool: Report missing support for subcommands Matt Helsley
2020-04-10 19:35 ` [RFC][PATCH 05/36] objtool: Add support for relocations without addends Matt Helsley
2020-04-10 19:35 ` [RFC][PATCH 06/36] objtool: Prepare to merge recordmcount Matt Helsley
2020-04-10 19:35 ` [RFC][PATCH 07/36] objtool: Make recordmcount into mcount subcmd Matt Helsley
2020-04-10 19:35 ` [RFC][PATCH 08/36] objtool: recordmcount: Start using objtool's elf wrapper Matt Helsley
2020-04-10 19:35 ` [RFC][PATCH 09/36] objtool: recordmcount: Search for __mcount_loc before walking the sections Matt Helsley
2020-04-10 19:35 ` [RFC][PATCH 10/36] objtool: recordmcount: Convert do_func() relhdrs Matt Helsley
2020-04-10 19:35 ` [RFC][PATCH 11/36] objtool: mcount: Remove unused fname parameter Matt Helsley
2020-04-10 19:35 ` [RFC][PATCH 12/36] objtool: mcount: Use libelf for section header names Matt Helsley
2020-04-10 19:35 ` [RFC][PATCH 13/36] objtool: mcount: Walk objtool Elf structs in find_secsym_ndx Matt Helsley
2020-04-10 19:35 ` [RFC][PATCH 14/36] objtool: mcount: Use symbol structs to find mcount relocations Matt Helsley
2020-04-10 19:35 ` [RFC][PATCH 15/36] objtool: mcount: Walk relocation lists Matt Helsley
2020-04-10 19:35 ` [RFC][PATCH 16/36] objtool: mcount: Move get_mcountsym Matt Helsley
2020-04-10 19:35 ` [RFC][PATCH 17/36] objtool: mcount: Replace MIPS offset types Matt Helsley
2020-04-10 19:35 ` [RFC][PATCH 18/36] objtool: mcount: Move is_fake_mcount() Matt Helsley
2020-04-10 19:35 ` [RFC][PATCH 19/36] objtool: mcount: Stop using ehdr in find_section_sym_index Matt Helsley
2020-04-10 19:35 ` [RFC][PATCH 20/36] objtool: mcount: Move find_section_sym_index() Matt Helsley
2020-04-10 19:35 ` [RFC][PATCH 21/36] objtool: mcount: Restrict using ehdr in append_func() Matt Helsley
2020-04-10 19:35 ` [RFC][PATCH 22/36] objtool: mcount: Use objtool ELF to write Matt Helsley
2020-04-10 19:35 ` [RFC][PATCH 23/36] objtool: mcount: Move nop_mcount() Matt Helsley
2020-04-10 19:35 ` [RFC][PATCH 24/36] objtool: mcount: Move helpers out of ELF wrapper Matt Helsley
2020-04-10 19:35 ` [RFC][PATCH 25/36] objtool: mcount: Move relocation entry size detection Matt Helsley
2020-04-10 19:35 ` [RFC][PATCH 26/36] objtool: mcount: Only keep ELF file size Matt Helsley
2020-04-10 19:35 ` [RFC][PATCH 27/36] objtool: mcount: Use ELF header from objtool Matt Helsley
2020-04-10 19:35 ` [RFC][PATCH 28/36] objtool: mcount: Remove unused file mapping Matt Helsley
2020-04-10 19:35 ` [RFC][PATCH 29/36] objtool: mcount: Reduce usage of _size wrapper Matt Helsley
2020-04-10 19:35 ` [RFC][PATCH 30/36] objtool: mcount: Move mcount_adjust out of wrapper Matt Helsley
2020-04-10 19:35 ` [RFC][PATCH 31/36] objtool: mcount: Pre-allocate new ELF sections Matt Helsley
2020-04-10 19:35 ` [RFC][PATCH 32/36] objtool: mcount: Generic location and relocation table types Matt Helsley
2020-04-10 19:35 ` [RFC][PATCH 33/36] objtool: mcount: Move sift_rel_mcount out of wrapper file Matt Helsley
2020-04-10 19:35 ` [RFC][PATCH 34/36] objtool: mcount: Remove wrapper for ELF relocation type Matt Helsley
2020-04-10 19:35 ` [RFC][PATCH 35/36] objtool: mcount: Remove wrapper double-include trick Matt Helsley
2020-04-10 19:35 ` [RFC][PATCH 36/36] objtool: mcount: Remove wordsized endian wrappers Matt Helsley
2020-04-14 7:24 ` [RFC][PATCH 00/36] objtool: Make recordmcount a subcommand Julien Thierry
2020-04-14 13:35 ` Steven Rostedt
2020-04-14 14:17 ` Julien Thierry
2020-04-14 15:54 ` Steven Rostedt
2020-04-14 20:09 ` Matt Helsley
2020-04-14 20:47 ` Peter Zijlstra
2020-04-14 21:05 ` Steven Rostedt
2020-04-14 21:17 ` Peter Zijlstra
2020-04-14 21:47 ` Steven Rostedt
2020-04-14 22:25 ` Peter Zijlstra
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=20200414205603.GC118458@rlwimi.vmware.com \
--to=mhelsley@vmware.com \
--cc=jpoimboe@redhat.com \
--cc=jthierry@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mbenes@suse.cz \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).