From patchwork Wed Aug 14 11:53:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wieczorkiewicz, Pawel" X-Patchwork-Id: 11093809 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B5EBE1398 for ; Wed, 14 Aug 2019 11:55:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A2FC4287CB for ; Wed, 14 Aug 2019 11:55:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 964FC287D1; Wed, 14 Aug 2019 11:55:28 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00,DKIM_ADSP_ALL, DKIM_INVALID,DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 3DA46287CB for ; Wed, 14 Aug 2019 11:55:28 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hxrqs-0006AK-8e; Wed, 14 Aug 2019 11:54:02 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hxrqr-0006AF-2A for xen-devel@lists.xen.org; Wed, 14 Aug 2019 11:54:01 +0000 X-Inumbo-ID: 335475ba-be8a-11e9-807d-0fe6c326b3ab Received: from smtp-fw-33001.amazon.com (unknown [207.171.190.10]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 335475ba-be8a-11e9-807d-0fe6c326b3ab; Wed, 14 Aug 2019 11:53:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.de; i=@amazon.de; q=dns/txt; s=amazon201209; t=1565783638; x=1597319638; h=from:to:cc:subject:date:message-id:mime-version; bh=HMLHaYGnYdsl4+f8w+M2LsBhl1+9LxdtIOk2BKjFp5w=; b=allSIOYYMslgGHDCbjcDq42vvmcuIdg701p/bYMMLxgIm+8xPhHDLCE4 xsk0HYEQYh/r49xBLsBWalxRPlneCkKxLS3Vm1Q9GS69Vpji2IOYra5jQ ivfhSs+EGmD4C09IAWOMfs14QE5Fq3R+iA3WgjrLTrZbScuqRC+gbmZnq s=; X-IronPort-AV: E=Sophos;i="5.64,385,1559520000"; d="scan'208";a="819776381" Received: from sea3-co-svc-lb6-vlan2.sea.amazon.com (HELO email-inbound-relay-2a-6e2fc477.us-west-2.amazon.com) ([10.47.22.34]) by smtp-border-fw-out-33001.sea14.amazon.com with ESMTP; 14 Aug 2019 11:53:32 +0000 Received: from EX13MTAUEA001.ant.amazon.com (pdx4-ws-svc-p6-lb7-vlan2.pdx.amazon.com [10.170.41.162]) by email-inbound-relay-2a-6e2fc477.us-west-2.amazon.com (Postfix) with ESMTPS id 00170A23C0; Wed, 14 Aug 2019 11:53:31 +0000 (UTC) Received: from EX13D03EUA001.ant.amazon.com (10.43.165.33) by EX13MTAUEA001.ant.amazon.com (10.43.61.82) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Wed, 14 Aug 2019 11:53:31 +0000 Received: from EX13MTAUWA001.ant.amazon.com (10.43.160.58) by EX13D03EUA001.ant.amazon.com (10.43.165.33) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Wed, 14 Aug 2019 11:53:30 +0000 Received: from dev-dsk-wipawel-1a-0c4e6d58.eu-west-1.amazon.com (10.4.134.33) by mail-relay.amazon.com (10.43.160.118) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Wed, 14 Aug 2019 11:53:28 +0000 From: Pawel Wieczorkiewicz To: Date: Wed, 14 Aug 2019 11:53:13 +0000 Message-ID: <20190814115314.12271-1-wipawel@amazon.de> X-Mailer: git-send-email 2.16.5 MIME-Version: 1.0 Precedence: Bulk Subject: [Xen-devel] [PATCH livepatch-strip 1/2] livepatch-build: Strip transient or unneeded symbols X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: mpohlack@amazon.de, ross.lagerwall@citrix.com, wipawel@amazon.de, konrad.wilk@oracle.com Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP In the process of creating a final hotpatch module file make sure to strip all transient symbols that have not been caught and removed by create-diff-object processing. For now these are only the hooks kpatch load/unload symbols. For all new object files that are carried along for the final linking the transient hooks symbols are not stripped and neither are any unneeded symbols. Strip them explicitly from resulting object file. Signed-off-by: Pawel Wieczorkiewicz --- livepatch-build | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/livepatch-build b/livepatch-build index 3f0530e..cc71640 100755 --- a/livepatch-build +++ b/livepatch-build @@ -111,6 +111,28 @@ function build_special() unset LIVEPATCH_CAPTURE_DIR } +strip_extra_symbols () +{ + local -r FILE="$1" + local -a STRIP_CMD_OPTS=() + local -a SYM_PREFIX=("livepatch_load_data_" + "livepatch_unload_data_" + "livepatch_preapply_data_" + "livepatch_apply_data_" + "livepatch_postapply_data_" + "livepatch_prerevert_data_" + "livepatch_revert_data_" + "livepatch_postrevert_data_") + + STRIP_CMD_OPTS+=("-w") + for sym in "${SYM_PREFIX[@]}"; do + STRIP_CMD_OPTS+=("-N") + STRIP_CMD_OPTS+=("\"${sym}*\"") + done + + strip "${STRIP_CMD_OPTS[@]}" "$FILE" +} + function create_patch() { echo "Extracting new and modified ELF sections..." @@ -150,6 +172,7 @@ function create_patch() NEW_FILES=$(comm -23 <(cd patched/xen && find . -type f -name '*.o' | sort) <(cd original/xen && find . -type f -name '*.o' | sort)) for i in $NEW_FILES; do cp "patched/$i" "output/$i" + strip --strip-unneeded "output/$i" CHANGED=1 done @@ -176,6 +199,8 @@ function create_patch() "${TOOLSDIR}"/prelink $debugopt output.o "${PATCHNAME}.livepatch" "$XENSYMS" &>> "${OUTPUT}/prelink.log" || die fi + strip_extra_symbols "${PATCHNAME}.livepatch" + objcopy --add-section .livepatch.depends=depends.bin "${PATCHNAME}.livepatch" objcopy --set-section-flags .livepatch.depends=alloc,readonly "${PATCHNAME}.livepatch"