linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC][PATCH v4 00/32] objtool: Make recordmcount a subcommand
@ 2020-06-02 19:49 Matt Helsley
  2020-06-02 19:49 ` [RFC][PATCH v4 01/32] objtool: Prepare to merge recordmcount Matt Helsley
                   ` (31 more replies)
  0 siblings, 32 replies; 49+ messages in thread
From: Matt Helsley @ 2020-06-02 19:49 UTC (permalink / raw)
  To: linux-kernel
  Cc: Josh Poimboeuf, Peter Zijlstra, Steven Rostedt, Sami Tolvanen,
	Julien Thierry, Kamalesh Babulal, 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. It  very
gradually convert recordmcount to become a subcommand of objtool and
then reuses 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 a critical offset and then rely on
future tooling, in this case, to drop the unused bits. 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:

I've been using scripts to test cross compilation and execution of
objtool, and mcount on objects built for x86, ppc64le, arm64, s390, and
sparc. I used PowerPC as a sample arch for fixing a bug (see Changes)
and confirmed it builds a full zImage with defconfig
(CONFIG_DYNAMIC_FTRACE=y).

Changes
v4:
	Split out recordmcount cleanups and upstreamed.
	[ https://lore.kernel.org/lkml/20190802134712.2d8cc63f@gandalf.local.home/ ]

	Split out and iterated on objtool multi-arch support.
	[ https://lore.kernel.org/lkml/cover.1586468801.git.mhelsley@vmware.com/ ]

	Split out expanded relocation support, renamed types, and functions
	to reflect expanded relocation support, and posted.
	[ https://lore.kernel.org/lkml/cover.1590785960.git.mhelsley@vmware.com/ ]

	This set is based on the patches sent upstream and posted above.

	Adapted to renames by Ingo and Peter: s/elf_open/elf_open_read/

	Added weak symbols for mcount subcommand
		This nicely eliminated the need for the mcount.h header.

	Added tools/objtool/Makefile per-arch SUBCMD_ blocks for each
		arch recordmcount / mcount supports.

	Moved ftrace/mcount/record.h from objtool_dep to recordmcount_dep
		This keeps the dependencies better organized.

	Fixed Makefile issue reported for PowerPC and a couple other archs
		by kbuild test robot. The always-$(BUILD_C_RECORDMCOUNT)
		line wasn't sufficiently replaced. Added to prepare-objtool
		target in top level Makefile.

	Split up dependencies to be independent of CONFIG_STACK_VALIDATION
		and CONFIG_UNWINDER_ORC since these are x86-specific.
		Now any arch which uses the C version of recordmcount
		will build objtool if dynamic tracing is enabled.

	Added a second rename at the end to be consistent with other
		objtool subcommands.

v3:
        Rebased on mainline. s/elf_open/elf_read/ in recordmcount.c

v2:
        Fix whitespace before line continuation

        Add ftrace/mcount/record.h to objtool_dep

        Rename the Makefile variable BUILD_C_RECORDMCOUNT to
            better reflect its purpose

        Similar: rename recordmcount_source => recordmcount_dep
            When using objtool we can just depend on the
            binary rather than the source the binary is
            built from. This should address Josh's feedback and
            make the Makefile code a bit clearer

        Add a comment to make reading the Makefile a little
            easier

        Rebased to latest mainline -rc


Matt Helsley (32):
  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 has_rel_mcount() and tot_relsize()
  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 endian wrappers
  objtool: mcount: Rename

 Documentation/dontdiff                     |   2 +-
 Documentation/trace/ftrace-design.rst      |   4 +-
 Documentation/trace/ftrace.rst             |   6 +-
 Makefile                                   |  24 +-
 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                     |  22 +-
 scripts/recordmcount.c                     | 663 --------------------
 scripts/recordmcount.h                     | 606 ------------------
 scripts/sorttable.h                        |   2 +-
 tools/objtool/.gitignore                   |   1 +
 tools/objtool/Build                        |   2 +
 tools/objtool/Makefile                     |  37 +-
 tools/objtool/builtin-mcount.c             |  50 ++
 tools/objtool/builtin.h                    |   2 +
 tools/objtool/elf.c                        |   5 +-
 tools/objtool/elf.h                        |   2 +
 tools/objtool/mcount.c                     | 682 +++++++++++++++++++++
 tools/objtool/objtool.c                    |   1 +
 tools/objtool/objtool.h                    |   1 +
 {scripts => tools/objtool}/recordmcount.pl |   0
 tools/objtool/weak.c                       |   5 +
 25 files changed, 821 insertions(+), 1304 deletions(-)
 delete mode 100644 scripts/recordmcount.c
 delete mode 100644 scripts/recordmcount.h
 create mode 100644 tools/objtool/builtin-mcount.c
 create mode 100644 tools/objtool/mcount.c
 rename {scripts => tools/objtool}/recordmcount.pl (100%)


base-commit: 2160e6958fc4fa0a70d5f8a2f32760c7ab3bfd6c
-- 
2.20.1


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

end of thread, other threads:[~2020-06-17 18:30 UTC | newest]

Thread overview: 49+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-02 19:49 [RFC][PATCH v4 00/32] objtool: Make recordmcount a subcommand Matt Helsley
2020-06-02 19:49 ` [RFC][PATCH v4 01/32] objtool: Prepare to merge recordmcount Matt Helsley
2020-06-09  8:54   ` Julien Thierry
2020-06-09 15:42     ` Matt Helsley
2020-06-09 19:31       ` Julien Thierry
2020-06-02 19:49 ` [RFC][PATCH v4 02/32] objtool: Make recordmcount into mcount subcmd Matt Helsley
2020-06-09  9:00   ` Julien Thierry
2020-06-09 18:39     ` Matt Helsley
2020-06-09 18:52       ` Steven Rostedt
2020-06-09 18:56         ` Matt Helsley
2020-06-09 19:11       ` Julien Thierry
2020-06-02 19:49 ` [RFC][PATCH v4 03/32] objtool: recordmcount: Start using objtool's elf wrapper Matt Helsley
2020-06-02 19:49 ` [RFC][PATCH v4 04/32] objtool: recordmcount: Search for __mcount_loc before walking the sections Matt Helsley
2020-06-02 19:49 ` [RFC][PATCH v4 05/32] objtool: recordmcount: Convert do_func() relhdrs Matt Helsley
2020-06-02 19:49 ` [RFC][PATCH v4 06/32] objtool: mcount: Remove unused fname parameter Matt Helsley
2020-06-02 19:50 ` [RFC][PATCH v4 07/32] objtool: mcount: Use libelf for section header names Matt Helsley
2020-06-02 19:50 ` [RFC][PATCH v4 08/32] objtool: mcount: Walk objtool Elf structs in find_secsym_ndx Matt Helsley
2020-06-02 19:50 ` [RFC][PATCH v4 09/32] objtool: mcount: Use symbol structs to find mcount relocations Matt Helsley
2020-06-02 19:50 ` [RFC][PATCH v4 10/32] objtool: mcount: Walk relocation lists Matt Helsley
2020-06-02 19:50 ` [RFC][PATCH v4 11/32] objtool: mcount: Move get_mcountsym Matt Helsley
2020-06-02 19:50 ` [RFC][PATCH v4 12/32] objtool: mcount: Replace MIPS offset types Matt Helsley
2020-06-02 19:50 ` [RFC][PATCH v4 13/32] objtool: mcount: Move is_fake_mcount() Matt Helsley
2020-06-02 19:50 ` [RFC][PATCH v4 14/32] objtool: mcount: Stop using ehdr in find_section_sym_index Matt Helsley
2020-06-02 19:50 ` [RFC][PATCH v4 15/32] objtool: mcount: Move find_section_sym_index() Matt Helsley
2020-06-02 19:50 ` [RFC][PATCH v4 16/32] objtool: mcount: Restrict using ehdr in append_func() Matt Helsley
2020-06-02 19:50 ` [RFC][PATCH v4 17/32] objtool: mcount: Use objtool ELF to write Matt Helsley
2020-06-02 19:50 ` [RFC][PATCH v4 18/32] objtool: mcount: Move nop_mcount() Matt Helsley
2020-06-12 13:26   ` Peter Zijlstra
2020-06-12 16:05     ` Peter Zijlstra
2020-06-17 17:36       ` Matt Helsley
2020-06-17 18:30         ` Peter Zijlstra
2020-06-13 19:49     ` Matt Helsley
2020-06-02 19:50 ` [RFC][PATCH v4 19/32] objtool: mcount: Move has_rel_mcount() and tot_relsize() Matt Helsley
2020-06-02 19:50 ` [RFC][PATCH v4 20/32] objtool: mcount: Move relocation entry size detection Matt Helsley
2020-06-02 19:50 ` [RFC][PATCH v4 21/32] objtool: mcount: Only keep ELF file size Matt Helsley
2020-06-02 19:50 ` [RFC][PATCH v4 22/32] objtool: mcount: Use ELF header from objtool Matt Helsley
2020-06-02 19:50 ` [RFC][PATCH v4 23/32] objtool: mcount: Remove unused file mapping Matt Helsley
2020-06-02 19:50 ` [RFC][PATCH v4 24/32] objtool: mcount: Reduce usage of _size wrapper Matt Helsley
2020-06-02 19:50 ` [RFC][PATCH v4 25/32] objtool: mcount: Move mcount_adjust out of wrapper Matt Helsley
2020-06-02 19:50 ` [RFC][PATCH v4 26/32] objtool: mcount: Pre-allocate new ELF sections Matt Helsley
2020-06-02 19:50 ` [RFC][PATCH v4 27/32] objtool: mcount: Generic location and relocation table types Matt Helsley
2020-06-09  6:41   ` Kamalesh Babulal
2020-06-09 18:12     ` Matt Helsley
2020-06-10  4:35       ` Kamalesh Babulal
2020-06-02 19:50 ` [RFC][PATCH v4 28/32] objtool: mcount: Move sift_rel_mcount out of wrapper file Matt Helsley
2020-06-02 19:50 ` [RFC][PATCH v4 29/32] objtool: mcount: Remove wrapper for ELF relocation type Matt Helsley
2020-06-02 19:50 ` [RFC][PATCH v4 30/32] objtool: mcount: Remove wrapper double-include trick Matt Helsley
2020-06-02 19:50 ` [RFC][PATCH v4 31/32] objtool: mcount: Remove endian wrappers Matt Helsley
2020-06-02 19:50 ` [RFC][PATCH v4 32/32] objtool: mcount: Rename Matt Helsley

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).