From patchwork Mon Jul 13 21:55:09 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Martin X-Patchwork-Id: 494783 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by ozlabs.org (Postfix) with ESMTP id CF5E11402A9 for ; Tue, 14 Jul 2015 07:55:47 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=lh/coZce; dkim-atps=neutral Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id E5AD633718; Mon, 13 Jul 2015 21:55:46 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id K3kPTt73JI6P; Mon, 13 Jul 2015 21:55:40 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by silver.osuosl.org (Postfix) with ESMTP id 43DA13366C; Mon, 13 Jul 2015 21:55:26 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by ash.osuosl.org (Postfix) with ESMTP id 583EC1C2893 for ; Mon, 13 Jul 2015 21:55:22 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id 55BC895620 for ; Mon, 13 Jul 2015 21:55:22 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from hemlock.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id eTPXGDAEqowt for ; Mon, 13 Jul 2015 21:55:22 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-wi0-f179.google.com (mail-wi0-f179.google.com [209.85.212.179]) by hemlock.osuosl.org (Postfix) with ESMTPS id A73EF95670 for ; Mon, 13 Jul 2015 21:55:21 +0000 (UTC) Received: by wibud3 with SMTP id ud3so7736258wib.0 for ; Mon, 13 Jul 2015 14:55:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=NO25Lfz8PswRC1WeVjM9mfOpH52fOVnHcFhOdgzpuTU=; b=lh/coZcegIAJe8OKZzyPCP2pkaCm7YuOB5OYKbSsJNOperLgH81cYu8eBnkJxLP+W3 YSthWVTLzzE9o1jh1ctbHonvWHgqzGvbKgHdCq4V58ptJv0YjaUB6P31HCZt1JZJTGgA A3PryD4VDLUEAPDvV9Q8gW9nVXrZEmSePudzOVv4KbD9cX7yFvYtsuvAaSouU9ACPyD1 nixGqTFpvE1jxZWfJOpV4KWegsFwbPVb/Ns1DC9V0xBiEwgofq3iZntlmRz1Lw+4ff5z x6PwDIzECcL+/9NPLl5qv+W65ONUos2e7JW2M2Y2Quovsmeahp572OamkoBtaA0J3D5f xdVQ== X-Received: by 10.180.85.194 with SMTP id j2mr26548387wiz.11.1436824520297; Mon, 13 Jul 2015 14:55:20 -0700 (PDT) Received: from bobook.localdomain (AToulouse-657-1-1031-128.w92-134.abo.wanadoo.fr. [92.134.9.128]) by smtp.gmail.com with ESMTPSA id j7sm31499888wjz.11.2015.07.13.14.55.19 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 13 Jul 2015 14:55:19 -0700 (PDT) From: Samuel Martin To: buildroot@buildroot.org Date: Mon, 13 Jul 2015 23:55:09 +0200 Message-Id: <1436824511-1601-3-git-send-email-s.martin49@gmail.com> X-Mailer: git-send-email 2.4.5 In-Reply-To: <1436824511-1601-1-git-send-email-s.martin49@gmail.com> References: <1436824511-1601-1-git-send-email-s.martin49@gmail.com> Subject: [Buildroot] [PATCH v5 3/5] Makefile: add TARGET_SANITIZE_RPATH_HOOK to TARGET_FINALIZE_HOOKS X-BeenThere: buildroot@busybox.net X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Discussion and development of buildroot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: buildroot-bounces@busybox.net Sender: "buildroot" This patch introduces the TARGET_SANITIZE_RPATH_HOOK hook fixing the ELF files' RPATH of the TARGET_DIR (excluding the sysroot). After running this hook, the RPATH from any target ELF files won't contain any occurence of the sysroot or some build locations. Signed-off-by: Samuel Martin Tested-by: Baruch Siach --- changes v4->v5: - target hook now sanitizes the rpath (Baruch) - add verbose support - update comment changes v3->v4: - rebase - add comment changes v2->v3: - move hook in Makefile (Baruch) --- Makefile | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/Makefile b/Makefile index 4b88116..69c1105 100644 --- a/Makefile +++ b/Makefile @@ -558,6 +558,8 @@ endif # RPATH fixing # - The host hook sets RPATH in host ELF binaries, using relative paths to the # library locations. +# - The target hook sanitizes RPATH in target ELF binaries, removing pathes +# pointing to package's build directories or the sysroot's libdirs. PACKAGES += host-patchelf define HOST_FIX_RPATH_HOOK @@ -571,6 +573,17 @@ endef TARGET_FINALIZE_HOOKS += HOST_FIX_RPATH_HOOK +define TARGET_SANITIZE_RPATH_HOOK + $(TOPDIR)/support/scripts/fix_rpaths \ + sanitize $(TARGET_DIR) \ + $(if $(V),--verbose) \ + --patchelf-program $(HOST_DIR)/usr/bin/patchelf \ + --patterns "($(STAGING_DIR)|`readlink -f $(STAGING_DIR)`)/(usr/)?lib$$" \ + "($(BUILD_DIR)|`readlink -f $(BUILD_DIR)`)/.*" +endef + +TARGET_FINALIZE_HOOKS += TARGET_SANITIZE_RPATH_HOOK + $(TARGETS_ROOTFS): target-finalize target-finalize: $(PACKAGES)