From nobody Sun Feb 8 20:59:57 2026 Received: from mail-pf1-f175.google.com (mail-pf1-f175.google.com [209.85.210.175]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8D89C344052 for ; Sat, 31 Jan 2026 07:44:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769845498; cv=none; b=GspybBHr3BLJAf7de0UQTUKv83PWrzKf3+9S0PXamHoFQlCWFCgIPzB8xQY1BguwFkAU5k2eSWT0ZoZz20PLbxp07IJLnjQTko/hcKWkpED7nfNx5eXoh+kiCYEex8EeyIjnXHcmxsSafer01eimLl+rsF07YPt04Edh83xtFCI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769845498; c=relaxed/simple; bh=kZc/LHINNlskIjqK/Ezt0wdgB6dmXTDesKjw7YYNfKw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=lFVJBfaT2HvSnIJYEpU2tSr0R1B090dOjC+NAUn+4IyHvUfYgMTixaSFjKKVwsi1H85AcAthWFPM+OgRuJo00cK9zJOIzXkusuWkL1vsFf4vVZqoe6FSJ1Jgta9FB21JbuKoGf7UD1tKu3Y0SMvpdMMux9xZeqEWJzvsrrC6Hj8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=thingy.jp; spf=pass smtp.mailfrom=0x0f.com; dkim=pass (1024-bit key) header.d=thingy.jp header.i=@thingy.jp header.b=FHEPxSHK; arc=none smtp.client-ip=209.85.210.175 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=thingy.jp Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=0x0f.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=thingy.jp header.i=@thingy.jp header.b="FHEPxSHK" Received: by mail-pf1-f175.google.com with SMTP id d2e1a72fcca58-82310b74496so1702598b3a.3 for ; Fri, 30 Jan 2026 23:44:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thingy.jp; s=google; t=1769845497; x=1770450297; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=nMHV7n3E7WwDamOikF+MO/K8LzPwGrACYORp1duWaic=; b=FHEPxSHKBi/bHRQQdyhXvBdEJ5/WPGt+ABtdHILFIqBuM3vJ8msnZsEy4ACzFYTm3F X1XEW8miUY6velrs47DTgcntFBKiqsnd94w5HHnGDM/gVd4/qn5Wxx1JCr1aqVgKDycw aDvo+6HkSPc08njbJ0Hi9zbrC8OPAN9K9pRJs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1769845497; x=1770450297; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=nMHV7n3E7WwDamOikF+MO/K8LzPwGrACYORp1duWaic=; b=KJmAymAGw8CydUs6iamheBT8gxq0H7dekGcxvTv7Atv2o1g1agAkMwqbj0J6NVCnV4 /BWfrK+sMSzip4HYhR33m8CWWvKU5Xza6nqdAOJmZ14/law8DUIjGcr/NNnrcfiafWUN SbZnpOCqBPJu/tJ+7TDl6IX7R8VLZ1nytkCVOZTOMhANyraZNq52D+aVpyASJ/ENIth9 zDsyCKsmxG3DnTFirI9+5OfjMusT3MHtZ1CtVXTB8vVfJI7i4YFDRh0e6vhAmUkMVtEe 7E5pVqCs+KKEFRz3nuZZmDXlxFH83HhG6YRvrSTFbkFJSJn3Sw5Xr9i+SxVJOiWAeuyJ 7knQ== X-Forwarded-Encrypted: i=1; AJvYcCWD2DQIOrzozUzgSAJvcG7WCvnZcUYdU+6hI/DZJL/WWxPYeFfy5M5MEEv43THnzQH+bWob6gwfeIGVSDU=@vger.kernel.org X-Gm-Message-State: AOJu0YzBSgy4mGC9T+W0yKn84re0T03zjF/1Qt4x/1ePSxgqKCe6c5+n VsTrub+czlULSggI+AjMiZEr5gLG9r55y6JQV9OiEDC/FXA4TbZyHEhxwqKdKc6s2CU= X-Gm-Gg: AZuq6aK1GJjnlzwSf7xH5SDvH/jWvVlrLJ4+0m/xbocCcb5wj4pV8H+gzroz60dYDM7 yDNMKqYOKBxM/s/gHH52Dq0k4RXEqZhRrPb1gFRoDO9+BklOS867UPZw20t2uLlSXUs5261hAzv +hPWw4NpLaQFuMjswi5fzRznJ58bxa7G77bMpo72bWlH1jNwqSmu8rZa6ATWStCko1d5i7UevXt sUmOzkdEdyyRaSBWdlv6IOh284M1BdAA4KSFKvqQo3XqUVmQzH2X4vEgIgPjm6h3+rIwAfk9A4a yk801DQWwaoKF13LYUwwWUyccHqkyBdmWMGz0wMCoAY7qFWiwMXTzlFYAE01VpmLlWyvGQ+ObRe 7taJdnFmM8ZMkD432PGeSVluAObVVdTar5d9YJ9x2VyGBliwaWQd1OuJCjzJhWCZPLUQhtQfk5+ RPqOvQqYf+aHKZpkFARYLfMGqFSPW/EdE9UcZ+HPo6y/zWAYhqioiKpjJ3Zh3CI4pkwEnqqTE8s CodexaG5YPar50= X-Received: by 2002:a05:6a21:a98:b0:38f:df47:87b7 with SMTP id adf61e73a8af0-392e0050b35mr6127469637.21.1769845496988; Fri, 30 Jan 2026 23:44:56 -0800 (PST) Received: from kinako.work.home.arpa (p1490223-ipxg00b01sizuokaden.shizuoka.ocn.ne.jp. [153.223.134.223]) by smtp.googlemail.com with ESMTPSA id 41be03b00d2f7-c642a9f539dsm8866928a12.26.2026.01.30.23.44.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 30 Jan 2026 23:44:56 -0800 (PST) From: Daniel Palmer To: linux@weissschuh.net, w@1wt.eu Cc: kees@kernel.org, linux-kernel@vger.kernel.org, Daniel Palmer Subject: [RFC PATCH 8/9] selftests/nolibc: Add option for building with -static-pie Date: Sat, 31 Jan 2026 16:44:39 +0900 Message-ID: <20260131074440.732588-9-daniel@thingy.jp> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260131074440.732588-1-daniel@thingy.jp> References: <20260131074440.732588-1-daniel@thingy.jp> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Allow the tests to build with -static-pie instead of -static to test the self relocation code works. Note: This doesn't work 100% correctly. For x86_64 I can see the test binary is static or static-pie depending on if -static or -static-pie is used but for m68k it's always static and I had to hack in the workaround. I have somehow got the tests to seem to produce static PIE binaries when requested, and regular static ones when not but its a mess and this can't be used as-is. Signed-off-by: Daniel Palmer --- tools/testing/selftests/nolibc/Makefile | 2 +- tools/testing/selftests/nolibc/Makefile.nolibc | 8 ++++---- tools/testing/selftests/nolibc/run-tests.sh | 10 +++++++++- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/tools/testing/selftests/nolibc/Makefile b/tools/testing/selfte= sts/nolibc/Makefile index 40f5c2908dda..5d5c3231cc19 100644 --- a/tools/testing/selftests/nolibc/Makefile +++ b/tools/testing/selftests/nolibc/Makefile @@ -9,7 +9,7 @@ cc-option =3D $(call __cc-option, $(CC),,$(1),$(2)) =20 include Makefile.include =20 -CFLAGS =3D -nostdlib -nostdinc -static \ +CFLAGS =3D -nostdlib -nostdinc \ -isystem $(top_srcdir)/tools/include/nolibc -isystem $(top_srcdir)/usr/i= nclude \ $(CFLAGS_NOLIBC_TEST) =20 diff --git a/tools/testing/selftests/nolibc/Makefile.nolibc b/tools/testing= /selftests/nolibc/Makefile.nolibc index f9d43cbdc894..c55f4c17e06d 100644 --- a/tools/testing/selftests/nolibc/Makefile.nolibc +++ b/tools/testing/selftests/nolibc/Makefile.nolibc @@ -304,12 +304,12 @@ sysroot/$(ARCH)/include: =20 ifneq ($(NOLIBC_SYSROOT),0) nolibc-test: nolibc-test.c nolibc-test-linkage.c sysroot/$(ARCH)/include - $(QUIET_CC)$(CC) $(CFLAGS) $(LDFLAGS) -o $@ \ - -nostdlib -nostdinc -static -Isysroot/$(ARCH)/include nolibc-test.c nol= ibc-test-linkage.c $(LIBGCC) + $(CC) $(CFLAGS) $(LDFLAGS) -o $@ \ + -nostdlib -nostdinc -Isysroot/$(ARCH)/include nolibc-test.c nolibc-test= -linkage.c $(LIBGCC) else nolibc-test: nolibc-test.c nolibc-test-linkage.c - $(QUIET_CC)$(CC) $(CFLAGS) $(LDFLAGS) -o $@ \ - -nostdlib -static -include $(srctree)/tools/include/nolibc/nolibc.h nol= ibc-test.c nolibc-test-linkage.c $(LIBGCC) + $(CC) $(CFLAGS) $(LDFLAGS) -o $@ \ + -nostdlib -include $(srctree)/tools/include/nolibc/nolibc.h nolibc-test= .c nolibc-test-linkage.c $(LIBGCC) endif =20 libc-test: nolibc-test.c nolibc-test-linkage.c diff --git a/tools/testing/selftests/nolibc/run-tests.sh b/tools/testing/se= lftests/nolibc/run-tests.sh index 3917cfb8fdc4..12b4774a77d8 100755 --- a/tools/testing/selftests/nolibc/run-tests.sh +++ b/tools/testing/selftests/nolibc/run-tests.sh @@ -16,6 +16,7 @@ build_location=3D"$(realpath "${cache_dir}"/nolibc-tests/= )" perform_download=3D0 test_mode=3Dsystem werror=3D1 +staticpie=3D0 llvm=3D all_archs=3D( i386 x86_64 x32 @@ -31,7 +32,7 @@ all_archs=3D( ) archs=3D"${all_archs[@]}" =20 -TEMP=3D$(getopt -o 'j:d:c:b:a:m:pelh' -n "$0" -- "$@") +TEMP=3D$(getopt -o 'j:d:c:b:a:m:peslh' -n "$0" -- "$@") =20 eval set -- "$TEMP" unset TEMP @@ -55,6 +56,7 @@ Options: -b [DIR] Build location (default: ${build_location}) -m [MODE] Test mode user/system (default: ${test_mode}) -e Disable -Werror + -s Enable static PIE (default: ${staticpie}) -l Build with LLVM/clang EOF } @@ -85,6 +87,9 @@ while true; do '-e') werror=3D0 shift; continue ;; + '-s') + staticpie=3D1 + shift; continue ;; '-l') llvm=3D1 shift; continue ;; @@ -171,6 +176,9 @@ test_arch() { if [ "$werror" -ne 0 ]; then CFLAGS_EXTRA=3D"$CFLAGS_EXTRA -Werror -Wl,--fatal-warnings" fi + if [ "$staticpie" -ne 0 ]; then + CFLAGS_EXTRA=3D"$CFLAGS_EXTRA -ggdb -fPIE -pie -Wl,--no-dynamic-linker -= Wl,-ztext -Wl,-zseparate-code" + fi MAKE=3D(make -f Makefile.nolibc -j"${nproc}" XARCH=3D"${arch}" CROSS_COMP= ILE=3D"${cross_compile}" LLVM=3D"${llvm}" O=3D"${build_dir}") =20 case "$test_mode" in --=20 2.51.0