From patchwork Thu Sep 4 13:04:43 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 224 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=1756991154; bh=smdIMHRaV/cITYEf06tsTp0w7r0o4X2wKehERfwff3A=; 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=bsTeeQRhQ1Rp/ugfOjErpcM4/6qqraPxJSbiW1MHLu9IMtezra4yKz8yKCRjhQ8NU ed1hA313Bm0BDU9HuuPGkGH/JSyhwij55hFokNyP52O4llXer25fL8mY4Mh1IMGLr+ EWxpphukz/nrNoh0lI1LqKJwEXbxqqAi/QfBFv1GnxcMQsIoSqs08JePd988ehC8j3 XkK9Pqo3R8jemfWwUcCEtDpqCtiXUcGOTX2cq5yyEz/8DVis0CLBMaD7TlXIsw7crO KkevaBJl+9k3otEKpkQgBYDJzL5GeoF/ZDrLWkqmT3lD1npgF+wrHHmCkGM5MfjFe1 DQ0FZKGU0LsnQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 363D267961 for ; Thu, 4 Sep 2025 07:05:54 -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 T2GMpIo6ZL2S for ; Thu, 4 Sep 2025 07:05:54 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756991154; bh=smdIMHRaV/cITYEf06tsTp0w7r0o4X2wKehERfwff3A=; 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=bsTeeQRhQ1Rp/ugfOjErpcM4/6qqraPxJSbiW1MHLu9IMtezra4yKz8yKCRjhQ8NU ed1hA313Bm0BDU9HuuPGkGH/JSyhwij55hFokNyP52O4llXer25fL8mY4Mh1IMGLr+ EWxpphukz/nrNoh0lI1LqKJwEXbxqqAi/QfBFv1GnxcMQsIoSqs08JePd988ehC8j3 XkK9Pqo3R8jemfWwUcCEtDpqCtiXUcGOTX2cq5yyEz/8DVis0CLBMaD7TlXIsw7crO KkevaBJl+9k3otEKpkQgBYDJzL5GeoF/ZDrLWkqmT3lD1npgF+wrHHmCkGM5MfjFe1 DQ0FZKGU0LsnQ== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 26B42678C8 for ; Thu, 4 Sep 2025 07:05:54 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756991152; bh=AMdqxMPwnRadzfGYC8pKMNHHsmTNBi7Y/W5weKwQo+I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YjWQO30zqjJq5UQBs4K5X9zNDJWiu/OZvEXCnfcDknSXrd/tHy5Xn14GjhXbtCdBQ yAjUzkynHKV4axJdzS0VMqyMMIfKhTfKE0y7OcFCnZDSWFsikfTH2D3RYVwPM7Kbv0 TqCg5E3lRo45NmoN590ZdkxSf/1zjKvHimmnYG2igDk597V2RPXOB7xI11BJP713Q9 xeeG2FtUMPBNymjaPrR96fyCKfRzNnEGDjsY/Re9UmLhaztztPoN73I7fJfb0F+4Tg foMGezItoB4+1uihAJ9LPObZtuiJlj3Rr/J5k70PA1DGReowRQePl/YYEgy/J2EyE3 fr6TyT2JAn7rA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id B5506678AB; Thu, 4 Sep 2025 07:05:52 -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 qZUKImB232p2; Thu, 4 Sep 2025 07:05:52 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756991148; bh=79ZJyLHrtOaJZMLlmo7Q8ElwrNQ4FRHaqeZS0P/YYcw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qg0fBETiw4DLpjpugt481n62DRsBNSBcFquWM6c4VJ86jXcPzrnd7fKR56wWv2sXq bdI92na0jukMau96kI6iUm6j2NA6GiRfAliJRxpaHc8Tw8wkngBP0FaH952Dgm3fvd vlh1qoSI4/DX3WYOyQrBO0mVB7pqgsqhr9SSB+0Q7LMiWKX5uDFLvCXqubTmMvaOtH BuG9wvWB/aeW60Smn3W4o0CzM0MtZ0LBSlS1FKXX/LXmo6ih9zURLSoLhU85sWpFgV Pz+cQ/YuaKgKkgThzbDr1y+ClTkfcFSNlEPBGbdt/JOXHpAXFnwcsLrQhAWSCyCzoe E8wN/f+xoO+BA== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 944A6678BF; Thu, 4 Sep 2025 07:05:48 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Thu, 4 Sep 2025 07:04:43 -0600 Message-ID: <20250904130459.848794-11-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: SMNVYXSVJCUB3EFCCRT4UK2UCCYDNGLO X-Message-ID-Hash: SMNVYXSVJCUB3EFCCRT4UK2UCCYDNGLO 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 10/18] ulib: Create a test program for the 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 host program which can use the shared library. For now this operates similarly to sandbox itself, but future work will make it more flexible. Leave it out of the build, since there are a few other pieces needed. Signed-off-by: Simon Glass --- Makefile | 9 +++++++++ test/ulib/Makefile | 12 ++++++++++++ test/ulib/ulib_test.c | 36 ++++++++++++++++++++++++++++++++++++ 3 files changed, 57 insertions(+) create mode 100644 test/ulib/Makefile create mode 100644 test/ulib/ulib_test.c diff --git a/Makefile b/Makefile index c4f3065d2e6..a0a9ce3196b 100644 --- a/Makefile +++ b/Makefile @@ -1863,6 +1863,15 @@ quiet_cmd_libu-boot.so = LD $@ libu-boot.so: $(u-boot-init) $(u-boot-main) $(u-boot-keep-syms-lto) FORCE $(call if_changed,libu-boot.so) +# Build ulib_test that links with shared library +quiet_cmd_ulib_test = HOSTCC $@ + cmd_ulib_test = $(HOSTCC) $(HOSTCFLAGS) \ + -I$(srctree)/arch/sandbox/include -o $@ $< -L$(obj) -lu-boot \ + -Wl,-rpath,$(obj) + +test/ulib/ulib_test: test/ulib/ulib_test.o libu-boot.so FORCE + $(call if_changed,ulib_test) + quiet_cmd_sym ?= SYM $@ cmd_sym ?= $(OBJDUMP) -t $< > $@ u-boot.sym: u-boot FORCE diff --git a/test/ulib/Makefile b/test/ulib/Makefile new file mode 100644 index 00000000000..ae58e01fccd --- /dev/null +++ b/test/ulib/Makefile @@ -0,0 +1,12 @@ +# SPDX-License-Identifier: GPL-2.0+ +# +# Copyright 2025 Simon Glass + +obj-y += ulib_test.o + +# Link with the shared library +HOSTCFLAGS_ulib_test.o += -I$(srctree)/arch/sandbox/include +HOSTLDLIBS_ulib_test += -L$(obj)/../.. -lu-boot -Wl,-rpath,$(obj)/../.. + +# Ensure shared library is built first +$(obj)/ulib_test: $(obj)/../../libu-boot.so diff --git a/test/ulib/ulib_test.c b/test/ulib/ulib_test.c new file mode 100644 index 00000000000..dd9cc0bb978 --- /dev/null +++ b/test/ulib/ulib_test.c @@ -0,0 +1,36 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Test application for U-Boot shared library + * + * This demonstrates linking against libu-boot.so + * + * Copyright 2025 Canonical + * Written by Simon Glass + */ + +/* Use system headers, not U-Boot headers */ +#include +#include +#include +#include + +DECLARE_GLOBAL_DATA_PTR; + +int main(int argc, char *argv[]) +{ + struct global_data data; + int ret; + + printf("Calling U-Boot initialization via shared library...\n"); + + /* init global data */ + memset(&data, '\0', sizeof(data)); + + ret = sandbox_init(argc, argv, &data); + + /* Do pre- and post-relocation init */ + board_init_f(gd->flags); + board_init_r(data.new_gd, 0); + + return ret; +}