diff options
| author | Dave Airlie <airlied@redhat.com> | 2026-01-28 12:44:28 +1000 |
|---|---|---|
| committer | Dave Airlie <airlied@redhat.com> | 2026-01-28 12:44:28 +1000 |
| commit | 6704d98a4f48b7424edc0f7ae2a06c0a8af02e2f (patch) | |
| tree | 261ac2fddcd79f6b66568a613ee458260f5cc62c /tools/objtool/Makefile | |
| parent | 504f3cead6b04914c53831f9efce902b8d91c009 (diff) | |
| parent | 63804fed149a6750ffd28610c5c1c98cce6bd377 (diff) | |
| download | linux-next-6704d98a4f48b7424edc0f7ae2a06c0a8af02e2f.tar.gz linux-next-6704d98a4f48b7424edc0f7ae2a06c0a8af02e2f.zip | |
BackMerge tag 'v6.19-rc7' into drm-next
Linux 6.19-rc7
This is needed for msm and rust trees.
Signed-off-by: Dave Airlie <airlied@redhat.com>
Diffstat (limited to 'tools/objtool/Makefile')
| -rw-r--r-- | tools/objtool/Makefile | 41 |
1 files changed, 29 insertions, 12 deletions
diff --git a/tools/objtool/Makefile b/tools/objtool/Makefile index ad6e1ec706ce..a40f30232929 100644 --- a/tools/objtool/Makefile +++ b/tools/objtool/Makefile @@ -72,23 +72,40 @@ HOST_OVERRIDES := CC="$(HOSTCC)" LD="$(HOSTLD)" AR="$(HOSTAR)" # # To support disassembly, objtool needs libopcodes which is provided -# with libbdf (binutils-dev or binutils-devel package). +# with libbfd (binutils-dev or binutils-devel package). # -FEATURE_USER = .objtool -FEATURE_TESTS = libbfd disassembler-init-styled -FEATURE_DISPLAY = -include $(srctree)/tools/build/Makefile.feature - -ifeq ($(feature-disassembler-init-styled), 1) - OBJTOOL_CFLAGS += -DDISASM_INIT_STYLED -endif +# We check using HOSTCC directly rather than the shared feature framework +# because objtool is a host tool that links against host libraries. +# +# When using shared libraries, -lopcodes is sufficient as dependencies are +# resolved automatically. With static libraries, we must explicitly link +# against libopcodes' dependencies: libbfd, libiberty, and sometimes libz. +# Try each combination and use the first one that succeeds. +# +LIBOPCODES_LIBS := $(shell \ + for libs in "-lopcodes" \ + "-lopcodes -lbfd" \ + "-lopcodes -lbfd -liberty" \ + "-lopcodes -lbfd -liberty -lz"; do \ + echo 'extern void disassemble_init_for_target(void *);' \ + 'int main(void) { disassemble_init_for_target(0); return 0; }' | \ + $(HOSTCC) -xc - -o /dev/null $$libs 2>/dev/null && \ + echo "$$libs" && break; \ + done) + +# Styled disassembler support requires binutils >= 2.39 +HAVE_DISASM_STYLED := $(shell echo '$(pound)include <dis-asm.h>' | \ + $(HOSTCC) -E -xc - 2>/dev/null | grep -q disassembler_style && echo y) BUILD_DISAS := n -ifeq ($(feature-libbfd),1) +ifneq ($(LIBOPCODES_LIBS),) BUILD_DISAS := y - OBJTOOL_CFLAGS += -DDISAS -DPACKAGE="objtool" - OBJTOOL_LDFLAGS += -lopcodes + OBJTOOL_CFLAGS += -DDISAS -DPACKAGE='"objtool"' + OBJTOOL_LDFLAGS += $(LIBOPCODES_LIBS) +ifeq ($(HAVE_DISASM_STYLED),y) + OBJTOOL_CFLAGS += -DDISASM_INIT_STYLED +endif endif export BUILD_DISAS |
