* Re: [RFC 03/13] objtool: Disassemble code with libopcodes instead of running objdump @ 2025-06-06 17:21 kernel test robot 0 siblings, 0 replies; 8+ messages in thread From: kernel test robot @ 2025-06-06 17:21 UTC (permalink / raw) To: oe-kbuild; +Cc: lkp :::::: :::::: Manual check reason: "only suspicious fbc files changed" :::::: BCC: lkp@intel.com CC: oe-kbuild-all@lists.linux.dev In-Reply-To: <20250606153440.865808-4-alexandre.chartre@oracle.com> References: <20250606153440.865808-4-alexandre.chartre@oracle.com> TO: Alexandre Chartre <alexandre.chartre@oracle.com> Hi Alexandre, [This is a private test report for your RFC patch.] kernel test robot noticed the following build errors: [auto build test ERROR on linus/master] [also build test ERROR on v6.15 next-20250606] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch#_base_tree_information] url: https://github.com/intel-lab-lkp/linux/commits/Alexandre-Chartre/objtool-Move-disassembly-functions-to-a-separated-file/20250606-233948 base: linus/master patch link: https://lore.kernel.org/r/20250606153440.865808-4-alexandre.chartre%40oracle.com patch subject: [RFC 03/13] objtool: Disassemble code with libopcodes instead of running objdump :::::: branch date: 2 hours ago :::::: commit date: 2 hours ago reproduce: (https://download.01.org/0day-ci/archive/20250607/202506070147.yRx7HyNf-lkp@intel.com/reproduce) If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags | Reported-by: kernel test robot <lkp@intel.com> | Closes: https://lore.kernel.org/r/202506070147.yRx7HyNf-lkp@intel.com/ All errors (new ones prefixed by >>): 1 error generated. make[2]: *** [scripts/Makefile.build:98: scripts/mod/devicetable-offsets.s] Error 1 make[2]: Target 'scripts/mod/' not remade because of errors. make[1]: *** [Makefile:1278: prepare0] Error 2 In file included from disas.c:12: >> tools/include/tools/dis-asm-compat.h:10:6: error: redefinition of 'disassembler_style' 10 | enum disassembler_style {DISASSEMBLER_STYLE_NOT_EMPTY}; | ^ /usr/include/dis-asm.h:53:6: note: previous definition is here 53 | enum disassembler_style | ^ In file included from disas.c:12: >> tools/include/tools/dis-asm-compat.h:51:23: error: too few arguments to function call, expected 4, have 3 50 | init_disassemble_info(info, stream, | ~~~~~~~~~~~~~~~~~~~~~ 51 | unstyled_func); | ^ /usr/include/dis-asm.h:480:13: note: 'init_disassemble_info' declared here vim +/disassembler_style +10 tools/include/tools/dis-asm-compat.h a45b3d6926231c Andres Freund 2022-07-31 7 a45b3d6926231c Andres Freund 2022-07-31 8 /* define types for older binutils version, to centralize ifdef'ery a bit */ a45b3d6926231c Andres Freund 2022-07-31 9 #ifndef DISASM_INIT_STYLED a45b3d6926231c Andres Freund 2022-07-31 @10 enum disassembler_style {DISASSEMBLER_STYLE_NOT_EMPTY}; a45b3d6926231c Andres Freund 2022-07-31 11 typedef int (*fprintf_styled_ftype) (void *, enum disassembler_style, const char*, ...); a45b3d6926231c Andres Freund 2022-07-31 12 #endif a45b3d6926231c Andres Freund 2022-07-31 13 a45b3d6926231c Andres Freund 2022-07-31 14 /* a45b3d6926231c Andres Freund 2022-07-31 15 * Trivial fprintf wrapper to be used as the fprintf_styled_func argument to a45b3d6926231c Andres Freund 2022-07-31 16 * init_disassemble_info_compat() when normal fprintf suffices. a45b3d6926231c Andres Freund 2022-07-31 17 */ a45b3d6926231c Andres Freund 2022-07-31 18 static inline int fprintf_styled(void *out, a45b3d6926231c Andres Freund 2022-07-31 19 enum disassembler_style style, a45b3d6926231c Andres Freund 2022-07-31 20 const char *fmt, ...) a45b3d6926231c Andres Freund 2022-07-31 21 { a45b3d6926231c Andres Freund 2022-07-31 22 va_list args; a45b3d6926231c Andres Freund 2022-07-31 23 int r; a45b3d6926231c Andres Freund 2022-07-31 24 a45b3d6926231c Andres Freund 2022-07-31 25 (void)style; a45b3d6926231c Andres Freund 2022-07-31 26 a45b3d6926231c Andres Freund 2022-07-31 27 va_start(args, fmt); a45b3d6926231c Andres Freund 2022-07-31 28 r = vfprintf(out, fmt, args); a45b3d6926231c Andres Freund 2022-07-31 29 va_end(args); a45b3d6926231c Andres Freund 2022-07-31 30 a45b3d6926231c Andres Freund 2022-07-31 31 return r; a45b3d6926231c Andres Freund 2022-07-31 32 } a45b3d6926231c Andres Freund 2022-07-31 33 a45b3d6926231c Andres Freund 2022-07-31 34 /* a45b3d6926231c Andres Freund 2022-07-31 35 * Wrapper for init_disassemble_info() that hides version a45b3d6926231c Andres Freund 2022-07-31 36 * differences. Depending on binutils version and architecture either a45b3d6926231c Andres Freund 2022-07-31 37 * fprintf_func or fprintf_styled_func will be called. a45b3d6926231c Andres Freund 2022-07-31 38 */ a45b3d6926231c Andres Freund 2022-07-31 39 static inline void init_disassemble_info_compat(struct disassemble_info *info, a45b3d6926231c Andres Freund 2022-07-31 40 void *stream, a45b3d6926231c Andres Freund 2022-07-31 41 fprintf_ftype unstyled_func, a45b3d6926231c Andres Freund 2022-07-31 42 fprintf_styled_ftype styled_func) a45b3d6926231c Andres Freund 2022-07-31 43 { a45b3d6926231c Andres Freund 2022-07-31 44 #ifdef DISASM_INIT_STYLED a45b3d6926231c Andres Freund 2022-07-31 45 init_disassemble_info(info, stream, a45b3d6926231c Andres Freund 2022-07-31 46 unstyled_func, a45b3d6926231c Andres Freund 2022-07-31 47 styled_func); a45b3d6926231c Andres Freund 2022-07-31 48 #else a45b3d6926231c Andres Freund 2022-07-31 49 (void)styled_func; a45b3d6926231c Andres Freund 2022-07-31 50 init_disassemble_info(info, stream, a45b3d6926231c Andres Freund 2022-07-31 @51 unstyled_func); a45b3d6926231c Andres Freund 2022-07-31 52 #endif a45b3d6926231c Andres Freund 2022-07-31 53 } a45b3d6926231c Andres Freund 2022-07-31 54 -- 0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [RFC 03/13] objtool: Disassemble code with libopcodes instead of running objdump @ 2025-06-07 7:20 kernel test robot 0 siblings, 0 replies; 8+ messages in thread From: kernel test robot @ 2025-06-07 7:20 UTC (permalink / raw) To: oe-kbuild; +Cc: lkp :::::: :::::: Manual check reason: "only suspicious fbc files changed" :::::: BCC: lkp@intel.com CC: oe-kbuild-all@lists.linux.dev In-Reply-To: <20250606153440.865808-4-alexandre.chartre@oracle.com> References: <20250606153440.865808-4-alexandre.chartre@oracle.com> TO: Alexandre Chartre <alexandre.chartre@oracle.com> Hi Alexandre, [This is a private test report for your RFC patch.] kernel test robot noticed the following build errors: [auto build test ERROR on linus/master] [also build test ERROR on v6.15 next-20250606] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch#_base_tree_information] url: https://github.com/intel-lab-lkp/linux/commits/Alexandre-Chartre/objtool-Move-disassembly-functions-to-a-separated-file/20250606-233948 base: linus/master patch link: https://lore.kernel.org/r/20250606153440.865808-4-alexandre.chartre%40oracle.com patch subject: [RFC 03/13] objtool: Disassemble code with libopcodes instead of running objdump :::::: branch date: 15 hours ago :::::: commit date: 15 hours ago config: powerpc-allnoconfig (https://download.01.org/0day-ci/archive/20250607/202506071438.NpC5O1aA-lkp@intel.com/config) compiler: powerpc-linux-gcc (GCC) 15.1.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250607/202506071438.NpC5O1aA-lkp@intel.com/reproduce) If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags | Reported-by: kernel test robot <lkp@intel.com> | Closes: https://lore.kernel.org/r/202506071438.NpC5O1aA-lkp@intel.com/ All error/warnings (new ones prefixed by >>): arch/powerpc/decode.c: In function 'arch_reloc_size': >> arch/powerpc/decode.c:131:5: warning: declaration of 'arch_disas_info_init' shadows a global declaration [-Wshadow] 131 | int arch_disas_info_init(struct disassemble_info *dinfo) | ^~~~~~~~~~~~~~~~~~~~ In file included from tools/objtool/include/objtool/check.h:11, from arch/powerpc/decode.c:5: tools/objtool/include/objtool/arch.h:107:5: note: shadowed declaration is here 107 | int arch_disas_info_init(struct disassemble_info *dinfo); | ^~~~~~~~~~~~~~~~~~~~ >> arch/powerpc/decode.c:131:1: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement] 131 | int arch_disas_info_init(struct disassemble_info *dinfo) | ^~~ >> arch/powerpc/decode.c:136:1: error: expected declaration or statement at end of input 136 | } | ^ arch/powerpc/decode.c: At top level: >> arch/powerpc/decode.c:131:5: warning: 'arch_disas_info_init' defined but not used [-Wunused-function] 131 | int arch_disas_info_init(struct disassemble_info *dinfo) | ^~~~~~~~~~~~~~~~~~~~ make[6]: *** [tools/build/Makefile.build:86: tools/objtool/arch/powerpc/decode.o] Error 1 In file included from disas.c:12: tools/include/tools/dis-asm-compat.h:10:6: error: redeclaration of 'enum disassembler_style' 10 | enum disassembler_style {DISASSEMBLER_STYLE_NOT_EMPTY}; | ^~~~~~~~~~~~~~~~~~ In file included from tools/objtool/include/objtool/arch.h:10, from disas.c:6: /usr/include/dis-asm.h:53:6: note: originally defined here 53 | enum disassembler_style | ^~~~~~~~~~~~~~~~~~ tools/include/tools/dis-asm-compat.h: In function 'init_disassemble_info_compat': tools/include/tools/dis-asm-compat.h:50:9: error: too few arguments to function 'init_disassemble_info' 50 | init_disassemble_info(info, stream, | ^~~~~~~~~~~~~~~~~~~~~ /usr/include/dis-asm.h:480:13: note: declared here 480 | extern void init_disassemble_info (struct disassemble_info *dinfo, void *stream, | ^~~~~~~~~~~~~~~~~~~~~ make[5]: *** [tools/build/Makefile.build:86: tools/objtool/disas.o] Error 1 make[6]: Target '__build' not remade because of errors. make[5]: *** [tools/build/Makefile.build:142: arch/powerpc] Error 2 make[5]: Target '__build' not remade because of errors. make[4]: *** [Makefile:65: tools/objtool/objtool-in.o] Error 2 make[4]: Target 'all' not remade because of errors. make[3]: *** [Makefile:73: objtool] Error 2 make[2]: *** [Makefile:1448: tools/objtool] Error 2 make[2]: Target 'prepare' not remade because of errors. make[1]: *** [Makefile:248: __sub-make] Error 2 make[1]: Target 'prepare' not remade because of errors. make: *** [Makefile:248: __sub-make] Error 2 make: Target 'prepare' not remade because of errors. -- 0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki ^ permalink raw reply [flat|nested] 8+ messages in thread
* [RFC 00/13] objtool: Function validation tracing
@ 2025-06-06 15:34 Alexandre Chartre
2025-06-06 15:34 ` [RFC 03/13] objtool: Disassemble code with libopcodes instead of running objdump Alexandre Chartre
0 siblings, 1 reply; 8+ messages in thread
From: Alexandre Chartre @ 2025-06-06 15:34 UTC (permalink / raw)
To: linux-kernel, mingo, jpoimboe, peterz; +Cc: alexandre.chartre
Hi,
This RFC provides two changes to objtool.
- Disassemble code with libopcodes instead of running objdump
objtool executes the objdump command to disassemble code. In particular,
if objtool fails to validate a function then it will use objdump to
disassemble the entire file which is not very helpful when processing
a large file (like vmlinux.o).
Using libopcodes provides more control about the disassembly scope and
output, and it is possible to disassemble a single instruction or
a single function. Now when objtool fails to validate a function it
will disassemble that single function instead of disassembling the
entire file.
- Add the --trace <function> option to trace function validation
Figuring out why a function validation has failed can be difficult because
objtool checks all code flows (including alternatives) and maintains
instructions states (in particular call frame information).
The trace option allows to follow the function validation done by objtool
instruction per instruction, see what objtool is doing and get function
validation information. An output example is shown below.
Note: some changes are architecture specific (x86, powerpc, loongarch). So far,
I have only tested on x86, and some code might be x86 specific. Any feedback
about the behavior on powerpc and loongarch is welcome.
Thanks,
alex.
-----
Example: Trace the validation of the os_save() function in vmlinux.o
$ ./tools/objtool/objtool --hacks=jump_label --hacks=noinstr --hacks=skylake --ibt --orc --retpoline --rethunk --sls --static-call --uaccess --prefix=16 --link --trace os_xsave -v vmlinux.o
os_xsave: validation begin
65c20: os_xsave+0x0 push %r12 - state: cfa=rsp+16 r12=(cfa-16) stack_size=16
65c22: os_xsave+0x2 mov 0x0(%rip),%eax # alternatives_patched
65c28: os_xsave+0x8 push %rbp - state: cfa=rsp+24 rbp=(cfa-24) stack_size=24
65c29: os_xsave+0x9 mov %rdi,%rbp
65c2c: os_xsave+0xc push %rbx - state: cfa=rsp+32 rbx=(cfa-32) stack_size=32
65c2d: os_xsave+0xd mov 0x8(%rdi),%rbx
65c31: os_xsave+0x11 mov %rbx,%r12
65c34: os_xsave+0x14 shr $0x20,%r12
65c38: os_xsave+0x18 test %eax,%eax
65c3a: os_xsave+0x1a je 65c6a <os_xsave+0x4a> - jump taken
65c6a: os_xsave+0x4a | ud2
65c6c: os_xsave+0x4c | jmp 65c3c <os_xsave+0x1c> - unconditional jump
65c3c: os_xsave+0x1c | xor %edx,%edx
65c3e: os_xsave+0x1e | mov %rbx,%rsi
65c41: os_xsave+0x21 | mov %rbp,%rdi
65c44: os_xsave+0x24 | callq xfd_validate_state - call
65c49: os_xsave+0x29 | mov %ebx,%eax
65c4b: os_xsave+0x2b | mov %r12d,%edx
65c4e: os_xsave+0x2e | <alternative.65c4e> alt 1/4 begin
65c55: os_xsave+0x35 | | test %ebx,%ebx
65c57: os_xsave+0x37 | | jne 65c6e <os_xsave+0x4e> - jump taken
65c6e: os_xsave+0x4e | | | ud2
65c70: os_xsave+0x50 | | | pop %rbx - state: cfa=rsp+24 rbx=<undef> stack_size=24
65c71: os_xsave+0x51 | | | pop %rbp - state: cfa=rsp+16 rbp=<undef> stack_size=16
65c72: os_xsave+0x52 | | | pop %r12 - state: cfa=rsp+8 r12=<undef> stack_size=8
65c74: os_xsave+0x54 | | | xor %eax,%eax
65c76: os_xsave+0x56 | | | xor %edx,%edx
65c78: os_xsave+0x58 | | | xor %esi,%esi
65c7a: os_xsave+0x5a | | | xor %edi,%edi
65c7c: os_xsave+0x5c | | | jmpq __x86_return_thunk - return
65c57: os_xsave+0x37 | | jne 65c6e <os_xsave+0x4e> - jump not taken
65c59: os_xsave+0x39 | | pop %rbx - state: cfa=rsp+24 rbx=<undef> stack_size=24
65c5a: os_xsave+0x3a | | pop %rbp - state: cfa=rsp+16 rbp=<undef> stack_size=16
65c5b: os_xsave+0x3b | | pop %r12 - state: cfa=rsp+8 r12=<undef> stack_size=8
65c5d: os_xsave+0x3d | | xor %eax,%eax
65c5f: os_xsave+0x3f | | xor %edx,%edx
65c61: os_xsave+0x41 | | xor %esi,%esi
65c63: os_xsave+0x43 | | xor %edi,%edi
65c65: os_xsave+0x45 | | jmpq __x86_return_thunk - return
| <alternative.65c4e> alt 1/4 end
65c4e: os_xsave+0x2e | <alternative.65c4e> alt 2/4 begin
1c3d: .altinstr_replacement+0x1c3d | | xsaves64 0x40(%rbp)
65c53: os_xsave+0x33 | | xor %ebx,%ebx
65c55: os_xsave+0x35 | | test %ebx,%ebx - already visited
| <alternative.65c4e> alt 2/4 end
65c4e: os_xsave+0x2e | <alternative.65c4e> alt 3/4 begin
1c38: .altinstr_replacement+0x1c38 | | xsavec64 0x40(%rbp)
65c53: os_xsave+0x33 | | xor %ebx,%ebx - already visited
| <alternative.65c4e> alt 3/4 end
65c4e: os_xsave+0x2e | <alternative.65c4e> alt 4/4 begin
1c33: .altinstr_replacement+0x1c33 | | xsaveopt64 0x40(%rbp)
65c53: os_xsave+0x33 | | xor %ebx,%ebx - already visited
| <alternative.65c4e> alt 4/4 end
65c4e: os_xsave+0x2e | <alternative.65c4e> alt default
65c4e: os_xsave+0x2e | xsave64 0x40(%rbp)
65c53: os_xsave+0x33 | xor %ebx,%ebx - already visited
65c3a: os_xsave+0x1a je 65c6a <os_xsave+0x4a> - jump not taken
65c3c: os_xsave+0x1c xor %edx,%edx - already visited
os_xsave: validation end
-----
Alexandre Chartre (13):
objtool: Move disassembly functions to a separated file
objtool: Create disassembly context
objtool: Disassemble code with libopcodes instead of running objdump
objtool: Print symbol during disassembly
objtool: Store instruction disassembly result
objtool: Disassemble instruction on warning or backtrace
objtool: Extract code to validate instruction from the validate branch
loop
objtool: Record symbol name max length
objtool: Add option to trace function validation
objtool: Trace instruction state changes during function validation
objtool: Improve register reporting during function validation
objtool: Improve tracing of alternative instructions
objtool: Do not validate IBT for .return_sites and .call_sites
tools/objtool/Build | 1 +
tools/objtool/Makefile | 2 +-
tools/objtool/arch/loongarch/decode.c | 17 +
tools/objtool/arch/powerpc/decode.c | 18 +
tools/objtool/arch/x86/decode.c | 15 +
tools/objtool/builtin-check.c | 1 +
tools/objtool/check.c | 829 ++++++++++++++++--------
tools/objtool/disas.c | 452 +++++++++++++
tools/objtool/include/objtool/arch.h | 7 +
tools/objtool/include/objtool/builtin.h | 1 +
tools/objtool/include/objtool/check.h | 29 +
tools/objtool/include/objtool/warn.h | 17 +-
12 files changed, 1122 insertions(+), 267 deletions(-)
create mode 100644 tools/objtool/disas.c
--
2.43.5
^ permalink raw reply [flat|nested] 8+ messages in thread* [RFC 03/13] objtool: Disassemble code with libopcodes instead of running objdump 2025-06-06 15:34 [RFC 00/13] objtool: Function validation tracing Alexandre Chartre @ 2025-06-06 15:34 ` Alexandre Chartre 2025-06-07 0:45 ` kernel test robot ` (2 more replies) 0 siblings, 3 replies; 8+ messages in thread From: Alexandre Chartre @ 2025-06-06 15:34 UTC (permalink / raw) To: linux-kernel, mingo, jpoimboe, peterz; +Cc: alexandre.chartre objtool executes the objdump command to disassemble code. Use libopcodes instead to have more control about the disassembly scope and output. Signed-off-by: Alexandre Chartre <alexandre.chartre@oracle.com> --- tools/objtool/Makefile | 2 +- tools/objtool/arch/loongarch/decode.c | 6 + tools/objtool/arch/powerpc/decode.c | 6 + tools/objtool/arch/x86/decode.c | 7 + tools/objtool/check.c | 4 +- tools/objtool/disas.c | 186 +++++++++++++++--------- tools/objtool/include/objtool/arch.h | 5 + tools/objtool/include/objtool/check.h | 5 + tools/objtool/include/objtool/objtool.h | 4 + 9 files changed, 154 insertions(+), 71 deletions(-) diff --git a/tools/objtool/Makefile b/tools/objtool/Makefile index 8c20361dd100..00350fc7c662 100644 --- a/tools/objtool/Makefile +++ b/tools/objtool/Makefile @@ -34,7 +34,7 @@ INCLUDES := -I$(srctree)/tools/include \ # is passed here to match a legacy behavior. WARNINGS := $(EXTRA_WARNINGS) -Wno-switch-default -Wno-switch-enum -Wno-packed -Wno-nested-externs OBJTOOL_CFLAGS := -Werror $(WARNINGS) $(KBUILD_HOSTCFLAGS) -g $(INCLUDES) $(LIBELF_FLAGS) -OBJTOOL_LDFLAGS := $(LIBELF_LIBS) $(LIBSUBCMD) $(KBUILD_HOSTLDFLAGS) +OBJTOOL_LDFLAGS := $(LIBELF_LIBS) $(LIBSUBCMD) $(KBUILD_HOSTLDFLAGS) -lopcodes # Allow old libelf to be used: elfshdr := $(shell echo '$(pound)include <libelf.h>' | $(HOSTCC) $(OBJTOOL_CFLAGS) -x c -E - 2>/dev/null | grep elf_getshdr) diff --git a/tools/objtool/arch/loongarch/decode.c b/tools/objtool/arch/loongarch/decode.c index b6fdc68053cc..bf5ac6750512 100644 --- a/tools/objtool/arch/loongarch/decode.c +++ b/tools/objtool/arch/loongarch/decode.c @@ -386,4 +386,10 @@ unsigned long arch_jump_table_sym_offset(struct reloc *reloc, struct reloc *tabl default: return reloc->sym->offset + reloc_addend(reloc); } + +int arch_disas_info_init(struct disassemble_info *dinfo) +{ + return disas_info_init(dinfo, bfd_arch_loongarch, + bfd_mach_loongarch32, bfd_mach_loongarch64, + NULL); } diff --git a/tools/objtool/arch/powerpc/decode.c b/tools/objtool/arch/powerpc/decode.c index c851c51d4bd3..c0fcab2d643c 100644 --- a/tools/objtool/arch/powerpc/decode.c +++ b/tools/objtool/arch/powerpc/decode.c @@ -127,4 +127,10 @@ unsigned int arch_reloc_size(struct reloc *reloc) default: return 8; } + +int arch_disas_info_init(struct disassemble_info *dinfo) +{ + return disas_info_init(dinfo, bfd_arch_powerpc, + bfd_mach_ppc, bfd_mach_ppc64, + NULL); } diff --git a/tools/objtool/arch/x86/decode.c b/tools/objtool/arch/x86/decode.c index 98c4713c1b09..6c13c67ed9b9 100644 --- a/tools/objtool/arch/x86/decode.c +++ b/tools/objtool/arch/x86/decode.c @@ -880,3 +880,10 @@ unsigned int arch_reloc_size(struct reloc *reloc) return 8; } } + +int arch_disas_info_init(struct disassemble_info *dinfo) +{ + return disas_info_init(dinfo, bfd_arch_i386, + bfd_mach_i386_i386, bfd_mach_x86_64, + "att"); +} diff --git a/tools/objtool/check.c b/tools/objtool/check.c index 085fcc1b643b..9cfac23185b8 100644 --- a/tools/objtool/check.c +++ b/tools/objtool/check.c @@ -4701,8 +4701,6 @@ int check(struct objtool_file *file) goto out; } - free_insns(file); - if (opts.stats) { printf("nr_insns_visited: %ld\n", nr_insns_visited); printf("nr_cfi: %ld\n", nr_cfi); @@ -4726,5 +4724,7 @@ int check(struct objtool_file *file) disas_context_destroy(disas_ctx); } + free_insns(file); + return ret; } diff --git a/tools/objtool/disas.c b/tools/objtool/disas.c index ed74554bccbf..f2eb1050ce11 100644 --- a/tools/objtool/disas.c +++ b/tools/objtool/disas.c @@ -4,17 +4,52 @@ */ #include <objtool/arch.h> +#include <objtool/check.h> #include <objtool/warn.h> +#include <bfd.h> #include <linux/string.h> +#include <tools/dis-asm-compat.h> struct disas_context { struct objtool_file *file; + disassembler_ftype disassembler; + struct disassemble_info info; }; +/* + * Initialize disassemble info arch, mach (32 or 64-bit) and options. + */ +int disas_info_init(struct disassemble_info *dinfo, + int arch, int mach32, int mach64, + const char *options) +{ + struct disas_context *dctx = dinfo->application_data; + struct objtool_file *file = dctx->file; + + dinfo->arch = arch; + + switch (file->elf->ehdr.e_ident[EI_CLASS]) { + case ELFCLASS32: + dinfo->mach = mach32; + break; + case ELFCLASS64: + dinfo->mach = mach64; + break; + default: + return -1; + } + + dinfo->disassembler_options = options; + + return 0; +} + struct disas_context *disas_context_create(struct objtool_file *file) { struct disas_context *dctx; + struct disassemble_info *dinfo; + int err; dctx = malloc(sizeof(*dctx)); if (!dctx) { @@ -23,8 +58,49 @@ struct disas_context *disas_context_create(struct objtool_file *file) } dctx->file = file; + dinfo = &dctx->info; + + init_disassemble_info_compat(dinfo, stdout, + (fprintf_ftype)fprintf, + fprintf_styled); + + dinfo->read_memory_func = buffer_read_memory; + dinfo->application_data = dctx; + + /* + * bfd_openr() is not used to avoid doing ELF data processing + * and caching that has already being done. Here, we just need + * to identify the target file so we call an arch specific + * function to fill some disassemble info (arch, mach). + */ + + dinfo->arch = bfd_arch_unknown; + dinfo->mach = 0; + + err = arch_disas_info_init(dinfo); + if (err || dinfo->arch == bfd_arch_unknown || dinfo->mach == 0) { + WARN("failed to init disassembly arch\n"); + goto error; + } + + dinfo->endian = (file->elf->ehdr.e_ident[EI_DATA] == ELFDATA2MSB) ? + BFD_ENDIAN_BIG : BFD_ENDIAN_LITTLE; + + disassemble_init_for_target(dinfo); + + dctx->disassembler = disassembler(dinfo->arch, + dinfo->endian == BFD_ENDIAN_BIG, + dinfo->mach, NULL); + if (!dctx->disassembler) { + WARN("failed to create disassembler function\n"); + goto error; + } return dctx; + +error: + free(dctx); + return NULL; } void disas_context_destroy(struct disas_context *dctx) @@ -32,60 +108,54 @@ void disas_context_destroy(struct disas_context *dctx) free(dctx); } -/* 'funcs' is a space-separated list of function names */ -static void disas_funcs(const char *funcs) +/* + * Disassemble a single instruction. Return the size of the instruction. + */ +static size_t disas_insn(struct disas_context *dctx, + struct instruction *insn) { - const char *objdump_str, *cross_compile; - int size, ret; - char *cmd; - - cross_compile = getenv("CROSS_COMPILE"); - if (!cross_compile) - cross_compile = ""; - - objdump_str = "%sobjdump -wdr %s | gawk -M -v _funcs='%s' '" - "BEGIN { split(_funcs, funcs); }" - "/^$/ { func_match = 0; }" - "/<.*>:/ { " - "f = gensub(/.*<(.*)>:/, \"\\\\1\", 1);" - "for (i in funcs) {" - "if (funcs[i] == f) {" - "func_match = 1;" - "base = strtonum(\"0x\" $1);" - "break;" - "}" - "}" - "}" - "{" - "if (func_match) {" - "addr = strtonum(\"0x\" $1);" - "printf(\"%%04x \", addr - base);" - "print;" - "}" - "}' 1>&2"; - - /* fake snprintf() to calculate the size */ - size = snprintf(NULL, 0, objdump_str, cross_compile, objname, funcs) + 1; - if (size <= 0) { - WARN("objdump string size calculation failed"); - return; - } - - cmd = malloc(size); + disassembler_ftype disasm = dctx->disassembler; + struct disassemble_info *dinfo = &dctx->info; + + /* + * Set the disassembler buffer to read data from the section + * containing the instruction to disassemble. + */ + dinfo->buffer = insn->sec->data->d_buf; + dinfo->buffer_vma = 0; + dinfo->buffer_length = insn->sec->sh.sh_size; + + return disasm(insn->offset, &dctx->info); +} - /* real snprintf() */ - snprintf(cmd, size, objdump_str, cross_compile, objname, funcs); - ret = system(cmd); - if (ret) { - WARN("disassembly failed: %d", ret); - return; +/* + * Disassemble a function. + */ +static void disas_func(struct disas_context *dctx, struct symbol *func) +{ + struct instruction *insn; + size_t addr, size; + + printf("%s:\n", func->name); + sym_for_each_insn(dctx->file, func, insn) { + + addr = insn->offset; + printf(" %6lx: %s+0x%-6lx ", + addr, func->name, addr - func->offset); + size = disas_insn(dctx, insn); + printf("\n"); + if (size != insn->len) + WARN("inconsistent insn size (%ld and %d)\n", size, insn->len); } + printf("\n"); } +/* + * Disassemble all warned functions. + */ void disas_warned_funcs(struct disas_context *dctx) { struct symbol *sym; - char *funcs = NULL, *tmp; if (!dctx) { ERROR("disassembly context is not defined"); @@ -93,27 +163,7 @@ void disas_warned_funcs(struct disas_context *dctx) } for_each_sym(dctx->file, sym) { - if (sym->warned) { - if (!funcs) { - funcs = malloc(strlen(sym->name) + 1); - if (!funcs) { - ERROR_GLIBC("malloc"); - return; - } - strcpy(funcs, sym->name); - } else { - tmp = malloc(strlen(funcs) + strlen(sym->name) + 2); - if (!tmp) { - ERROR_GLIBC("malloc"); - return; - } - sprintf(tmp, "%s %s", funcs, sym->name); - free(funcs); - funcs = tmp; - } - } + if (sym->warned) + disas_func(dctx, sym); } - - if (funcs) - disas_funcs(funcs); } diff --git a/tools/objtool/include/objtool/arch.h b/tools/objtool/include/objtool/arch.h index 01ef6f415adf..aecf8fc29571 100644 --- a/tools/objtool/include/objtool/arch.h +++ b/tools/objtool/include/objtool/arch.h @@ -6,6 +6,8 @@ #ifndef _ARCH_H #define _ARCH_H +#include <bfd.h> +#include <dis-asm.h> #include <stdbool.h> #include <linux/list.h> #include <objtool/objtool.h> @@ -98,7 +100,10 @@ int arch_rewrite_retpolines(struct objtool_file *file); bool arch_pc_relative_reloc(struct reloc *reloc); + unsigned int arch_reloc_size(struct reloc *reloc); unsigned long arch_jump_table_sym_offset(struct reloc *reloc, struct reloc *table); +int arch_disas_info_init(struct disassemble_info *dinfo); + #endif /* _ARCH_H */ diff --git a/tools/objtool/include/objtool/check.h b/tools/objtool/include/objtool/check.h index 00fb745e7233..5290ac1ebbc1 100644 --- a/tools/objtool/include/objtool/check.h +++ b/tools/objtool/include/objtool/check.h @@ -125,4 +125,9 @@ struct instruction *next_insn_same_sec(struct objtool_file *file, struct instruc insn && insn->sec == _sec; \ insn = next_insn_same_sec(file, insn)) +#define sym_for_each_insn(file, sym, insn) \ + for (insn = find_insn(file, sym->sec, sym->offset); \ + insn && insn->offset < sym->offset + sym->len; \ + insn = next_insn_same_sec(file, insn)) + #endif /* _CHECK_H */ diff --git a/tools/objtool/include/objtool/objtool.h b/tools/objtool/include/objtool/objtool.h index f5ab71f07f5c..0b404cfd81c0 100644 --- a/tools/objtool/include/objtool/objtool.h +++ b/tools/objtool/include/objtool/objtool.h @@ -48,8 +48,12 @@ int orc_dump(const char *objname); int orc_create(struct objtool_file *file); struct disas_context; +struct disassemble_info; struct disas_context *disas_context_create(struct objtool_file *file); void disas_context_destroy(struct disas_context *dctx); void disas_warned_funcs(struct disas_context *dctx); +int disas_info_init(struct disassemble_info *dinfo, + int arch, int mach32, int mach64, + const char *options); #endif /* _OBJTOOL_H */ -- 2.43.5 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [RFC 03/13] objtool: Disassemble code with libopcodes instead of running objdump 2025-06-06 15:34 ` [RFC 03/13] objtool: Disassemble code with libopcodes instead of running objdump Alexandre Chartre @ 2025-06-07 0:45 ` kernel test robot 2025-06-10 21:22 ` Josh Poimboeuf 2025-06-11 12:23 ` Peter Zijlstra 2 siblings, 0 replies; 8+ messages in thread From: kernel test robot @ 2025-06-07 0:45 UTC (permalink / raw) To: Alexandre Chartre; +Cc: oe-kbuild-all Hi Alexandre, [This is a private test report for your RFC patch.] kernel test robot noticed the following build errors: [auto build test ERROR on linus/master] [also build test ERROR on v6.15 next-20250606] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch#_base_tree_information] url: https://github.com/intel-lab-lkp/linux/commits/Alexandre-Chartre/objtool-Move-disassembly-functions-to-a-separated-file/20250606-233948 base: linus/master patch link: https://lore.kernel.org/r/20250606153440.865808-4-alexandre.chartre%40oracle.com patch subject: [RFC 03/13] objtool: Disassemble code with libopcodes instead of running objdump :::::: branch date: 2 hours ago :::::: commit date: 2 hours ago reproduce: (https://download.01.org/0day-ci/archive/20250607/202506070147.yRx7HyNf-lkp@intel.com/reproduce) If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags | Reported-by: kernel test robot <lkp@intel.com> | Closes: https://lore.kernel.org/r/202506070147.yRx7HyNf-lkp@intel.com/ All errors (new ones prefixed by >>): 1 error generated. make[2]: *** [scripts/Makefile.build:98: scripts/mod/devicetable-offsets.s] Error 1 make[2]: Target 'scripts/mod/' not remade because of errors. make[1]: *** [Makefile:1278: prepare0] Error 2 In file included from disas.c:12: >> tools/include/tools/dis-asm-compat.h:10:6: error: redefinition of 'disassembler_style' 10 | enum disassembler_style {DISASSEMBLER_STYLE_NOT_EMPTY}; | ^ /usr/include/dis-asm.h:53:6: note: previous definition is here 53 | enum disassembler_style | ^ In file included from disas.c:12: >> tools/include/tools/dis-asm-compat.h:51:23: error: too few arguments to function call, expected 4, have 3 50 | init_disassemble_info(info, stream, | ~~~~~~~~~~~~~~~~~~~~~ 51 | unstyled_func); | ^ /usr/include/dis-asm.h:480:13: note: 'init_disassemble_info' declared here vim +/disassembler_style +10 tools/include/tools/dis-asm-compat.h a45b3d6926231c Andres Freund 2022-07-31 7 a45b3d6926231c Andres Freund 2022-07-31 8 /* define types for older binutils version, to centralize ifdef'ery a bit */ a45b3d6926231c Andres Freund 2022-07-31 9 #ifndef DISASM_INIT_STYLED a45b3d6926231c Andres Freund 2022-07-31 @10 enum disassembler_style {DISASSEMBLER_STYLE_NOT_EMPTY}; a45b3d6926231c Andres Freund 2022-07-31 11 typedef int (*fprintf_styled_ftype) (void *, enum disassembler_style, const char*, ...); a45b3d6926231c Andres Freund 2022-07-31 12 #endif a45b3d6926231c Andres Freund 2022-07-31 13 a45b3d6926231c Andres Freund 2022-07-31 14 /* a45b3d6926231c Andres Freund 2022-07-31 15 * Trivial fprintf wrapper to be used as the fprintf_styled_func argument to a45b3d6926231c Andres Freund 2022-07-31 16 * init_disassemble_info_compat() when normal fprintf suffices. a45b3d6926231c Andres Freund 2022-07-31 17 */ a45b3d6926231c Andres Freund 2022-07-31 18 static inline int fprintf_styled(void *out, a45b3d6926231c Andres Freund 2022-07-31 19 enum disassembler_style style, a45b3d6926231c Andres Freund 2022-07-31 20 const char *fmt, ...) a45b3d6926231c Andres Freund 2022-07-31 21 { a45b3d6926231c Andres Freund 2022-07-31 22 va_list args; a45b3d6926231c Andres Freund 2022-07-31 23 int r; a45b3d6926231c Andres Freund 2022-07-31 24 a45b3d6926231c Andres Freund 2022-07-31 25 (void)style; a45b3d6926231c Andres Freund 2022-07-31 26 a45b3d6926231c Andres Freund 2022-07-31 27 va_start(args, fmt); a45b3d6926231c Andres Freund 2022-07-31 28 r = vfprintf(out, fmt, args); a45b3d6926231c Andres Freund 2022-07-31 29 va_end(args); a45b3d6926231c Andres Freund 2022-07-31 30 a45b3d6926231c Andres Freund 2022-07-31 31 return r; a45b3d6926231c Andres Freund 2022-07-31 32 } a45b3d6926231c Andres Freund 2022-07-31 33 a45b3d6926231c Andres Freund 2022-07-31 34 /* a45b3d6926231c Andres Freund 2022-07-31 35 * Wrapper for init_disassemble_info() that hides version a45b3d6926231c Andres Freund 2022-07-31 36 * differences. Depending on binutils version and architecture either a45b3d6926231c Andres Freund 2022-07-31 37 * fprintf_func or fprintf_styled_func will be called. a45b3d6926231c Andres Freund 2022-07-31 38 */ a45b3d6926231c Andres Freund 2022-07-31 39 static inline void init_disassemble_info_compat(struct disassemble_info *info, a45b3d6926231c Andres Freund 2022-07-31 40 void *stream, a45b3d6926231c Andres Freund 2022-07-31 41 fprintf_ftype unstyled_func, a45b3d6926231c Andres Freund 2022-07-31 42 fprintf_styled_ftype styled_func) a45b3d6926231c Andres Freund 2022-07-31 43 { a45b3d6926231c Andres Freund 2022-07-31 44 #ifdef DISASM_INIT_STYLED a45b3d6926231c Andres Freund 2022-07-31 45 init_disassemble_info(info, stream, a45b3d6926231c Andres Freund 2022-07-31 46 unstyled_func, a45b3d6926231c Andres Freund 2022-07-31 47 styled_func); a45b3d6926231c Andres Freund 2022-07-31 48 #else a45b3d6926231c Andres Freund 2022-07-31 49 (void)styled_func; a45b3d6926231c Andres Freund 2022-07-31 50 init_disassemble_info(info, stream, a45b3d6926231c Andres Freund 2022-07-31 @51 unstyled_func); a45b3d6926231c Andres Freund 2022-07-31 52 #endif a45b3d6926231c Andres Freund 2022-07-31 53 } a45b3d6926231c Andres Freund 2022-07-31 54 -- 0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [RFC 03/13] objtool: Disassemble code with libopcodes instead of running objdump 2025-06-06 15:34 ` [RFC 03/13] objtool: Disassemble code with libopcodes instead of running objdump Alexandre Chartre 2025-06-07 0:45 ` kernel test robot @ 2025-06-10 21:22 ` Josh Poimboeuf 2025-06-11 12:23 ` Peter Zijlstra 2 siblings, 0 replies; 8+ messages in thread From: Josh Poimboeuf @ 2025-06-10 21:22 UTC (permalink / raw) To: Alexandre Chartre; +Cc: linux-kernel, mingo, peterz On Fri, Jun 06, 2025 at 05:34:30PM +0200, Alexandre Chartre wrote: > + dctx->disassembler = disassembler(dinfo->arch, > + dinfo->endian == BFD_ENDIAN_BIG, > + dinfo->mach, NULL); These lines should be aligned like: dctx->disassembler = disassembler(dinfo->arch, dinfo->endian == BFD_ENDIAN_BIG, dinfo->mach, NULL); -- Josh ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [RFC 03/13] objtool: Disassemble code with libopcodes instead of running objdump 2025-06-06 15:34 ` [RFC 03/13] objtool: Disassemble code with libopcodes instead of running objdump Alexandre Chartre 2025-06-07 0:45 ` kernel test robot 2025-06-10 21:22 ` Josh Poimboeuf @ 2025-06-11 12:23 ` Peter Zijlstra 2025-06-11 13:35 ` Alexandre Chartre 2 siblings, 1 reply; 8+ messages in thread From: Peter Zijlstra @ 2025-06-11 12:23 UTC (permalink / raw) To: Alexandre Chartre; +Cc: linux-kernel, mingo, jpoimboe On Fri, Jun 06, 2025 at 05:34:30PM +0200, Alexandre Chartre wrote: > objtool executes the objdump command to disassemble code. Use libopcodes > instead to have more control about the disassembly scope and output. > > Signed-off-by: Alexandre Chartre <alexandre.chartre@oracle.com> > --- > tools/objtool/Makefile | 2 +- > tools/objtool/arch/loongarch/decode.c | 6 + > tools/objtool/arch/powerpc/decode.c | 6 + > tools/objtool/arch/x86/decode.c | 7 + > tools/objtool/check.c | 4 +- > tools/objtool/disas.c | 186 +++++++++++++++--------- > tools/objtool/include/objtool/arch.h | 5 + > tools/objtool/include/objtool/check.h | 5 + > tools/objtool/include/objtool/objtool.h | 4 + > 9 files changed, 154 insertions(+), 71 deletions(-) > > diff --git a/tools/objtool/Makefile b/tools/objtool/Makefile > index 8c20361dd100..00350fc7c662 100644 > --- a/tools/objtool/Makefile > +++ b/tools/objtool/Makefile > @@ -34,7 +34,7 @@ INCLUDES := -I$(srctree)/tools/include \ > # is passed here to match a legacy behavior. > WARNINGS := $(EXTRA_WARNINGS) -Wno-switch-default -Wno-switch-enum -Wno-packed -Wno-nested-externs > OBJTOOL_CFLAGS := -Werror $(WARNINGS) $(KBUILD_HOSTCFLAGS) -g $(INCLUDES) $(LIBELF_FLAGS) > -OBJTOOL_LDFLAGS := $(LIBELF_LIBS) $(LIBSUBCMD) $(KBUILD_HOSTLDFLAGS) > +OBJTOOL_LDFLAGS := $(LIBELF_LIBS) $(LIBSUBCMD) $(KBUILD_HOSTLDFLAGS) -lopcodes Would it be possible to make this optional? Such that when people do not have libopcodes installed they can still build the kernel. Or is libopcodes a mandatory part of any binutils installation? ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [RFC 03/13] objtool: Disassemble code with libopcodes instead of running objdump 2025-06-11 12:23 ` Peter Zijlstra @ 2025-06-11 13:35 ` Alexandre Chartre 2025-06-11 19:25 ` Josh Poimboeuf 0 siblings, 1 reply; 8+ messages in thread From: Alexandre Chartre @ 2025-06-11 13:35 UTC (permalink / raw) To: Peter Zijlstra; +Cc: alexandre.chartre, linux-kernel, mingo, jpoimboe On 6/11/25 14:23, Peter Zijlstra wrote: > On Fri, Jun 06, 2025 at 05:34:30PM +0200, Alexandre Chartre wrote: >> objtool executes the objdump command to disassemble code. Use libopcodes >> instead to have more control about the disassembly scope and output. >> >> Signed-off-by: Alexandre Chartre <alexandre.chartre@oracle.com> >> --- >> tools/objtool/Makefile | 2 +- >> tools/objtool/arch/loongarch/decode.c | 6 + >> tools/objtool/arch/powerpc/decode.c | 6 + >> tools/objtool/arch/x86/decode.c | 7 + >> tools/objtool/check.c | 4 +- >> tools/objtool/disas.c | 186 +++++++++++++++--------- >> tools/objtool/include/objtool/arch.h | 5 + >> tools/objtool/include/objtool/check.h | 5 + >> tools/objtool/include/objtool/objtool.h | 4 + >> 9 files changed, 154 insertions(+), 71 deletions(-) >> >> diff --git a/tools/objtool/Makefile b/tools/objtool/Makefile >> index 8c20361dd100..00350fc7c662 100644 >> --- a/tools/objtool/Makefile >> +++ b/tools/objtool/Makefile >> @@ -34,7 +34,7 @@ INCLUDES := -I$(srctree)/tools/include \ >> # is passed here to match a legacy behavior. >> WARNINGS := $(EXTRA_WARNINGS) -Wno-switch-default -Wno-switch-enum -Wno-packed -Wno-nested-externs >> OBJTOOL_CFLAGS := -Werror $(WARNINGS) $(KBUILD_HOSTCFLAGS) -g $(INCLUDES) $(LIBELF_FLAGS) >> -OBJTOOL_LDFLAGS := $(LIBELF_LIBS) $(LIBSUBCMD) $(KBUILD_HOSTLDFLAGS) >> +OBJTOOL_LDFLAGS := $(LIBELF_LIBS) $(LIBSUBCMD) $(KBUILD_HOSTLDFLAGS) -lopcodes > > Would it be possible to make this optional? Such that when people do not > have libopcodes installed they can still build the kernel. > > Or is libopcodes a mandatory part of any binutils installation? I guess that libopcodes is mandatory because it is used by as (and also objdump). But I can check if it is effectively present anyway. alex. ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [RFC 03/13] objtool: Disassemble code with libopcodes instead of running objdump 2025-06-11 13:35 ` Alexandre Chartre @ 2025-06-11 19:25 ` Josh Poimboeuf 0 siblings, 0 replies; 8+ messages in thread From: Josh Poimboeuf @ 2025-06-11 19:25 UTC (permalink / raw) To: Alexandre Chartre; +Cc: Peter Zijlstra, linux-kernel, mingo On Wed, Jun 11, 2025 at 03:35:38PM +0200, Alexandre Chartre wrote: > > On 6/11/25 14:23, Peter Zijlstra wrote: > > On Fri, Jun 06, 2025 at 05:34:30PM +0200, Alexandre Chartre wrote: > > > objtool executes the objdump command to disassemble code. Use libopcodes > > > instead to have more control about the disassembly scope and output. > > > > > > Signed-off-by: Alexandre Chartre <alexandre.chartre@oracle.com> > > > --- > > > tools/objtool/Makefile | 2 +- > > > tools/objtool/arch/loongarch/decode.c | 6 + > > > tools/objtool/arch/powerpc/decode.c | 6 + > > > tools/objtool/arch/x86/decode.c | 7 + > > > tools/objtool/check.c | 4 +- > > > tools/objtool/disas.c | 186 +++++++++++++++--------- > > > tools/objtool/include/objtool/arch.h | 5 + > > > tools/objtool/include/objtool/check.h | 5 + > > > tools/objtool/include/objtool/objtool.h | 4 + > > > 9 files changed, 154 insertions(+), 71 deletions(-) > > > > > > diff --git a/tools/objtool/Makefile b/tools/objtool/Makefile > > > index 8c20361dd100..00350fc7c662 100644 > > > --- a/tools/objtool/Makefile > > > +++ b/tools/objtool/Makefile > > > @@ -34,7 +34,7 @@ INCLUDES := -I$(srctree)/tools/include \ > > > # is passed here to match a legacy behavior. > > > WARNINGS := $(EXTRA_WARNINGS) -Wno-switch-default -Wno-switch-enum -Wno-packed -Wno-nested-externs > > > OBJTOOL_CFLAGS := -Werror $(WARNINGS) $(KBUILD_HOSTCFLAGS) -g $(INCLUDES) $(LIBELF_FLAGS) > > > -OBJTOOL_LDFLAGS := $(LIBELF_LIBS) $(LIBSUBCMD) $(KBUILD_HOSTLDFLAGS) > > > +OBJTOOL_LDFLAGS := $(LIBELF_LIBS) $(LIBSUBCMD) $(KBUILD_HOSTLDFLAGS) -lopcodes > > > > Would it be possible to make this optional? Such that when people do not > > have libopcodes installed they can still build the kernel. > > > > Or is libopcodes a mandatory part of any binutils installation? > > I guess that libopcodes is mandatory because it is used by as (and also objdump). > But I can check if it is effectively present anyway. libopcodes should always be present, but compiling/linking against it shouldn't be possible unless a binutils devel pkg is installed. So I think Peter's basically asking for what I asked for: make all this optional depending on whether the binutils devel pkg is installed, and print a helpful error message if somebody tries to use without. -- Josh ^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2025-06-11 19:25 UTC | newest] Thread overview: 8+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2025-06-06 17:21 [RFC 03/13] objtool: Disassemble code with libopcodes instead of running objdump kernel test robot -- strict thread matches above, loose matches on Subject: below -- 2025-06-07 7:20 kernel test robot 2025-06-06 15:34 [RFC 00/13] objtool: Function validation tracing Alexandre Chartre 2025-06-06 15:34 ` [RFC 03/13] objtool: Disassemble code with libopcodes instead of running objdump Alexandre Chartre 2025-06-07 0:45 ` kernel test robot 2025-06-10 21:22 ` Josh Poimboeuf 2025-06-11 12:23 ` Peter Zijlstra 2025-06-11 13:35 ` Alexandre Chartre 2025-06-11 19:25 ` Josh Poimboeuf
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.