Merge tag 'objtool-urgent-2026-01-24' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip

Pull objtool fix from Ingo Molnar:
"Fix objtool build error in non-standard static library build
environments"

* tag 'objtool-urgent-2026-01-24' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
objtool: Fix libopcodes linking with static libraries

+17 -4
+17 -4
tools/objtool/Makefile
··· 77 77 # We check using HOSTCC directly rather than the shared feature framework 78 78 # because objtool is a host tool that links against host libraries. 79 79 # 80 - HAVE_LIBOPCODES := $(shell echo 'int main(void) { return 0; }' | \ 81 - $(HOSTCC) -xc - -o /dev/null -lopcodes 2>/dev/null && echo y) 80 + # When using shared libraries, -lopcodes is sufficient as dependencies are 81 + # resolved automatically. With static libraries, we must explicitly link 82 + # against libopcodes' dependencies: libbfd, libiberty, and sometimes libz. 83 + # Try each combination and use the first one that succeeds. 84 + # 85 + LIBOPCODES_LIBS := $(shell \ 86 + for libs in "-lopcodes" \ 87 + "-lopcodes -lbfd" \ 88 + "-lopcodes -lbfd -liberty" \ 89 + "-lopcodes -lbfd -liberty -lz"; do \ 90 + echo 'extern void disassemble_init_for_target(void *);' \ 91 + 'int main(void) { disassemble_init_for_target(0); return 0; }' | \ 92 + $(HOSTCC) -xc - -o /dev/null $$libs 2>/dev/null && \ 93 + echo "$$libs" && break; \ 94 + done) 82 95 83 96 # Styled disassembler support requires binutils >= 2.39 84 97 HAVE_DISASM_STYLED := $(shell echo '$(pound)include <dis-asm.h>' | \ ··· 99 86 100 87 BUILD_DISAS := n 101 88 102 - ifeq ($(HAVE_LIBOPCODES),y) 89 + ifneq ($(LIBOPCODES_LIBS),) 103 90 BUILD_DISAS := y 104 91 OBJTOOL_CFLAGS += -DDISAS -DPACKAGE='"objtool"' 105 - OBJTOOL_LDFLAGS += -lopcodes 92 + OBJTOOL_LDFLAGS += $(LIBOPCODES_LIBS) 106 93 ifeq ($(HAVE_DISASM_STYLED),y) 107 94 OBJTOOL_CFLAGS += -DDISASM_INIT_STYLED 108 95 endif