From patchwork Thu Jul 18 20:33:23 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: 1962209 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 4WQ4Jj3Qwzz1xrQ for ; Fri, 19 Jul 2024 06:33:41 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id DE53E606D5; Thu, 18 Jul 2024 20:33:39 +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 NqvjrVHh6tXF; Thu, 18 Jul 2024 20:33:39 +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 DFE87606D9 Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by smtp3.osuosl.org (Postfix) with ESMTP id DFE87606D9; Thu, 18 Jul 2024 20:33:38 +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 0EA2A1BF3A1 for ; Thu, 18 Jul 2024 20:33:37 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id F00C0404A3 for ; Thu, 18 Jul 2024 20:33:36 +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 eiZ_7IzQP1kg for ; Thu, 18 Jul 2024 20:33:35 +0000 (UTC) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=212.227.15.19; helo=mout.gmx.net; envelope-from=j.neuschaefer@gmx.net; receiver= DMARC-Filter: OpenDMARC Filter v1.4.2 smtp2.osuosl.org 2BFD34048B DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 2BFD34048B Received: from mout.gmx.net (mout.gmx.net [212.227.15.19]) by smtp2.osuosl.org (Postfix) with ESMTPS id 2BFD34048B for ; Thu, 18 Jul 2024 20:33:34 +0000 (UTC) X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from probook ([151.216.37.99]) by mail.gmx.net (mrgmx005 [212.227.17.190]) with ESMTPSA (Nemesis) id 1M9nxn-1sQwud3BfJ-002qbI; Thu, 18 Jul 2024 22:33:30 +0200 Date: Thu, 18 Jul 2024 22:33:23 +0200 MIME-Version: 1.0 Message-Id: <20240718-ztext-v4-1-15a9744f1edb@gmx.net> X-B4-Tracking: v=1; b=H4sIABJ8mWYC/1XNTQ6DIBRG0a0YxqV5oCh01H00HSA/yqDaACG2x r0XTa3p8HvhXGYUjHcmoEsxI2+SC24c8qhOBVK9HDqDnc4bUaAVVKTB72imiJlUqpVtTRRIlN8 +vbFu2jq3e969C3H0ry2byHrdC+JbSAQTLLlmiiqrLGuu3WM6Dyai1Sd6GEZ/hmLAnArOoKSW1 OLflIdpoNpNmf8RRDANteKthsMsy/IBPUUxggABAAA= To: buildroot@buildroot.org X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1721334810; l=2292; i=j.neuschaefer@gmx.net; s=20240329; h=from:subject:message-id; bh=ncULdTHRSQBwAL9QqV4ScMwWPVRTBV5NeyZGLihMPvc=; b=HvKBSek671oORoujmKWLyHYDfCA1Klzxfzanvbs9jNH2473ULcwiRET6CeMlxWoQWIBanLwkE HO5JH3wJGT4AcsvpHhLs4WTAla1MsDA1e421mNv2okB16gMnm8OWueJ X-Developer-Key: i=j.neuschaefer@gmx.net; a=ed25519; pk=NIe0bK42wNaX/C4bi6ezm7NJK0IQE+8MKBm7igFMIS4= X-Provags-ID: V03:K1:PrcZrnaMUvxhqtFxrOb5oUcE3h6iPCNx1sCPrbFRAOyvYt4Thkv E/N0muYHSaOwts05lp4EzFafGhxvM496uR4LffMJaXvCfr0mwx7ORXxTLtKd00XyzHJbcXr WFlM1h9XCQOdR9YVYVCpEhFi91hArb9Jz5evGq6Z+X4LnXsZCCq/0k1Xs4eEAwFnm53FXXj eSh2JUy0UAVUcML773B+A== UI-OutboundReport: notjunk:1;M01:P0:/NeWtxg07V8=;bJldITi/vksDPXjIXvBCANT9BP3 N63JO7plPY236q9EB/LpSCsmPJ2NOXlEEOrKOq7f4qsWwJ3sX7pLUifil74xxH4zZghARXaqy W1VtHH2YWrcbw2jOl+PRtIFxu9IIBh+Tv3rohuyq8el2OTsTzHzSzChS5Kf9QoLGo2xdaFlBW eQU32yUq2IOfUXZMPw0ybqXQf8H9RjrDzzVwuu0Us4uKfSDrGZC63j5v1J1fNsKnSE5kLwH7U AqeaDSdG2B4NG2jagU/Cl83EBkjzaEqojp0HHe+9xw4xJ3KvU0CzI0dVdNE6biS2h83Mvejar ktNqgG3l4Ott/zdvVN785fFx5TtVO85koYPz8sug6yGx1aJFI5ytopgWNdHfjaA6MW9BG4bxt vjeGkNWu47WI6ALy8ssW04eDMvRJQaQ+myQfYAtJSbbmFHc6QHXOuXCwzoX1lEx2pCRqsaHsN bw0QQCAJJoKDnjFuQrk1ex+7DJGHmgUMYrt9PEYcrHgWSwbjqO3O6AAq6HNKEWUDDue6t6cJh YuaIrweFrr3Jcb/BUQ+nIdsm1Y4DFGrxIv0U/0jPSTEtzAuqzhxIAXSKbRg2Rmf2wkv0FZiPO Ef21MWnpME1OfknLcIcTGC2gSED6bPA8vdWL8O9zZxfRmhJaZ4Zz3zkWx05pnArI8mPjyFT9d p1kJ6VpTZhEfUNhrmAPP/pvq5NeRPnDarFNUrsUcKOc0vBX9hL2kykP1ne9ZF0FPVXgv9mTP3 iLTnzVDpV3y0kxyaKEQRJvOxXQpic49qWtN8bjHDmxn+hZ6gXqawT2At2e/0PhxLpdhJaguqe nbudvcZR5/E99kdecXgmFCOQ== X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.net; s=s31663417; t=1721334810; x=1721939610; i=j.neuschaefer@gmx.net; bh=RnlKSpsVk6RMYCd00NLGm06W2Rync1UBPqIq6kVq6ZE=; 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=JUjNpXbx0D6r4HZm4sGnm3TGzq08emMLG1jOuwEof4SGoqXBIJVlAZuqBmdgkwd/ NmPyUzoC79+7XOcfGi8KI2+wQH0EZMgplYEho2Fe4ZppQWbDFET59tvZrVZFk7iCK nFBL9e+vYVE//lUqEaZb9Ti8nlLtJ71Sh8/9BsJM5THdXzXlgq28lNG9LLLZ/KayP uPHQszL2CG9G4tt1FXrvqHcciNzM7IyxAqbWi7aIgLrncrwHLx2bAJCq8tfbkP2Jb bu4AIh5nrNULLGg3rTlEXMS0DizXOhBL6IWJARPoha0jxPxcnKI/pTD2YIWyf9+JQ gcmp1DYVjB5jNJdVqw== 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=JUjNpXbx Subject: [Buildroot] [PATCH v4] 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: "Yann E. MORIN" , Thomas Petazzoni , =?utf-8?q?J=2E_Neusch?= =?utf-8?q?=C3=A4fer?= 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 toolchains with dynamic linking. To verify this patch: - Delete package/micropython/0001-py-nlrthumb-Make-non-Thumb2-long-jump-workaround-opt.patch - Build micropython (before v1.23) with a musl toolchain and BR2_SHARED_LIBS. The build should abort while linking micropython. [1]: https://www.openwall.com/lists/musl/2020/09/25/4 Signed-off-by: J. Neuschäfer --- Changes in v4: - Remove Config.in option, implement the whole logic in package/Makefile.in - Document how to verify - Link to v3: https://lore.kernel.org/r/20240704-ztext-v3-1-9195d06c8bd0@gmx.net Changes in v3: - drop micropython patch (already merged) - rewrite to positive logic, as suggested by Yann E. MORIN - Link to v2: https://lore.kernel.org/r/20240529-ztext-v2-0-82985032f169@gmx.net Changes in v2: - Slightly different wording - Enable the option by default on musl toolchains - Add patch to fix build of micropython Link to v1: - https://lore.kernel.org/r/20240419-ztext-v1-1-a8d5c2cfcf57@gmx.net --- --- package/Makefile.in | 9 +++++++++ 1 file changed, 9 insertions(+) --- base-commit: c624eee120b6ee0c81e636bd47abe92452610cf7 change-id: 20240417-ztext-5accbab61c0a Best regards, -- J. Neuschäfer diff --git a/package/Makefile.in b/package/Makefile.in index 47a89f1ae1..3587662014 100644 --- a/package/Makefile.in +++ b/package/Makefile.in @@ -149,6 +149,15 @@ endif TARGET_LDFLAGS = $(call qstrip,$(BR2_TARGET_LDFLAGS)) +# musl's dynamic loader doesn't support DT_TEXTREL, which results in a runtime +# crash if it gets used. The "-z text" linker option issues a build-time error +# when DT_TEXREL is used, so we capture the problem earlier. +# +# See also: https://www.openwall.com/lists/musl/2020/09/25/4 +ifeq ($(BR2_TOOLCHAIN_USES_MUSL)$(BR2_BINFMT_SUPPORTS_SHARED),yy) +TARGET_LDFLAGS += -Wl,-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