From nobody Sun Feb 8 22:58:20 2026 Received: from mail-pg1-f179.google.com (mail-pg1-f179.google.com [209.85.215.179]) (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 7566B40B6F0 for ; Wed, 4 Feb 2026 12:46:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770209180; cv=none; b=u9Q/tnyAoCVbD+PoMuVRJuoEuY4BTW3NenfsF5W7EMwcd2y+1euSIdLLxR6l6eQ5MG/UYVxLzbRZsNP15BEqZ7AVlKuadu0FF5G55p5yND+giyuW/nK1ZHr1v1xC/RJG1A7VQnWqKR3mQeXmL/+vX8wGXRxEsOd2IlNB8JLUcQY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770209180; c=relaxed/simple; bh=kZc/LHINNlskIjqK/Ezt0wdgB6dmXTDesKjw7YYNfKw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=a3cP7DYUO7NkjSS54ARUsr9qjLv0DCGjwf8SmO4dJE/KovT5q7pLj0o6h2XKhswQ85KI8efpS5z941uLQMIjru8kQjGP1PYDyc4PhvSUUk5mS+yu2VU9YlPoMejG4eGHbWAAEITJkmzpL6xQlR59rnmKNVRSOyTPmYNA2rWHywc= 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=nJA0ngI5; arc=none smtp.client-ip=209.85.215.179 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="nJA0ngI5" Received: by mail-pg1-f179.google.com with SMTP id 41be03b00d2f7-c5513f598c0so342660a12.0 for ; Wed, 04 Feb 2026 04:46:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thingy.jp; s=google; t=1770209180; x=1770813980; 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=nJA0ngI5tTHBJyl88/DLpYeXHyYvtJ4TdSFE9L57I1G/jETp/0w+pKZ3MiaabaG+lX lgT1+6BCQekXvookYrOUrQv6BnDM+JQoWoqIeCehl9TC2PHDyrlbFxiDeqKV+kRkYAAb PrgFCItyl7DrOonJr7lUKMpCBHA1B6vQckO5c= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1770209180; x=1770813980; 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=aWjLEwMMe97XJFQH4YUuvNNXQZ4wOhy0K6ZyU09XFMjQmV8oBjZDa31EDiJvB4Vodf I71cNLC9a0S6A/9DK2KhCOg12jvVX+Jd/IQYSV+W2zdSZJYnd9zP5NeSzca1LF4A+dpC jRR7UY1vyvezmOsS5hJwiGhfIdU9dWpu9XG4osVB2WYwbYtV+dhFG1HlpJARs9+Swt3+ F/4nYE7klIkiqi8UAa9NH2sdjYLSisFEp12Sg6nkTBgWdSuBJAEt9VKHoDHcbKP9u8+s Blowu+/nW4i7tqvEbvm3HTwBNfcidciY0E8O+1ECds1xTaWp92dpEPOtgcCBVmhP2IwO IzqQ== X-Gm-Message-State: AOJu0Yw7I9NSHXmTKSOrS8/ykZD5EM6idTl6iBNljszGln6QaZfrEoPl w9Ejm+gO5ufHDYBGra5cW9bToa+C4Ea8r7CV9xsl+WsBu2AyuwG76taZjMNgcshcGQ3DruTBmUc 9Zjz4 X-Gm-Gg: AZuq6aIlxUZc0olFAlhgPeXsePIhQ5Thi0ahCDnlVQN6O9vzqLxMFZsj3UYvHlDyN9W uDecNCGURazwzlb486Yt7OwmGHFSXl5Y7Rrq81X2XXfaGZbef1KLTXCkrZRk9/kteSPYjR85QrU af+juViI1y47HNr8HWn4GgQlmcy2n0Kxs8Ndk7x53MZbsuA0x2aCKbulCNVUj3/znNS+DorMOwP cKYxpl2edUqKC8QfJJNuoZ2Eopza3jQm7vuV285StmppZklnQjiN9dT69z/lky1g9fLuCyprCvd KxcE6KKhtTF+Wy9jupqRbwWYjGxC7mguCaaB2Tu40+uWSlLl7jSamp5DdQFODIWMiGCc+5KTgHh nqSDSXm/wtEGEx95A8Ym4YiA188XdLshJW/gtXU+Zl90KqrDvkspwnL/HnsC1G5NVgvFGqNKSTu vtNYrqPBtluAxGBjxJMl2ZsJ4B27YJ1Wd+auIN31rrdeilsokga3GTfdpiOFl5UBI7hqVrczAna y9/ X-Received: by 2002:a17:90b:2fc6:b0:352:cdda:7aa7 with SMTP id 98e67ed59e1d1-354871af6edmr2577349a91.24.1770209179915; Wed, 04 Feb 2026 04:46:19 -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 98e67ed59e1d1-354862effa6sm2378920a91.9.2026.02.04.04.46.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Feb 2026 04:46:19 -0800 (PST) From: Daniel Palmer To: w@1wt.eu, linux@weissschuh.net Cc: linux-kernel@vger.kernel.org, Daniel Palmer Subject: [RFC PATCH v2 10/10] selftests/nolibc: Add option for building with -static-pie Date: Wed, 4 Feb 2026 21:45:42 +0900 Message-ID: <20260204124542.523567-11-daniel@thingy.jp> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260204124542.523567-1-daniel@thingy.jp> References: <20260204124542.523567-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