From patchwork Wed May 29 18:22:56 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: 1941445 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=2605:bc80:3010::136; helo=smtp3.osuosl.org; envelope-from=buildroot-bounces@buildroot.org; receiver=patchwork.ozlabs.org) Received: from smtp3.osuosl.org (smtp3.osuosl.org [IPv6:2605:bc80:3010::136]) (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 4VqHnZ6NQKz20Pc for ; Thu, 30 May 2024 04:23:30 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 501E2605C4; Wed, 29 May 2024 18:23:29 +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 S3I_JhxzU_9N; Wed, 29 May 2024 18:23:28 +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 smtp3.osuosl.org 4B38E60B9C Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by smtp3.osuosl.org (Postfix) with ESMTP id 4B38E60B9C; Wed, 29 May 2024 18:23:28 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from smtp2.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by ash.osuosl.org (Postfix) with ESMTP id 25DBE1D393B for ; Wed, 29 May 2024 18:23:27 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 127F340428 for ; Wed, 29 May 2024 18:23:27 +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 tceiKoRGQzu8 for ; Wed, 29 May 2024 18:23:25 +0000 (UTC) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=212.227.17.22; helo=mout.gmx.net; envelope-from=j.neuschaefer@gmx.net; receiver= DMARC-Filter: OpenDMARC Filter v1.4.2 smtp2.osuosl.org D4545400F1 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org D4545400F1 Received: from mout.gmx.net (mout.gmx.net [212.227.17.22]) by smtp2.osuosl.org (Postfix) with ESMTPS id D4545400F1 for ; Wed, 29 May 2024 18:23:24 +0000 (UTC) X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from probook ([151.216.80.169]) by mail.gmx.net (mrgmx105 [212.227.17.168]) with ESMTPSA (Nemesis) id 1M89Gt-1s78tG00Gp-005Erm; Wed, 29 May 2024 20:23:21 +0200 Date: Wed, 29 May 2024 20:22:56 +0200 MIME-Version: 1.0 Message-Id: <20240529-ztext-v2-1-82985032f169@gmx.net> References: <20240529-ztext-v2-0-82985032f169@gmx.net> In-Reply-To: <20240529-ztext-v2-0-82985032f169@gmx.net> To: buildroot@buildroot.org X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1717006985; l=1965; i=j.neuschaefer@gmx.net; s=20240329; h=from:subject:message-id; bh=L1YCAsmIKjQu/Kl76ZfUEpVlzez/gE7O4O1iVjRItIs=; b=3iHPscK9m5qUamzPQzZBzCHtcKu/R3nk90XrbSPElrlIyaAIRbpWhf5mrnyLkvlNdCq3zoqbJ jBy0j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E+h8V7n+U2ZU j2HzF2LQGWwcYOl54065FFCKLljKIrKM0i0g3Ayj7PbF99qKweV+JmGQzvF2UkS/t56gtaSe4 p66hHU68VNviiXChbXMtCFjAAclLTSHuEFgkx9nMvxDHgCzH0X1/6yhYwAQg/H4rrBlevvDMA djvOd+vcGYFl7j7A5pmwG3oYyomhCPOpuDv/vGm20pG5k= X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.net; s=s31663417; t=1717007001; x=1717611801; i=j.neuschaefer@gmx.net; bh=rux404EF/kyiU6De6bkxKASucVepGjrOEG2dVElRLXw=; h=X-UI-Sender-Class:From:Date:Subject:MIME-Version:Content-Type: Content-Transfer-Encoding:Message-Id:References:In-Reply-To:To:Cc: cc:content-transfer-encoding:content-type:date:from:message-id: mime-version:reply-to:subject:to; b=b4ns4R8siiTyPOJGpdTZXg1Vs+9XqcNFn4g5vE3WHp4dDL0UPMgJKLek/MAV/GDZ WtBQbifZ89QWtRC6vUo4aC/Jr7gOHdattFdVrOxRlZLh4KW8oN/T0zPJNCwf/v5WM rkNwlhPqpNA1naZJA2dETY6jj9phn/JWXPfOeyRfvyk461he5Q7mPtor9h8maX2xD WTiaG1tJEJXk+KjIABR1gTclJvpk5NSal2et6CmRZyVLuA/U/iP7+ChvSA6wLFfrt +1zr6ESi8OcTQDFjpnY21oh2SnFCU1l2JLx/y/TGqWmETieiqeBfXpWfMlMqVJEGG aQqsqK5S5RuuC0WosQ== X-Mailman-Original-Authentication-Results: smtp2.osuosl.org; dmarc=pass (p=quarantine dis=none) header.from=gmx.net X-Mailman-Original-Authentication-Results: smtp2.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=b4ns4R8s Subject: [Buildroot] [PATCH v2 1/2] Config.in: ban textrels on musl toolchains 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?= , Thomas Petazzoni Errors-To: buildroot-bounces@buildroot.org Sender: "buildroot" musl-libc doesn't support TEXTRELs[1] and programs with TEXTRELs will crash on start-up under musl. This patch forbids the use of TEXTRELs on musl, but adds an option to either forbid them on other libcs as well, or allow them on musl. [1]: https://www.openwall.com/lists/musl/2020/09/25/4 Signed-off-by: J. Neuschäfer --- v2: - slightly different wording - default to yes on musl toolchains - fix check-package warnings - depends on BR2_SHARED_LIBS -> depends on !BR2_STATIC_LIBS --- Config.in | 14 ++++++++++++++ package/Makefile.in | 4 ++++ 2 files changed, 18 insertions(+) -- 2.43.0 diff --git a/Config.in b/Config.in index b5a94325c4..92e89ed32d 100644 --- a/Config.in +++ b/Config.in @@ -910,6 +910,20 @@ endchoice comment "RELocation Read Only (RELRO) needs shared libraries" depends on !BR2_SHARED_LIBS +config BR2_LINK_ZTEXT + bool "Disallow text section relocations (TEXTRELs)" + default BR2_TOOLCHAIN_USES_MUSL + depends on !BR2_STATIC_LIBS + 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's dynamic + loader and will result in a run-time crash: + + 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 f415e55f84..68efd39dba 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