From patchwork Fri Jun 23 13:01:38 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Kemper X-Patchwork-Id: 780008 X-Patchwork-Delegate: blogic@openwrt.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3wvJWh2nqYz9sPN for ; Fri, 23 Jun 2017 23:02:24 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="WYzu1LXQ"; dkim-atps=neutral DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Subject:Content-Type: MIME-Version:Message-ID:To:From:Date:Reply-To:Cc:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=W63PlGEL0W1o1wueNFEIyX56Yt7ua2gKZubzV/T78fQ=; b=WYzu1LXQKWQvdcrmcv107A4E+7 0UWaXeDwYG8Huta4rcCivR01yyz4NvuJ13fjC2MlCh+7dme1yIcoAJEipDvi2yQC2EJln5h1jFAsC ipne84IneCHcpZhjwMUgTwBpV3/vnsgeOxqPzdUzhAQjwy44/fBoHIcIVrHgTiF2zpO4InV+Iy0hf wN/MEd123eCbRXDdgiv00+7MULwNMpo8YVE8Lg86uAKMYWgYiBrduxEbYh9Ow5LSUEeo9SOq/5h5y Xks03XWzOpgmLpNL57pXrsO/YijQ5PPfiG9RdwjaCMfu9i05li2xnb25DNIswlZD70LCf2ICbGBsB q1u5XJ1Q==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dOODy-0003bo-5D; Fri, 23 Jun 2017 13:02:10 +0000 Received: from mout.gmx.net ([212.227.15.19]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dOODu-0003Zx-AC for lede-dev@lists.infradead.org; Fri, 23 Jun 2017 13:02:08 +0000 Received: from hotdamn.lan ([88.7.218.137]) by mail.gmx.com (mrgmx003 [212.227.17.190]) with ESMTPSA (Nemesis) id 0MexaL-1d8m6f3wtt-00OVe9 for ; Fri, 23 Jun 2017 15:01:41 +0200 Date: Fri, 23 Jun 2017 15:01:38 +0200 From: Sebastian Kemper To: lede-dev@lists.infradead.org Message-ID: <20170623130138.GA30877@hotdamn.lan> Mail-Followup-To: lede-dev@lists.infradead.org MIME-Version: 1.0 Content-Disposition: inline X-Provags-ID: V03:K0:hyipLCePgf97H1g6OrbEgNazKIrymVkeqCVZFr2ncphwYIndsOH jQsX3kz2i8dqlJSDKT339spB1FMBKNNgWheHGz/7ITscIK4aM5Zy1hmNgM7ugXeyEbosrXp 5aQM4tX9yRJQVNoB/jKxWP9ukyCWu0T91TeVHOzT7p7oldMMQikL6i6RRBRVHPEvsQZDTKZ oASZUlvc5b0+DPZ4Sr0nw== X-UI-Out-Filterresults: notjunk:1; V01:K0:ou0fTSiGDYU=:gDnOxzRza6rCCOi2aOIm+/ kDrqsSV7K5iYJB+IeNY4jGTtdSJsACkuCjFrJSjUseAO1rUIZKP2tujsLm1z5EcKinXIP3nQY yO3RdmVzYA9dn5XoQXr9TzVFHfGpFhZXubrJXKPSkSr3tLz2kmc9WkXQqEFa11YbX6ukeFWSa YKiRYnPpmHp4Ju2ODiObHJL8Y0LzKcBdj7BpOOwSLhqCrUWgw9jNpwmpqASRAQjlqqnGigzm8 TrJlPveKIaOPZaJHB6usKOwoqPTTi5olCsMiGg+77HXkbIooHW1nnOpjQ70jJF7RNldgy3Dzc ib2VlZz/MvzUIr+PDfVIaXeAiF2yDutc3LaPzBn+0y6nuv/eCv9EumRhXeLJPKsw/pFp9Z+RC 5vffMfrCj/JHF4WQSqKS56u3vO8nKBbM2Ik+UB5zpds3dOjQzL8ai8ZRcKE8ZD3KKiLiQ8W5+ i9JRRu/i9o7XXscRgsFNcCaPCC7+KxOuihXTLiOTNhe4wrEObEKb30qUnC3IdV6fRfqwIOwQf iw2utSik3ZVd1O1z20OS+7GLPRvj4si5VwxT/iX585UCvGZUT/UYt8c3xNzF182gB9FW5l3tU rK/IjcTMrR6ny6tyN8oIHmIf9OGWqQSzeVLNZjz9frhOIRT1854J6YHsppJ8jgY0OWuwsLCk2 6CQ9o7TcEmt1BqA+DxfvF3yMAY3FcUDsGPL3DdZW2np/zfEAygBCm1ISMprgVpIYoHGcitun4 dHlIGsKBhEvXb14GAq/DJM7jM+I57OHq0nC0ClrX84LebfW6iA2A7A2qDa0= X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170623_060206_707625_0FB2CEF5 X-CRM114-Status: UNSURE ( 6.44 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -1.9 (-) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (-1.9 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [212.227.15.19 listed in list.dnswl.org] -0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [212.227.15.19 listed in wl.mailspike.net] -0.0 T_RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -0.0 SPF_PASS SPF: sender matches SPF record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (sebastian_ml[at]gmx.net) -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.0 RCVD_IN_MSPIKE_WL Mailspike good senders Subject: [LEDE-DEV] scripts/rstrip.sh fix patchelf invocation X-BeenThere: lede-dev@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Lede-dev" Errors-To: lede-dev-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org When rstrip.sh finds a bogus rpath, it removes it, while keeping the sane rpaths. Example of two rpaths: /home/sk/tmp/lede/staging_dir/toolchain-mips_24kc_gcc-5.4.0_musl-1.1.16/lib /usr/lib/perl5/5.22/CORE rstrip.sh now calls patchelf: $PATCHELF --set-rpath "/usr/lib/perl5/5.22/CORE" mod_perl.so Unfortunately the rpath is now broken: readelf -d mod_perl.so 0x00000001 (NEEDED) Shared library: [libstdc++.so.6] 0x00000001 (NEEDED) Shared library: [libc.so] 0x00000001 (NEEDED) Shared library: [libgcc_s.so.1] 0x0000000e (SONAME) Library soname: [mod_perl.so] 0x1d000000 (: 1d000000) 0x1399 0x0000000c (INIT) 0x46a8 The patchelf README says: "If only DT_RPATH is present, it is converted to DT_RUNPATH unless `--force-rpath' is specified." As no DT_RUNPATH element is visible either, I think we can assume this doesn't quite work. But when patchelf is invoked with --force-rpath in front of --set-rpath, then the result is fine: readelf -d mod_perl.so 0x00000001 (NEEDED) Shared library: [libgcc_s.so.1] 0x00000001 (NEEDED) Shared library: [libc.so] 0x0000000e (SONAME) Library soname: [mod_commands.so] 0x0000000f (RPATH) Library rpath: [/usr/lib/perl5/5.22/CORE] 0x0000000c (INIT) 0x3ec4 0x0000000d (FINI) 0x13f50 An alternative would be to first remove DT_RPATH and then add it again, because that works and the DT_RPATH is actually added as DT_RUNPATH. patchelf --remove-rpath mod_perl.so patchelf --set-rpath /usr/lib/perl5/5.22/CORE mod_perl.so readelf -d mod_perl.so 0x0000001d (RUNPATH) Library runpath: [/usr/lib/perl5/5.22/CORE] 0x00000001 (NEEDED) Shared library: [libperl.so] 0x00000001 (NEEDED) Shared library: [libgdbm.so.4] But as rstrip.sh only calls patchelf if it finds something it doesn't like, I don't see the point of currently doing that, because we'd have some binaries using DT_RUNPATH, others DT_RPATH. OTOH rstrip.sh could always remove DT_RPATH and add it again, so all binaries would use DT_RUNPATH. Anyway, I don't know the preference of OpenWrt/LEDE devs, so attached a patch with the quick fix that doesn't change the old behavior. Signed-off-by: Sebastian Kemper diff --git a/scripts/rstrip.sh b/scripts/rstrip.sh index 55caefc1a8..6edafe536a 100755 --- a/scripts/rstrip.sh +++ b/scripts/rstrip.sh @@ -38,7 +38,7 @@ find $TARGETS -type f -a -exec file {} \; | \ *) echo "$SELF: $F: removing rpath $path" ;; esac done - [ "$new_rpath" = "$old_rpath" ] || $PATCHELF --set-rpath "$new_rpath" $F + [ "$new_rpath" = "$old_rpath" ] || $PATCHELF --force-rpath --set-rpath "$new_rpath" $F } eval "$STRIP $F" a=$(stat -c '%a' $F)