Skip to content

objtool: Interface overhaul

Josh Poimboeuf lkml xen-devel 2 versions – Applied

Status from this message: The following commit has been merged into the x86/urgent branch of tip:

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest25 patches 18 repliesApplied
  2. v118 patches 22 repliesSuperseded

Changes in v2 from the cover letter

- extricate sls
- fix ibt regressions in v1
- fix issues found by improved ibt logic
- split '--hacks' into two
- add objdump-func script
- remove "()" in function address strings
- add '--sec-address' option
- add '--link'

Patches in v2 Applied

#Subject and filesSizeRepliesApplied
1/25objtool: Enable unreachable warnings for CLANG LTOscripts/Makefile.build scripts/link-vmlinux.sh+2 -20 replies
2/25libsubcmd: Fix OPTION_GROUP sortingtools/lib/subcmd/parse-options.c+14 -30 replies
3/25x86/static_call: Add ANNOTATE_NOENDBR to static call trampolinearch/x86/include/asm/static_call.h+1 -00 replies
4/25x86/retpoline: Add ANNOTATE_ENDBR for retpolinesarch/x86/lib/retpoline.S+1 -10 replies
5/25x86/uaccess: Add ENDBR to __put_user_nocheck*()arch/x86/lib/putuser.S+4 -00 replies
6/25x86/xen: Add ANNOTATE_ENDBR to startup_xen()arch/x86/xen/xen-head.S+1 -06 replies
7/25objtool: Reorganize cmdline optionsscripts/Makefile.build scripts/link-vmlinux.sh tools/objtool/arch/x86/decode.c +6 more+108 -780 replies
8/25objtool: Ditch subcommandsscripts/Makefile.build scripts/link-vmlinux.sh tools/objtool/Build +7 more+72 -2110 replies
9/25objtool: Don't print parentheses in function addressestools/objtool/include/objtool/warn.h+1 -50 replies
10/25objtool: Print data address for "!ENDBR" data warningstools/objtool/check.c+2 -50 replies
11/25objtool: Use offstr() to print address of missing ENDBRtools/objtool/check.c+2 -30 replies
12/25objtool: Add option to print section addressestools/objtool/builtin-check.c tools/objtool/include/objtool/builtin.h tools/objtool/include/objtool/warn.h+19 -140 replies
13/25scripts: Create objdump-func helper scriptscripts/objdump-func+18 -02 replies
14/25objtool: Make stack validation optionalscripts/Makefile.build scripts/link-vmlinux.sh tools/objtool/builtin-check.c +2 more+23 -130 replies
15/25objtool: Rework ibt and extricate from stack validationtools/objtool/check.c+147 -1334 replies
16/25objtool: Extricate sls from stack validationtools/objtool/check.c+43 -130 replies
17/25objtool: Add CONFIG_OBJTOOLMakefile arch/Kconfig arch/x86/Kconfig +14 more+73 -571 reply
18/25objtool: Make stack validation frame-pointer-specificscripts/Makefile.build scripts/link-vmlinux.sh tools/objtool/builtin-check.c +2 more+3 -100 replies
19/25objtool: Make static call annotation optionalscripts/Makefile.build scripts/link-vmlinux.sh tools/objtool/builtin-check.c +2 more+14 -50 replies
20/25objtool: Make jump label hack optionalarch/Kconfig arch/x86/Kconfig arch/x86/include/asm/jump_label.h +5 more+44 -120 replies
21/25objtool: Make noinstr hacks optionalarch/Kconfig arch/x86/Kconfig lib/Kconfig.debug +6 more+23 -60 replies
22/25objtool: Rename "VMLINUX_VALIDATION" -> "NOINSTR_VALIDATION"include/linux/instrumentation.h lib/Kconfig.debug scripts/link-vmlinux.sh+5 -50 replies
23/25objtool: Add HAVE_NOINSTR_VALIDATIONarch/Kconfig arch/x86/Kconfig lib/Kconfig.debug+5 -10 replies
24/25objtool: Remove --lto and --vmlinux in favor of --linkscripts/Makefile.build scripts/link-vmlinux.sh tools/objtool/builtin-check.c +4 more+70 -391 reply
25/25objtool: Update documentationtools/objtool/Documentation/objtool.txt+102 -200 replies

Reviews trailers per patch

2 of 25 patches have a Reviewed-by or Acked-by of their own; the series has one for all of them.

PatchPeter ZijlstraLai JiangshanKees CookAndrew CooperMiroslav Benes
SeriesR-b
1/25
2/25
3/25
4/25
5/25
6/25R-b R-b
7/25
8/25
9/25
10/25
11/25
12/25
13/25Originally-by
14/25
15/25
16/25
17/25R-b R-b
18/25
19/25
20/25
21/25
22/25
23/25
24/25
25/25

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 5 reviewers.

Read the v2 thread

Cover letter [PATCH v2 00/25] objtool: Interface overhaul

v2:
- extricate sls
- fix ibt regressions in v1
- fix issues found by improved ibt logic
- split '--hacks' into two
- add objdump-func script
- remove "()" in function address strings
- add '--sec-address' option
- add '--link'

Objtool's interface has some issues:

- Several features are done unconditionally, without any way to turn them off. Some of them might be surprising. This makes objtool tricky to use, and prevents porting individual features to other arches.

- The config dependencies are too coarse-grained. Objtool enablement is tied to CONFIG_STACK_VALIDATION, but it has several other features independent of that.

- The objtool subcmds ("check" and "orc") are clumsy: "check" is really a subset of "orc", so it has all the same options. The subcmd model has never really worked for objtool, as it only has a single purpose:
"do some combination of things on an object file".

- The '--lto' and '--vmlinux' options are nonsensical and have surprising behavior.

Overhaul the interface:

- get rid of subcmds

- make all features individually selectable

- remove and/or clarify confusing/obsolete options

- update the documentation

- fix some bugs found along the way

TODO: rename files...

$ tools/objtool/objtool --help

Usage: objtool <actions> [<options>] file.o

Actions:

    -h, --hacks[=<jump_label,noinstr>]
                          patch toolchain bugs/limitations
    -i, --ibt             validate and annotate IBT
    -l, --sls             validate straight-line-speculation mitigations
    -m, --mcount          annotate mcount/fentry calls for ftrace
    -n, --noinstr         validate noinstr rules
    -o, --orc             generate ORC metadata
    -r, --retpoline       validate and annotate retpoline usage
    -s, --stackval        validate frame pointer rules
    -t, --static-call     annotate static calls
    -u, --uaccess         validate uaccess rules for SMAP
        --dump[=<orc>]    dump metadata

Options:

        --backtrace       unwind on error
        --backup          create .orig files before modification
        --dry-run         don't write modifications
        --link            object is a linked object
        --module          object is part of a kernel module
        --no-unreachable  skip 'unreachable instruction' warnings
        --sec-address     print section addresses in warnings
        --stats           print statistics

Josh Poimboeuf (25):
objtool: Enable unreachable warnings for CLANG LTO
libsubcmd: Fix OPTION_GROUP sorting
x86/static_call: Add ANNOTATE_NOENDBR to static call trampoline x86/retpoline: Add ANNOTATE_ENDBR for retpolines x86/uaccess: Add ENDBR to __put_user_nocheck*() x86/xen: Add ANNOTATE_ENDBR to startup_xen()
objtool: Reorganize cmdline options
objtool: Ditch subcommands
objtool: Don't print parentheses in function addresses
objtool: Print data address for "!ENDBR" data warnings
objtool: Use offstr() to print address of missing ENDBR
objtool: Add option to print section addresses
scripts: Create objdump-func helper script
objtool: Make stack validation optional
objtool: Rework ibt and extricate from stack validation
objtool: Extricate sls from stack validation
objtool: Add CONFIG_OBJTOOL
objtool: Make stack validation frame-pointer-specific
objtool: Make static call annotation optional
objtool: Make jump label hack optional
objtool: Make noinstr hacks optional
objtool: Rename "VMLINUX_VALIDATION" -> "NOINSTR_VALIDATION"
objtool: Add HAVE_NOINSTR_VALIDATION
objtool: Remove --lto and --vmlinux in favor of --link
objtool: Update documentation

 Makefile                                      |   2 +-
 arch/Kconfig                                  |  18 +-
 arch/x86/Kconfig                              |  21 +-
 arch/x86/Kconfig.debug                        |   2 +-
 arch/x86/include/asm/jump_label.h             |   6 +-
 arch/x86/include/asm/static_call.h            |   1 +
 arch/x86/kernel/alternative.c                 |   6 +-
 arch/x86/lib/putuser.S                        |   4 +
 arch/x86/lib/retpoline.S                      |   2 +-
 arch/x86/xen/xen-head.S                       |   1 +
 include/linux/compiler.h                      |   6 +-
 include/linux/instrumentation.h               |   6 +-
 include/linux/objtool.h                       |   6 +-
 kernel/trace/Kconfig                          |   1 +
 lib/Kconfig.debug                             |  22 +-
 lib/Kconfig.kcsan                             |   4 +-
 lib/Kconfig.ubsan                             |   2 +-
 scripts/Makefile.build                        |  23 +-
 scripts/link-vmlinux.sh                       |  66 ++-
 scripts/objdump-func                          |  18 +
 scripts/package/builddeb                      |   2 +-
 tools/include/linux/objtool.h                 |   6 +-
 tools/lib/subcmd/parse-options.c              |  17 +-
 tools/objtool/Build                           |  12 +-
 .../{stack-validation.txt => objtool.txt}     | 122 ++++-
 tools/objtool/Makefile                        |   8 +-
 tools/objtool/arch/x86/decode.c               |   2 +-
 tools/objtool/arch/x86/special.c              |   2 +-
 tools/objtool/builtin-check.c                 | 156 ++++--
 tools/objtool/builtin-orc.c                   |  73 ---
 tools/objtool/check.c                         | 456 ++++++++++--------
 tools/objtool/elf.c                           |  11 +-
 tools/objtool/include/objtool/builtin.h       |  34 +-
 tools/objtool/include/objtool/elf.h           |  12 +-
 tools/objtool/include/objtool/warn.h          |  35 +-
 tools/objtool/objtool.c                       | 103 +---
 tools/objtool/weak.c                          |   9 +-
 37 files changed, 719 insertions(+), 558 deletions(-)
 create mode 100755 scripts/objdump-func
 rename tools/objtool/Documentation/{stack-validation.txt => objtool.txt} (80%)
 delete mode 100644 tools/objtool/builtin-orc.c
Signature · 1 line
2.34.1