From patchwork Sat Feb 14 02:13:02 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1868 Return-Path: X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1771035249; bh=01n/hHASp0HatVX7X2ZnWQD2+Ab+U/DErqX83mEndQI=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=u1i7Q5xJJNskkxNCFTyzlUuOMp4hSEnGtHfvGTEhs0M2AiYaNOR9E5UTOFR6I7Gq+ KV5VXn1239ogqu0LLE+dtiVJqsbSCnXhAuMnKuysM8MciVvaVZ1hWHY8kx4R0BKTGL xeSvg6vQ8Bc94vh7bMTBB/EIUqO8NVpRjd/EfmNlo/l73PDiffV+aPeZJdLhpgQ0Hs J0te4+LhSWiDIz77l3sZCHRLDe3NWKO+ypzQSkThUZUqXkNWe4wPzs4FESVoiABr4N bWWcX1Er38+OcZMlpszxaR8BGd5u4CLmHzGmlq9kVvV7y901Tqp2LyAoJhK5rm7SFy 96kbl97cPfiCg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id B865869B5B for ; Fri, 13 Feb 2026 19:14:09 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id frccfVtA4JXF for ; Fri, 13 Feb 2026 19:14:09 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1771035249; bh=01n/hHASp0HatVX7X2ZnWQD2+Ab+U/DErqX83mEndQI=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=u1i7Q5xJJNskkxNCFTyzlUuOMp4hSEnGtHfvGTEhs0M2AiYaNOR9E5UTOFR6I7Gq+ KV5VXn1239ogqu0LLE+dtiVJqsbSCnXhAuMnKuysM8MciVvaVZ1hWHY8kx4R0BKTGL xeSvg6vQ8Bc94vh7bMTBB/EIUqO8NVpRjd/EfmNlo/l73PDiffV+aPeZJdLhpgQ0Hs J0te4+LhSWiDIz77l3sZCHRLDe3NWKO+ypzQSkThUZUqXkNWe4wPzs4FESVoiABr4N bWWcX1Er38+OcZMlpszxaR8BGd5u4CLmHzGmlq9kVvV7y901Tqp2LyAoJhK5rm7SFy 96kbl97cPfiCg== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id A73B469B58 for ; Fri, 13 Feb 2026 19:14:09 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1771035248; bh=mOmP1Et7UNIPWMSvQlQpB+5jjaRsrK6SDVwHGSfLIzw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=A4HoRCz9KPN/S5Xc8NoKDfz4UGCkKETtxqQJWwZyQAsTZRpXaKi0kEdqqvUmvcSuE 73puo4XksAr2lmA/orEfulkZSbo4333yybqor70Jb6n2nlL0/avKogg80rNAyiksro ggvFJwYaTEHiKNW9x1Hze+sS3np4a8a9zWH+8hQpjjoVxYh0rPUW0AFdO/PZohQ8r4 Vkyv+efBgF9l7PhJFltEOyk+xZas7t3iL95+zYCuFK453tlz2G5NfsZhuUqY+mBnV0 +7PTJiRNdhlZEIdKFlQB6XxBVpHc5VWAMKzsJkv7G8B/03eqcLR1UHj59/+fAYf9qM /vJxqRilGP89A== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 1E7A569B56; Fri, 13 Feb 2026 19:14:08 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id cMJu_tZ7QYr9; Fri, 13 Feb 2026 19:14:08 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1771035243; bh=W8hvo+Nb2SU9XH7WCQYOGbKaiNcQW/UocJ6Pu9CZ7HM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bFQ30BYBNj1Ut+rS3qjbZ9TRECcbvJoVAiOjhykEvrRnmU3KStvFYhqgkKD8UjsTz rCIcLa6RJhce3YnQ0PBNfz/g3QDG0AWXdiSdMDRsiyMviSCta0ov2oCvacYzgh1OGH dwJr/NnxcnarY5zQVutf9SR1I6ZsiNLPAwcO01BTYxpqal0am6anghhTqXvHfTTXJ+ y6LOAlxjN54PPlEYbukqZE6vCR1MBiTXPXXdqIhjz1Dbz5mU1GFnRwHf31xHE+uxGX yrkjVaDZq8OQDkidxEQ/rWfn/jBZ/f/9tJbGZz4bWYBzPMeiFBZ859BnT4M+sQBZrt P7Yu0bUPvZ/Mg== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 4A15D69A69; Fri, 13 Feb 2026 19:14:03 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Fri, 13 Feb 2026 19:13:02 -0700 Message-ID: <20260214021317.816170-9-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260214021317.816170-1-sjg@u-boot.org> References: <20260214021317.816170-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: 5ATQAK2GF66IDBBRUS7TBBY2VE4Y3ROR X-Message-ID-Hash: 5ATQAK2GF66IDBBRUS7TBBY2VE4Y3ROR X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Simon Glass , "Claude Opus 4 . 6" X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 08/13] Makefile: Extract u-boot-link helper for reuse List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass Factor the u-boot link command into a parameterised u-boot-link macro that accepts extra objects and a map-file path. The existing cmd_u-boot__ calls it with empty extra objects and u-boot.map, so behaviour is unchanged. This allows arch/x86 example builds to reuse the same link logic to produce binaries that override weak symbols in the main u-boot archive. Co-developed-by: Claude Opus 4.6 Signed-off-by: Simon Glass --- Makefile | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index 26ecf59a98a..e61e1c7fe94 100644 --- a/Makefile +++ b/Makefile @@ -1831,33 +1831,40 @@ endif # Rule to link u-boot # May be overridden by arch/$(ARCH)/config.mk +# +# u-boot-link is a parameterised helper shared with arch/x86 example builds: +# $(1) - extra objects to link alongside $(u-boot-init) (empty for u-boot) +# $(2) - map-file path ifeq ($(LTO_ENABLE),y) quiet_cmd_u-boot__ ?= LTO $@ - cmd_u-boot__ ?= \ +define u-boot-link touch $(u-boot-main) ; \ $(CC) -nostdlib -nostartfiles \ $(LTO_FINAL_LDFLAGS) $(c_flags) \ $(KBUILD_LDFLAGS:%=-Wl,%) $(LDFLAGS_u-boot:%=-Wl,%) -o $@ \ - -T u-boot.lds $(u-boot-init) \ + -T u-boot.lds $(u-boot-init) $(1) \ -Wl,--whole-archive \ $(u-boot-main) \ $(u-boot-keep-syms-lto) \ $(PLATFORM_LIBS) \ -Wl,--no-whole-archive \ - -Wl,-Map,u-boot.map; \ + -Wl,-Map,$(2); \ $(if $(ARCH_POSTLINK), $(MAKE) -f $(ARCH_POSTLINK) $@, true) +endef else quiet_cmd_u-boot__ ?= LD $@ - cmd_u-boot__ ?= \ +define u-boot-link touch $(u-boot-main) ; \ - $(LD) $(KBUILD_LDFLAGS) $(LDFLAGS_u-boot) -o $@ \ - -T u-boot.lds $(u-boot-init) \ + $(LD) $(KBUILD_LDFLAGS) $(LDFLAGS_u-boot) -o $@ \ + -T u-boot.lds $(u-boot-init) $(1) \ --whole-archive \ $(u-boot-main) \ --no-whole-archive \ - $(PLATFORM_LIBS) -Map u-boot.map; \ + $(PLATFORM_LIBS) -Map $(2); \ $(if $(ARCH_POSTLINK), $(MAKE) -f $(ARCH_POSTLINK) $@, true) +endef endif + cmd_u-boot__ ?= $(call u-boot-link,,u-boot.map) quiet_cmd_smap = GEN common/system_map.o cmd_smap = \