From nobody Sun Feb 8 15:46:31 2026 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D139E329C6B; Wed, 21 Jan 2026 19:28:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769023731; cv=none; b=be3MwqbZby06ww0NlY029JlS8q+oj9eP7hD5fKEQJQYlE537oK8Dz49Bgqz/ZuzqLsjY3lqs4a7VzGW3wBiBzX6GmZ1xmav8wapK2myZg2gPOvg2EBwLThUtbzaVpP0aI6ORAB2iqXhM0tNyhjwLyg+9Gw7+tabVZ2vIGa2VpDo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769023731; c=relaxed/simple; bh=vDtu4tsLJJpKLdshx8lbIt2iCEza4vEkjFSvBsqLbJw=; h=Date:From:To:Subject:Cc:In-Reply-To:References:MIME-Version: Message-ID:Content-Type; b=AT5ygEFik6h0+25PkSg/VePDyA5dPjNmQClvJcNyaTN8gVuFIg54uAk3oqnyM3flHX4ESFlkuJoc0sS5NbTgbEubOz/k7anSVSbgCPmqo3Etl/xD8i5t923wd39Oy9/c48Nt/CuILsGq8TBygnUI0OZskDCyjmTCSy1sBRWfWFA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=HFBR4KbH; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=6ksH8C/k; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="HFBR4KbH"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="6ksH8C/k" Date: Wed, 21 Jan 2026 19:28:40 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1769023722; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=GhUHOIwKOIGQ7e/rhpCLnh1g+lS0qeOrqVRWyJWHR/Y=; b=HFBR4KbHTftyiHtd+tytDx+FV/BcElwPoN/eZKgbbPxVEe+rP5I/sqh/FRyxQ3H7LRNjyz +9/3AVKUlnMQk/1CvllOs/mUrdpzY/fM2QLW/siima8JSlAIfIH3uSGRpEjEjo5wvd8UBE 4O/JzcmcVNlHuE7TogbYs+cOQUpllskA2IDqQcyDu6IABoPjHgfshM7KszacfBVTKV9yKm gz9rXHh+WVAUH23zePM1ImOeSjfRYRgNFW44pbVJiX1qJruEygrhRzf0B5Pm8xnJi8NaJ1 VSy9OpyskzCLwwoAjQiiVpl+NnuDEUsg/eQ9lyv9sfthg2B0W5U7k1cfRQyz4A== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1769023722; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=GhUHOIwKOIGQ7e/rhpCLnh1g+lS0qeOrqVRWyJWHR/Y=; b=6ksH8C/k5gdmYZxj4Szrh0vcCW30xI0wX22E6TClZIYghvlfw79oCRW2EP8kMT0cqmUb7U eVNtw3eJ0oOTyTBQ== From: "tip-bot2 for Sasha Levin" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: objtool/urgent] objtool: Fix libopcodes linking with static libraries Cc: "Rafael J. Wysocki" , Sasha Levin , "Peter Zijlstra (Intel)" , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20260121162532.1596238-1-sashal@kernel.org> References: <20260121162532.1596238-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <176902372065.510.12809888165013587029.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Precedence: bulk Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable The following commit has been merged into the objtool/urgent branch of tip: Commit-ID: 3f2de814c0597c97d5abe09a1635d8c4e2fddaf2 Gitweb: https://git.kernel.org/tip/3f2de814c0597c97d5abe09a1635d8c4e= 2fddaf2 Author: Sasha Levin AuthorDate: Wed, 21 Jan 2026 11:25:32 -05:00 Committer: Peter Zijlstra CommitterDate: Wed, 21 Jan 2026 20:25:14 +01:00 objtool: Fix libopcodes linking with static libraries Commit 436326bc525d ("objtool: fix build failure due to missing libopcodes check") tests for libopcodes using an empty main(), which passes even when static libraries lack their dependencies. This causes undefined reference errors (xmalloc, bfd_get_bits, etc.) when linking against static libopcodes without its required libbfd and libiberty. Fix by testing with an actual libopcodes symbol and trying increasingly complete library combinations until one succeeds. Fixes: 436326bc525d ("objtool: fix build failure due to missing libopcodes = check") Reported-by: Rafael J. Wysocki Signed-off-by: Sasha Levin Signed-off-by: Peter Zijlstra (Intel) Tested-by: Rafael J. Wysocki (Intel) Link: https://patch.msgid.link/20260121162532.1596238-1-sashal@kernel.org --- tools/objtool/Makefile | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/tools/objtool/Makefile b/tools/objtool/Makefile index 9b45031..a40f302 100644 --- a/tools/objtool/Makefile +++ b/tools/objtool/Makefile @@ -77,8 +77,21 @@ HOST_OVERRIDES :=3D CC=3D"$(HOSTCC)" LD=3D"$(HOSTLD)" AR= =3D"$(HOSTAR)" # We check using HOSTCC directly rather than the shared feature framework # because objtool is a host tool that links against host libraries. # -HAVE_LIBOPCODES :=3D $(shell echo 'int main(void) { return 0; }' | \ - $(HOSTCC) -xc - -o /dev/null -lopcodes 2>/dev/null && echo y) +# 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 :=3D $(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) =20 # Styled disassembler support requires binutils >=3D 2.39 HAVE_DISASM_STYLED :=3D $(shell echo '$(pound)include ' | \ @@ -86,10 +99,10 @@ HAVE_DISASM_STYLED :=3D $(shell echo '$(pound)include <= dis-asm.h>' | \ =20 BUILD_DISAS :=3D n =20 -ifeq ($(HAVE_LIBOPCODES),y) +ifneq ($(LIBOPCODES_LIBS),) BUILD_DISAS :=3D y OBJTOOL_CFLAGS +=3D -DDISAS -DPACKAGE=3D'"objtool"' - OBJTOOL_LDFLAGS +=3D -lopcodes + OBJTOOL_LDFLAGS +=3D $(LIBOPCODES_LIBS) ifeq ($(HAVE_DISASM_STYLED),y) OBJTOOL_CFLAGS +=3D -DDISASM_INIT_STYLED endif