From patchwork Fri Sep 5 17:01:22 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 248 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=1757091749; bh=fOdIKTxBDi8c7gAfdXamLrLmdZah5dgdyfOMiV40CJA=; 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=V17cPGyAoNJcAsLg8+tG5sjnG8g2h/lhbKTKOfGByrv37eaPYhBQjLepnfQVZWbFv 5EzMLq5vvQYqyaaYIuZyPEyww3kgJAb8+iqRgykixQIKXWWkY6D0v4KKoPw0W3/vEZ 6HAnnpniR6J1WZdHhzRQ2D7wnOLYmrITfdeFJkbwHNexY/vd2oNF6BofmtEuIrwJd0 /rlT7co64vM5dBcnozhoNrXuRvfg50DLRjwSn20EGwHDllyxtsAMSZu0OaHwQDHktu 0iFBAwXXi2p/OgLJeg7NClU9iRH8mOeuYlO7Rmfr1VsVg3ucM8qPhEO4Ckza/fLsij pRUzI1mZGjpnA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 567B3679A6 for ; Fri, 5 Sep 2025 11:02:29 -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 3jgjp5osY49D for ; Fri, 5 Sep 2025 11:02:29 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1757091749; bh=fOdIKTxBDi8c7gAfdXamLrLmdZah5dgdyfOMiV40CJA=; 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=V17cPGyAoNJcAsLg8+tG5sjnG8g2h/lhbKTKOfGByrv37eaPYhBQjLepnfQVZWbFv 5EzMLq5vvQYqyaaYIuZyPEyww3kgJAb8+iqRgykixQIKXWWkY6D0v4KKoPw0W3/vEZ 6HAnnpniR6J1WZdHhzRQ2D7wnOLYmrITfdeFJkbwHNexY/vd2oNF6BofmtEuIrwJd0 /rlT7co64vM5dBcnozhoNrXuRvfg50DLRjwSn20EGwHDllyxtsAMSZu0OaHwQDHktu 0iFBAwXXi2p/OgLJeg7NClU9iRH8mOeuYlO7Rmfr1VsVg3ucM8qPhEO4Ckza/fLsij pRUzI1mZGjpnA== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 44CB2678E7 for ; Fri, 5 Sep 2025 11:02:29 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1757091747; bh=1gQ4qo2f6hDrhfTW60NPc1llH08tikfY+rhWRUZXDwA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=A/sx6SGkkP3uMpr1F1y3MnJG7tt4qRK0EUbqF1yeCVKBs6ahf3HuC7FYWrk7/4u9s MG7JjfQMTqITmArgy6NDmrHL/Who/F5zQ61MU5DP6s2HTQcFSRRFC5Rt9KlsRFM8wY wDApy7RybHwEBGFhe7PWtuJZluXlHY8TEbd3jDB+YIS0vFpz15tzF8oH/zH+WWWcqm kqSxTh27v7YaSVaNK/2zoqkn9BZcvqr+KDITb8JqVHusIMBpqF02T1XxYoZd4SJo8V qCgxb0QmfToRIMUAYL4Pl9CwGcw+d7fiAYwaBqmEVrJm8VOnn09qtpfZCAV8Or3mwg 4JrVX2nT9AZSA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 6E2386799D; Fri, 5 Sep 2025 11:02:27 -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 dVxT2Rf-BGj0; Fri, 5 Sep 2025 11:02:27 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1757091743; bh=Py/GHoS/0OcSM4lu1SfzgVZAPtKckU4lBXmtw4+AcnU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rEnyey9xgXzixEWuTCRtisPDchImZuDwS4RYM966jOg47lgV0xNLO0ayK6X3ZwPmH G+FUFhulqMlByuK+gbNpVY7M4ElqukVU3Qs/mqraUl1nQce8A1HGoBr8CORm+38ld/ yXVmaNIFqBY/up0BJ8yotXRrr3KCoSeukDaMrqQLL0U1uhZX4Y3JKE/KJEq0yNdpo+ PZrI59uWOEljhgoPr4D45zsTslSAFT6L4ly2Sauzsyt2yYYIRmRq78LY5wrZZhEYxc oqbH6sxMuaSJ+OJ0ErnfIVd7sACI7IbXXMKPWxnsumWusKfOTe9Eg/mS8HHE53uyBM pjJaw4FH+vr/g== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id BCD11678AA; Fri, 5 Sep 2025 11:02:22 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Fri, 5 Sep 2025 11:01:22 -0600 Message-ID: <20250905170132.182249-12-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250905170132.182249-1-sjg@u-boot.org> References: <20250905170132.182249-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: ESMNMBO2QUBDH3E3Y6WXTLQDK467I34Y X-Message-ID-Hash: ESMNMBO2QUBDH3E3Y6WXTLQDK467I34Y 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 X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 11/15] ulib: Provide a test program for the static 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 Create a static version of the library test. This requires a linker script, since the linker lists much be correctly placed within the final executable. Provide a linker script for the sandbox version. Signed-off-by: Simon Glass --- Makefile | 18 +++++++++++++++++- arch/sandbox/config.mk | 1 + arch/sandbox/cpu/ulib-test-static.lds | 19 +++++++++++++++++++ 3 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 arch/sandbox/cpu/ulib-test-static.lds diff --git a/Makefile b/Makefile index bf571de9f06..3ece9a02b6c 100644 --- a/Makefile +++ b/Makefile @@ -1046,7 +1046,7 @@ INPUTS-$(CONFIG_X86) += u-boot-x86-start16.bin u-boot-x86-reset16.bin \ ifdef CONFIG_CMDLINE ifneq ($(cc-name),clang) INPUTS-$(CONFIG_ULIB) += libu-boot.so test/ulib/ulib_test -INPUTS-$(CONFIG_ULIB) += libu-boot.a +INPUTS-$(CONFIG_ULIB) += libu-boot.a test/ulib/ulib_test_static endif endif @@ -1893,6 +1893,22 @@ quiet_cmd_ulib_test = HOSTCC $@ test/ulib/ulib_test: test/ulib/ulib_test.o libu-boot.so FORCE $(call if_changed,ulib_test) +# Build ulib_test_static to test linking with the static library +# main.o is excluded from the static library since the main program is provided +# by the user +# Use --whole-archive to include all linker lists +# Use a linker script to ensure proper alignment of linker-lists +quiet_cmd_ulib_test_static = HOSTCC $@ + cmd_ulib_test_static = $(HOSTCC) $(HOSTCFLAGS) \ + -I$(srctree)/arch/sandbox/include -o $@ $< \ + -Wl,-T,$(LIB_STATIC_LDS) \ + -Wl,--whole-archive $(obj)/libu-boot.a -Wl,--no-whole-archive \ + -lpthread -ldl -lSDL2 -lrt -Wl,-z,noexecstack + +test/ulib/ulib_test_static: test/ulib/ulib_test.o libu-boot.a \ + $(LIB_STATIC_LDS) FORCE + $(call if_changed,ulib_test_static) + quiet_cmd_sym ?= SYM $@ cmd_sym ?= $(OBJDUMP) -t $< > $@ u-boot.sym: u-boot FORCE diff --git a/arch/sandbox/config.mk b/arch/sandbox/config.mk index 566f5b417ae..f80e2ef369f 100644 --- a/arch/sandbox/config.mk +++ b/arch/sandbox/config.mk @@ -72,3 +72,4 @@ EFI_RELOC := reloc_sandbox_efi.o # U-Boot Library LIB_LDS := $(srctree)/arch/sandbox/cpu/u-boot-lib.lds +LIB_STATIC_LDS := $(srctree)/arch/sandbox/cpu/ulib-test-static.lds diff --git a/arch/sandbox/cpu/ulib-test-static.lds b/arch/sandbox/cpu/ulib-test-static.lds new file mode 100644 index 00000000000..c400fba4f2b --- /dev/null +++ b/arch/sandbox/cpu/ulib-test-static.lds @@ -0,0 +1,19 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * Linker script for ulib_test_static binary + * + * This ensures proper alignment for linker-lists when linking with libu-boot.a + */ + +SECTIONS +{ + /* Ensure proper alignment for linker lists */ + . = ALIGN(32); + __u_boot_list : { + __u_boot_list_start = .; + KEEP(*(SORT(__u_boot_list*))); + __u_boot_list_end = .; + } +} + +INSERT AFTER .rodata;