From patchwork Wed Aug 7 11:32:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wieczorkiewicz, Pawel" X-Patchwork-Id: 11081927 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 694C2112C for ; Wed, 7 Aug 2019 11:34:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 552CC289E8 for ; Wed, 7 Aug 2019 11:34:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4478A289F1; Wed, 7 Aug 2019 11:34:10 +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 D81C5289E8 for ; Wed, 7 Aug 2019 11:34:09 +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 1hvKBN-0001xv-Ji; Wed, 07 Aug 2019 11:32:41 +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 1hvKBM-0001xq-82 for xen-devel@lists.xen.org; Wed, 07 Aug 2019 11:32:40 +0000 X-Inumbo-ID: 0f83928e-b907-11e9-9c35-0f0d476548fa Received: from smtp-fw-2101.amazon.com (unknown [72.21.196.25]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 0f83928e-b907-11e9-9c35-0f0d476548fa; Wed, 07 Aug 2019 11:32:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.de; i=@amazon.de; q=dns/txt; s=amazon201209; t=1565177559; x=1596713559; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=H7icvKm2pSSMMeV2NPmMrQxPbsW2XsLifMKx2xY4NwM=; b=RWl67GGIaYTnpAQmGqiEzerB3kgZ2nj4kisz2Fv1UZ1ZlMiGJacl1yhl Seah0abl/6NLaQ7KPGtZUA1szVPYPI7kYt8PATRhO19jAcD7NVBedsKlG UmJOv+14d7deK7Oh8daSedobWi28TvOH1Q5mN60IIko7q9Hnv3FqngB+G 4=; X-IronPort-AV: E=Sophos;i="5.64,357,1559520000"; d="scan'208";a="745591285" Received: from iad6-co-svc-p1-lb1-vlan2.amazon.com (HELO email-inbound-relay-2a-8549039f.us-west-2.amazon.com) ([10.124.125.2]) by smtp-border-fw-out-2101.iad2.amazon.com with ESMTP; 07 Aug 2019 11:32:37 +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-8549039f.us-west-2.amazon.com (Postfix) with ESMTPS id E7396A2738; Wed, 7 Aug 2019 11:32:36 +0000 (UTC) Received: from EX13D05EUB004.ant.amazon.com (10.43.166.115) by EX13MTAUEA001.ant.amazon.com (10.43.61.243) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Wed, 7 Aug 2019 11:32:36 +0000 Received: from EX13MTAUEE001.ant.amazon.com (10.43.62.200) by EX13D05EUB004.ant.amazon.com (10.43.166.115) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Wed, 7 Aug 2019 11:32:35 +0000 Received: from dev-dsk-wipawel-1a-0c4e6d58.eu-west-1.amazon.com (10.4.134.33) by mail-relay.amazon.com (10.43.62.226) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Wed, 7 Aug 2019 11:32:34 +0000 From: Pawel Wieczorkiewicz To: Date: Wed, 7 Aug 2019 11:32:19 +0000 Message-ID: <20190807113219.71570-1-wipawel@amazon.de> X-Mailer: git-send-email 2.16.5 In-Reply-To: <20190416120716.26269-1-wipawel@amazon.de> References: <20190416120716.26269-1-wipawel@amazon.de> MIME-Version: 1.0 Precedence: Bulk Subject: [Xen-devel] [livepatch-build-tools part2 v2 1/6] common: Add is_standard_section() helper function 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, Pawel Wieczorkiewicz , konrad.wilk@oracle.com Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP Detect standard (always to be included) sections via their section header type. The standard sections: ".shstrtab", ".symtab", ".strtab" are either of type SHT_SYMTAB or SHT_STRTAB. Signed-off-by: Pawel Wieczorkiewicz Reviewed-by: Andra-Irina Paraschiv Reviewed-by: Bjoern Doebel Reviewed-by: Norbert Manthey Reviewed-by: Ross Lagerwall --- v2: * Keep lines to 80 chars --- common.c | 12 ++++++++++++ common.h | 1 + create-diff-object.c | 4 +--- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/common.c b/common.c index bc63955..1fb07cb 100644 --- a/common.c +++ b/common.c @@ -5,6 +5,7 @@ #include #include #include +#include #include #include "list.h" @@ -258,6 +259,17 @@ int is_debug_section(struct section *sec) return !strncmp(name, ".debug_", 7); } +int is_standard_section(struct section *sec) +{ + switch (sec->sh.sh_type) { + case SHT_STRTAB: + case SHT_SYMTAB: + return true; + default: + return false; + } +} + /* returns the offset of the string in the string table */ int offset_of_string(struct list_head *list, char *name) { diff --git a/common.h b/common.h index 7599fe7..cda690d 100644 --- a/common.h +++ b/common.h @@ -150,6 +150,7 @@ struct symbol *find_symbol_by_name(struct list_head *list, const char *name); int is_text_section(struct section *sec); int is_debug_section(struct section *sec); int is_rela_section(struct section *sec); +int is_standard_section(struct section *sec); int is_local_sym(struct symbol *sym); void rela_insn(struct section *sec, struct rela *rela, struct insn *insn); diff --git a/create-diff-object.c b/create-diff-object.c index 82f777e..4699ba0 100644 --- a/create-diff-object.c +++ b/create-diff-object.c @@ -1278,9 +1278,7 @@ static void kpatch_include_standard_elements(struct kpatch_elf *kelf) list_for_each_entry(sec, &kelf->sections, list) { /* include these sections even if they haven't changed */ - if (!strcmp(sec->name, ".shstrtab") || - !strcmp(sec->name, ".strtab") || - !strcmp(sec->name, ".symtab") || + if (is_standard_section(sec) || should_include_str_section(sec->name)) { sec->include = 1; if (sec->secsym)