From patchwork Thu Sep 4 13:04:42 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 223 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=1756991149; bh=kbMcDyIyCJOXnDFmVLo5V3v0s6DdUOMGQFZNv40EfPQ=; 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=CfKD5MtiSD7l3kAZE5I5R4jiCXyRtWNutRPjjsxDYC3Fiq/cSJbMr5LXiL/zIYa8Y nCX9mt22KEwJ9Egp2kNaSBzcEmeE3502j3XOngYZHAFU9JxTL/HWXzcQDrqyQBfxj5 WfhCgvZiYsYLE+mMOMOh+1mwXXOmMVCya33IyatPJqhRyX6jkfb2+I4giMJtFGknhA J+tsWvkUVbq51BulHUCgfbYO2uyLk6W4VW/Qsq2RKTcuPdXWMnV5DR1Szcxe6aD0Ng kStaqXOjmAl2XRpyywEMTZfeFbxtTQUq8oFmabeVjhbwtPa6NbcdOc0wv5mztLBTdB ys2ldmxaBrBgw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id E2305678AB for ; Thu, 4 Sep 2025 07:05:49 -0600 (MDT) 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 ROAsanRdsV7M for ; Thu, 4 Sep 2025 07:05:49 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756991149; bh=kbMcDyIyCJOXnDFmVLo5V3v0s6DdUOMGQFZNv40EfPQ=; 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=CfKD5MtiSD7l3kAZE5I5R4jiCXyRtWNutRPjjsxDYC3Fiq/cSJbMr5LXiL/zIYa8Y nCX9mt22KEwJ9Egp2kNaSBzcEmeE3502j3XOngYZHAFU9JxTL/HWXzcQDrqyQBfxj5 WfhCgvZiYsYLE+mMOMOh+1mwXXOmMVCya33IyatPJqhRyX6jkfb2+I4giMJtFGknhA J+tsWvkUVbq51BulHUCgfbYO2uyLk6W4VW/Qsq2RKTcuPdXWMnV5DR1Szcxe6aD0Ng kStaqXOjmAl2XRpyywEMTZfeFbxtTQUq8oFmabeVjhbwtPa6NbcdOc0wv5mztLBTdB ys2ldmxaBrBgw== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id D182E6795C for ; Thu, 4 Sep 2025 07:05:49 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756991148; bh=ssgkzgv/lt/r3KfOkakxkj/5uLFdTw0APAUtfHf3sFg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hzeUJKG9S+gLzkVhCVgs2YxDprn3h6N7Sg2ZQUdXNnkGCxxKApkObVIgXXmwBbwg2 qYY98wD4IRP1/Jtg2Rc/owQuDGbXYksn2QSS6pEm8RW52ZF7FXuw0/3hYMP9iVnnUk UbRvrme3+gWfR6UHI3p8HNKx7GcX9pEGzez5v6EyjP7ZfVs6oku1ciBL2g/rVIvFGQ ZtzcUso9WId6OOqsbim7ILgqHMCEPu5SzwjNK5nhkhGr1KF64SNslxhqfJ+VCTfrcm pxAeB5aB2DijNdKQIGTFZdQBucw+sj+nev3p6P3itfVfKHI9VH81HEcYIbiuK0OZaR m+Kag0MHGLG4A== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 4D4F2678AB; Thu, 4 Sep 2025 07:05:48 -0600 (MDT) 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 bSXBnLc7TaZl; Thu, 4 Sep 2025 07:05:48 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756991143; bh=DziHy7HaedevMpvZM8YVh7WqMuNK/eQCWN+M1/LT/AQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FNZDbw4diWneCIAyFDHfBWDOF1Jf7pX6xx5UPtNUQPoUr0BMcTFG7OB6PXRiPYg6N Ys5eknF96yG4h/ydc5jMkp3TDnVsMWiflt2tRSD40VcaCsywKO+IiPTTJZ9ByzBKYm IzCdIcY4+iRifcImTSVlHls9PZ0ioru5/LHqC2NKxVWHLCLRm/V6osGl2O4fYui4W7 hRSsE0zSZre77PiyjkhKI4QVMeE4+ALHIBxY6Pa/Gj8g1GLwYUgK7qGhG96SsY18Ot 3nJvL6y7epkmLHPFxkj++8QzSmSapE/hXWnyDRzwnQsS1BLvXDPM4bMhaxBhk8hivL BxjZ7wXXJyV1A== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id AC499678BF; Thu, 4 Sep 2025 07:05:43 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Thu, 4 Sep 2025 07:04:42 -0600 Message-ID: <20250904130459.848794-10-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250904130459.848794-1-sjg@u-boot.org> References: <20250904130459.848794-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: PUOMPN3L6I5KMVUVAZPFBS4O2NZ7BVRA X-Message-ID-Hash: PUOMPN3L6I5KMVUVAZPFBS4O2NZ7BVRA 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: Heinrich Schuchardt , Simon Glass X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 09/18] ulib: Support building U-Boot as a shared library 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 Provide a rule which creates a libu-boot.so file which can be used to provide some of U-Boot's functionality to another program. Move the RISCV up a line so it is clear that it relates to the u-boot target. For now this is not very useful, as everything is bound together, and U-Boot will just start normally when the library is used (including waiting for the user to type commands!). Further work will improve this over time. Signed-off-by: Simon Glass --- Makefile | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index fb4358b1753..c4f3065d2e6 100644 --- a/Makefile +++ b/Makefile @@ -1043,6 +1043,8 @@ INPUTS-$(CONFIG_X86) += u-boot-x86-start16.bin u-boot-x86-reset16.bin \ $(if $(CONFIG_SPL_X86_16BIT_INIT),spl/u-boot-spl.bin) \ $(if $(CONFIG_TPL_X86_16BIT_INIT),tpl/u-boot-tpl.bin) +INPUTS-$(CONFIG_ULIB) += libu-boot.so + LDFLAGS_u-boot += $(LDFLAGS_FINAL) # Avoid 'Not enough room for program headers' error on binutils 2.28 onwards. @@ -1843,11 +1845,24 @@ ifeq ($(CONFIG_KALLSYMS),y) $(call cmd,u-boot__) common/system_map.o endif $(call cmd,llcheck,u-boot) - ifeq ($(CONFIG_RISCV),y) @tools/prelink-riscv $@ endif +# Build U-Boot as a shared library +quiet_cmd_libu-boot.so = LD $@ + cmd_libu-boot.so = $(CC) -shared -o $@ -Wl,--build-id=none \ + $(u-boot-init) \ + $(KBUILD_LDFLAGS:%=-Wl,%) $(SANITIZERS) $(LTO_FINAL_LDFLAGS) \ + -Wl,--whole-archive \ + $(filter-out %/main.o,$(u-boot-main)) \ + $(u-boot-keep-syms-lto) \ + -Wl,--no-whole-archive \ + $(PLATFORM_LIBS) -Wl,-Map -Wl,libu-boot.map + +libu-boot.so: $(u-boot-init) $(u-boot-main) $(u-boot-keep-syms-lto) FORCE + $(call if_changed,libu-boot.so) + quiet_cmd_sym ?= SYM $@ cmd_sym ?= $(OBJDUMP) -t $< > $@ u-boot.sym: u-boot FORCE