From patchwork Fri Apr 19 14:52:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?J=2E_Neusch=C3=A4fer?= X-Patchwork-Id: 1925576 Return-Path: X-Original-To: incoming-buildroot@patchwork.ozlabs.org Delivered-To: patchwork-incoming-buildroot@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=buildroot.org (client-ip=140.211.166.133; helo=smtp2.osuosl.org; envelope-from=buildroot-bounces@buildroot.org; receiver=patchwork.ozlabs.org) Received: from smtp2.osuosl.org (smtp2.osuosl.org [140.211.166.133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4VLd1H0QMfz1yP2 for ; Sat, 20 Apr 2024 00:53:06 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 561A741A22; Fri, 19 Apr 2024 14:53:04 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id PutNgp8c78ua; Fri, 19 Apr 2024 14:53:03 +0000 (UTC) X-Comment: SPF check N/A for local connections - client-ip=140.211.166.34; helo=ash.osuosl.org; envelope-from=buildroot-bounces@buildroot.org; receiver= DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 4D0C041A3E Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by smtp2.osuosl.org (Postfix) with ESMTP id 4D0C041A3E; Fri, 19 Apr 2024 14:53:03 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from smtp3.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by ash.osuosl.org (Postfix) with ESMTP id 21B681BF33C for ; Fri, 19 Apr 2024 14:53:01 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 0E4CB60D93 for ; Fri, 19 Apr 2024 14:53:01 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id r3PW-wGBk_Dm for ; Fri, 19 Apr 2024 14:53:00 +0000 (UTC) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=212.227.17.20; helo=mout.gmx.net; envelope-from=j.neuschaefer@gmx.net; receiver= DMARC-Filter: OpenDMARC Filter v1.4.2 smtp3.osuosl.org 94FDE60DE5 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 94FDE60DE5 Received: from mout.gmx.net (mout.gmx.net [212.227.17.20]) by smtp3.osuosl.org (Postfix) with ESMTPS id 94FDE60DE5 for ; Fri, 19 Apr 2024 14:52:59 +0000 (UTC) X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from probook ([5.226.147.226]) by mail.gmx.net (mrgmx104 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MVNB1-1s7YVT2fmp-00SN6k; Fri, 19 Apr 2024 16:52:56 +0200 Date: Fri, 19 Apr 2024 16:52:50 +0200 MIME-Version: 1.0 Message-Id: <20240419-ztext-v1-1-a8d5c2cfcf57@gmx.net> X-B4-Tracking: v=1; b=H4sIAEGFImYC/6tWKk4tykwtVrJSqFYqSi3LLM7MzwNyDHUUlJIzE vPSU3UzU4B8JSMDIxMDE0Nz3aqS1IoSXdPE5OSkxCQzw2SDRCWg2oKi1LTMCrA50bG1tQDrP1q 5VwAAAA== To: buildroot@buildroot.org X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1713538375; l=2040; i=j.neuschaefer@gmx.net; s=20240329; h=from:subject:message-id; bh=uRR/dS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F4nW29iZtH UKKm4okfMGZsqqvs4Y8xa4mVuoCBIZ7HshXP5yz4EFDENT1ulMPvbfU+PVs/EfaJvLNyB1QdL 6/9deD/77/o3Aru0ygmRbn2Qe5DeNjq7Us+PG6YUM5uKkVxN1+9JAGdtQYnWtr+1VUgkZefHi g6Hp1Gwoc8kJmj0bQXfs7LOr+xo09wmjFr4PgFvrZCRIiqAMmpN8EXkxfc9lWCpIWlwTcrgmy HJNDXLIaB/UWX67Flp7ewfJCMw4/wpmF3ZxmtFLMCGostmhjTF3uvMcW5VyIyMFi3JkQiSqrc bLg+CVTwFi1mYhXN5NJtT8F+uEU07EICqDN4Bu6iZmT0E= X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.net; s=s31663417; t=1713538377; x=1714143177; i=j.neuschaefer@gmx.net; bh=teryNMXpVbqUUpBfXnmdOm30AIOXm7Zwn4mmKbsVjNk=; h=X-UI-Sender-Class:From:Date:Subject:MIME-Version:Content-Type: Content-Transfer-Encoding:Message-Id:To:Cc:cc: content-transfer-encoding:content-type:date:from:message-id: mime-version:reply-to:subject:to; b=lalBRu9ppEpBfFUsplmkkHjMvz3apPmQ1kT3sDfxEQihBtYkyTcYWzBdq0Qk0fl1 X2oYLOote7F98+DADEigpkmHk+EYRJ19sL0p0TsrIbKO2SqfXmPPPeKSL3sZiqmwm 8uZ4P9g7Ez1ZafMM4zEudohTo9YFriUwjunz92UjIO/SdpHD8EhdIAQKS8HeGQyEc vNUlTSWVQY2p2J6HaspBqO5RR0jaMJ5MF+GpJF45AIwzM74hW36qFI4RVCt36mxMt XWWnpP6dAnWXUHqSchHMVa6iGEHf+bbhWzokSqA8Ge9OrNt4c3jB0pzwJuTwsSd9b 0wcSYsayEpKqfKCR5Q== X-Mailman-Original-Authentication-Results: smtp3.osuosl.org; dmarc=pass (p=quarantine dis=none) header.from=gmx.net X-Mailman-Original-Authentication-Results: smtp3.osuosl.org; dkim=pass (2048-bit key, unprotected) header.d=gmx.net header.i=j.neuschaefer@gmx.net header.a=rsa-sha256 header.s=s31663417 header.b=lalBRu9p Subject: [Buildroot] [PATCH] Config.in: add option to ban textrels X-BeenThere: buildroot@buildroot.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Discussion and development of buildroot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: =?utf-8?q?J=2E_Neusch=C3=A4fer_via_buildroot?= From: =?utf-8?q?J=2E_Neusch=C3=A4fer?= Reply-To: =?utf-8?q?J=2E_Neusch=C3=A4fer?= Cc: =?utf-8?q?J=2E_Neusch=C3=A4fer?= Errors-To: buildroot-bounces@buildroot.org Sender: "buildroot" Ideally, this option would default to yes when a musl-based toolchain is used, as musl doesn't support TEXTRELs[1] and programs with TEXTRELs will crash on start-up under musl. However, to avoid a large build fallout, it defaults to "no" for now. After this option has been enabled in build tests for a while and some of the fallout has been fixed, the default can be changed. [1]: https://www.openwall.com/lists/musl/2020/09/25/4 Signed-off-by: J. Neuschäfer --- Config.in | 13 +++++++++++++ package/Makefile.in | 4 ++++ 2 files changed, 17 insertions(+) --- base-commit: 256aa8ed85f8fd65ea0f0f242adb55f95a13eb2b change-id: 20240417-ztext-5accbab61c0a Best regards, -- J. Neuschäfer diff --git a/Config.in b/Config.in index e4f58f3f66..26964a6bac 100644 --- a/Config.in +++ b/Config.in @@ -906,6 +906,19 @@ endchoice comment "RELocation Read Only (RELRO) needs shared libraries" depends on !BR2_SHARED_LIBS +config BR2_LINK_ZTEXT + bool "Disallow text section relocations (TEXTRELs)" + depends on BR2_SHARED_LIBS + default n # ideally: BR2_TOOLCHAIN_USES_MUSL + help + Pass "-z text" to the linker to detect TEXTRELs and throw an error if + they occur. + + This is recommended when building a system with musl-libc, because + TEXTRELs are not supported on musl-libc: + + https://www.openwall.com/lists/musl/2020/09/25/4 + config BR2_FORTIFY_SOURCE_ARCH_SUPPORTS bool default y diff --git a/package/Makefile.in b/package/Makefile.in index 3e276d23d6..de93defb3b 100644 --- a/package/Makefile.in +++ b/package/Makefile.in @@ -149,6 +149,10 @@ endif TARGET_LDFLAGS = $(call qstrip,$(BR2_TARGET_LDFLAGS)) +ifeq ($(BR2_LINK_ZTEXT),y) +TARGET_LDFLAGS += -z text +endif + # By design, _FORTIFY_SOURCE requires gcc optimization to be enabled. # Therefore, we need to pass _FORTIFY_SOURCE and the optimization level # through the same mechanism, i.e currently through CFLAGS. Passing