From patchwork Sun Nov 1 17:28:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Petr_=C5=A0tetiar?= X-Patchwork-Id: 1391799 X-Patchwork-Delegate: ynezz@true.cz Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.openwrt.org (client-ip=2001:8b0:10b:1231::1; helo=merlin.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=true.cz Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:8b0:10b:1231::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4CPNT13Yfcz9sSf for ; Mon, 2 Nov 2020 04:34:11 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:Message-Id:Date:Subject:To: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:References:List-Owner; bh=lIImpmzDXALE3rsnvPzrIhoxAT3sZaEp2PUgOpu1twg=; b=GnIIPPYbToFmWMZ5qMTM0+vzl VdUlrxhDAnrCwrRB53s3Q2GxBIX96/+zRBo5x3wDZ/Kkss+n06YPx1d/S4bowBY5YYeMAr3Bi+O2Z t5NsyD7R4k5qBir86ywTmn+lsFvqwiD+fWtLyceL96ToxqQC5oucksg0ggA9FDhagzfeEBqlzRbxX vVkSrLHOrLMLKWNYVrjaYTWmRWxTpfT5Fb5mj1p0hj4K/2jx6rBTKLzkz/3/F7Gd7VFN3EHZTvpZD q+IzkMLenuTFK+j8ZJ/gYb6/e2LNQZ2tJhghWpoiY/gZ5KuSc0auT0U+6in4UgTI1jKpT/BsZAu1Q XVqHB++0g==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kZHAf-0000dv-7b; Sun, 01 Nov 2020 17:29:37 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kZHAd-0000dl-4Y for openwrt-devel@merlin.infradead.org; Sun, 01 Nov 2020 17:29:35 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:Content-Type: In-Reply-To:MIME-Version:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-ID:Content-Description:References; bh=gkNwguytALuwHTxszb6e9tnRO6GzR9ZGHGUetw+gL3o=; b=tehvhpXJNSvA+u1HS+II2BpQRj PZBASvZea+Nhw+mexfmmaOv9+h1CXsAsg3zLvZTH4EenTqtOACCMT1TavXATMu0XM2e+26ndlmFGV 10G7zJnA1ORY2CXaXGOraGq7qINu/AlbieMQlQWw2Uy78y/F24ZzKLLYMU5uqoRGKaPT5q9E7WSm6 a2G01VL1uSg4dDJhVjulqZYIF9oAX17EAL+8/4Zxq4ThuU3z8xEf6HPCnPaKSOS2t4+1kE+Vibi5e VQtZb9VuztVZ0NG+bByMNagBVlx9SyKdCUY/TC3WWtK7EpjLsOwXMynpbS4AsIqbFn7OfZmWuK0d1 uqBFti3Q==; Received: from smtp-out.xnet.cz ([178.217.244.18]) by casper.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kZHAZ-0007bg-E8 for openwrt-devel@lists.openwrt.org; Sun, 01 Nov 2020 17:29:33 +0000 Received: from meh.true.cz (meh.true.cz [108.61.167.218]) (Authenticated sender: petr@true.cz) by smtp-out.xnet.cz (Postfix) with ESMTPSA id 511803F2C; Sun, 1 Nov 2020 18:28:47 +0100 (CET) Received: by meh.true.cz (OpenSMTPD) with ESMTP id 3e888a6c; Sun, 1 Nov 2020 18:28:28 +0100 (CET) From: =?utf-8?q?Petr_=C5=A0tetiar?= To: openwrt-devel@lists.openwrt.org Subject: [PATCH v2] scripts: bundle-libraries.sh: fix broken SDK compiler Date: Sun, 1 Nov 2020 18:28:43 +0100 Message-Id: <20201101172843.8904-1-ynezz@true.cz> MIME-Version: 1.0 In-Reply-To: <20201101141602.32650-1-ynezz@true.cz> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201101_172931_739887_981C55CF X-CRM114-Status: UNSURE ( 8.67 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -1.9 (-) X-Spam-Report: SpamAssassin version 3.4.4 on casper.infradead.org summary: Content analysis details: (-1.9 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 SPF_NONE SPF: sender does not publish an SPF Record X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: OpenWrt Development List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Petr_=C5=A0tetiar?= Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org Recent versions (> 5.33) of `file` report liblto_plugin.so as executable: $ file liblto_plugin.so liblto_plugin.so.0.0.0: ELF 64-bit LSB pie executable ... Which then leads to improper packaging of the plugin, resulting in the broken compiler: configure: checking whether the C compiler works mips-openwrt-linux-musl/bin/ld: liblto_plugin.so: error loading plugin: liblto_plugin.so: invalid ELF header As the LTO compiler plugin library is incorrectly packaged as SDK executable: $ head -1 ~/staging_dir/toolchain...libexec/gcc/.../liblto_plugin.so #!/usr/bin/env bash Fix this by filtering out shared libraries from the bundling. Ref: https://bugzilla.redhat.com/show_bug.cgi?id=1296868 Signed-off-by: Petr Štetiar Acked-by: Jo-Philipp Wich --- scripts/bundle-libraries.sh | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) changes since v1: - skipping the libraries instead of removing the execute bit (Jow) diff --git a/scripts/bundle-libraries.sh b/scripts/bundle-libraries.sh index 9efcbbd0b20e..e9dd0dc442ac 100755 --- a/scripts/bundle-libraries.sh +++ b/scripts/bundle-libraries.sh @@ -125,6 +125,23 @@ _patch_glibc() { fi } +should_be_patched() { + local bin="$1" + + [ -x "$bin" ] || return 1 + + case "$bin" in + *.so|*.so.[0-9]*) + return 1 + ;; + *) + file "$bin" | grep -sqE "ELF.*(executable|interpreter)" && return 0 + ;; + esac + + return 1 +} + for LDD in ${PATH//://ldd }/ldd; do "$LDD" --version >/dev/null 2>/dev/null && break LDD="" @@ -150,7 +167,7 @@ for BIN in "$@"; do LDSO="" - [ -n "$LDD" ] && [ -x "$BIN" ] && file "$BIN" | grep -sqE "ELF.*(executable|interpreter)" && { + [ -n "$LDD" ] && should_be_patched "$BIN" && { for token in $("$LDD" "$BIN" 2>/dev/null); do case "$token" in */*.so*) dest="$DIR/lib/${token##*/}"