All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC][PATCH 00/36] objtool: Make recordmcount a subcommand
@ 2020-04-10 19:35 Matt Helsley
  2020-04-10 19:35 ` [RFC][PATCH 01/36] objtool: Exit successfully when requesting help Matt Helsley
                   ` (36 more replies)
  0 siblings, 37 replies; 54+ messages in thread
From: Matt Helsley @ 2020-04-10 19:35 UTC (permalink / raw)
  To: linux-kernel
  Cc: Josh Poimboeuf, Peter Zijlstra, Julien Thierry, Ingo Molnar,
	Steven Rostedt, Miroslav Benes, Matt Helsley

recordmcount has its own ELF wrapper code and could utilize
objtool's ELF code to more-portably handle architecture variations.
This series makes recordmcount a subcommand of objtool.

The initial 5 patches make objtool compilable for more than x86.
Unlike recordmcount the check command and orc tools are not currently
checking other architectures so we need a way to cleanly build
objtool for those architectures that don't support check / orc. I
went with using weak symbols and added a "missing" architecture
which can be used to indicate the tool is not implemented while
avoiding the need for every architecture to explicitly specify
which subcommands / features are not implemented. I'm curious if
there are better approaches folks recommend though -- this is the
one I landed on. The patches do not add HAVE_OBJTOOL to all
architectures.

Note:
I've been following some of the discussion around making check work
for arm64. So I'd say this series moves check into arch/x86 to
reflect its current status and demonstrates how a command relevant
to a single arch could be handled -- not necessarily what
will/should happen to check.

Subsequent patches, the bulk of the set, very gradually convert
recordmcount to become a subcommand of objtool and then reuse
parts of objtool's ELF code. recordmcount maps the file in and
collects simple information it needs to append a section to the
object file. The only part of the original file it modifies is the
address of new section tables -- interestingly enough this
resembles RCU in that we don't really trim the old tables so
much as unlink them via one critical offset and then rely on
future (tooling in this case) to drop the unused bits. So much of
the recordmcount ELF code is only reading and walking the data
structures to collect the mcount locations it records in a separate
area of memory. This means it's safe to mix access to the mapped
file with access to the objtool-style linked data
structures as we gradually convert it to using only the linked data
structures. Once the old ELF code is no longer in use we can drop it
and use objtool to take over the task of writing the results without
using the RCU-like trick any more.

Testing so far:

I've been using scripts to test compilation, execution of objtool,
and mcount output for x86, ppc64le, arm64, s390, and sparc.

Matt Helsley (36):
  objtool: Exit successfully when requesting help
  objtool: Move struct objtool_file into arch-independent header
  objtool: Enable compilation of objtool for all architectures
  objtool: Report missing support for subcommands
  objtool: Add support for relocations without addends
  objtool: Prepare to merge recordmcount
  objtool: Make recordmcount into mcount subcmd
  objtool: recordmcount: Start using objtool's elf wrapper
  objtool: recordmcount: Search for __mcount_loc before walking the
    sections
  objtool: recordmcount: Convert do_func() relhdrs
  objtool: mcount: Remove unused fname parameter
  objtool: mcount: Use libelf for section header names
  objtool: mcount: Walk objtool Elf structs in find_secsym_ndx
  objtool: mcount: Use symbol structs to find mcount relocations
  objtool: mcount: Walk relocation lists
  objtool: mcount: Move get_mcountsym
  objtool: mcount: Replace MIPS offset types
  objtool: mcount: Move is_fake_mcount()
  objtool: mcount: Stop using ehdr in find_section_sym_index
  objtool: mcount: Move find_section_sym_index()
  objtool: mcount: Restrict using ehdr in append_func()
  objtool: mcount: Use objtool ELF to write
  objtool: mcount: Move nop_mcount()
  objtool: mcount: Move helpers out of ELF wrapper
  objtool: mcount: Move relocation entry size detection
  objtool: mcount: Only keep ELF file size
  objtool: mcount: Use ELF header from objtool
  objtool: mcount: Remove unused file mapping
  objtool: mcount: Reduce usage of _size wrapper
  objtool: mcount: Move mcount_adjust out of wrapper
  objtool: mcount: Pre-allocate new ELF sections
  objtool: mcount: Generic location and relocation table types
  objtool: mcount: Move sift_rel_mcount out of wrapper file
  objtool: mcount: Remove wrapper for ELF relocation type
  objtool: mcount: Remove wrapper double-include trick
  objtool: mcount: Remove wordsized endian wrappers

 Documentation/dontdiff                     |   2 +-
 Documentation/trace/ftrace-design.rst      |   4 +-
 Documentation/trace/ftrace.rst             |   6 +-
 Makefile                                   |   6 +-
 arch/arm64/include/asm/ftrace.h            |   2 +-
 arch/x86/include/asm/ftrace.h              |   2 +-
 kernel/trace/Kconfig                       |   2 +-
 scripts/.gitignore                         |   1 -
 scripts/Makefile                           |   1 -
 scripts/Makefile.build                     |  24 +-
 scripts/recordmcount.c                     | 663 --------------------
 scripts/recordmcount.h                     | 606 ------------------
 scripts/sorttable.h                        |   2 +-
 tools/objtool/.gitignore                   |   1 +
 tools/objtool/Build                        |   6 +-
 tools/objtool/Makefile                     |   1 +
 tools/objtool/arch/missing/Build           |   4 +
 tools/objtool/arch/missing/check.c         |  16 +
 tools/objtool/arch/missing/mcount.c        |  16 +
 tools/objtool/arch/missing/orc_dump.c      |  13 +
 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-check.c              |   5 +
 tools/objtool/builtin-mcount.c             |  56 ++
 tools/objtool/builtin-orc.c                |   9 +-
 tools/objtool/builtin.h                    |   4 +
 tools/objtool/check.h                      |  48 +-
 tools/objtool/elf.c                        |  60 +-
 tools/objtool/elf.h                        |   7 +-
 tools/objtool/mcount.h                     |  14 +
 tools/objtool/objtool.c                    |  40 +-
 tools/objtool/objtool.h                    |  20 +
 tools/objtool/orc.h                        |   3 +-
 tools/objtool/recordmcount.c               | 682 +++++++++++++++++++++
 {scripts => tools/objtool}/recordmcount.pl |   0
 43 files changed, 1038 insertions(+), 1383 deletions(-)
 delete mode 100644 scripts/recordmcount.c
 delete mode 100644 scripts/recordmcount.h
 create mode 100644 tools/objtool/arch/missing/Build
 create mode 100644 tools/objtool/arch/missing/check.c
 create mode 100644 tools/objtool/arch/missing/mcount.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%)
 create mode 100644 tools/objtool/builtin-mcount.c
 create mode 100644 tools/objtool/mcount.h
 create mode 100644 tools/objtool/objtool.h
 create mode 100644 tools/objtool/recordmcount.c
 rename {scripts => tools/objtool}/recordmcount.pl (100%)

-- 
2.20.1


^ permalink raw reply	[flat|nested] 54+ messages in thread

end of thread, other threads:[~2020-04-15  7:05 UTC | newest]

Thread overview: 54+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
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 23:07   ` kbuild test robot
2020-04-11  1:09   ` kbuild test robot
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

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.