From patchwork Tue Apr 16 12:07: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: 10902901 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 7AACE17E1 for ; Tue, 16 Apr 2019 12:11:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6195B287C0 for ; Tue, 16 Apr 2019 12:11:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 540C2289CA; Tue, 16 Apr 2019 12:11:18 +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 EFB41289D1 for ; Tue, 16 Apr 2019 12:11:17 +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 1hGMty-0000HD-Hs; Tue, 16 Apr 2019 12:09:26 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hGMtx-0000H5-9D for xen-devel@lists.xen.org; Tue, 16 Apr 2019 12:09:25 +0000 X-Inumbo-ID: 79045809-6040-11e9-92d7-bc764e045a96 Received: from smtp-fw-33001.amazon.com (unknown [207.171.190.10]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id 79045809-6040-11e9-92d7-bc764e045a96; Tue, 16 Apr 2019 12:09:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.de; i=@amazon.de; q=dns/txt; s=amazon201209; t=1555416564; x=1586952564; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=2uSYuau1/RpgGWuHrJjkQxuiufqVG6PyuR96NFLCe44=; b=XbAYNHtfc81BCsZUc0VyFRYuvGomZoly1u69xDoavqATJd7DA6WaS/we EfkFBD0BxdhGDd7nfGUSAxuek5HrBkkOV7Am+Mqce8Do4V3CelhGHt/rT 8O1QAQ6z0IKKwy30B8ZI76ykB/9Zw+pUSx84W1emafsK0PXn1R4iDjMR5 g=; X-IronPort-AV: E=Sophos;i="5.60,357,1549929600"; d="scan'208";a="794603038" Received: from sea3-co-svc-lb6-vlan2.sea.amazon.com (HELO email-inbound-relay-1e-57e1d233.us-east-1.amazon.com) ([10.47.22.34]) by smtp-border-fw-out-33001.sea14.amazon.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 16 Apr 2019 12:08:06 +0000 Received: from EX13MTAUEA001.ant.amazon.com (iad55-ws-svc-p15-lb9-vlan3.iad.amazon.com [10.40.159.166]) by email-inbound-relay-1e-57e1d233.us-east-1.amazon.com (8.14.7/8.14.7) with ESMTP id x3GC7eYx022932 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=FAIL); Tue, 16 Apr 2019 12:07:40 GMT Received: from EX13D05EUB001.ant.amazon.com (10.43.166.87) by EX13MTAUEA001.ant.amazon.com (10.43.61.82) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Tue, 16 Apr 2019 12:07:40 +0000 Received: from EX13MTAUWB001.ant.amazon.com (10.43.161.207) by EX13D05EUB001.ant.amazon.com (10.43.166.87) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Tue, 16 Apr 2019 12:07:39 +0000 Received: from dev-dsk-wipawel-1a-0c4e6d58.eu-west-1.amazon.com (10.4.134.33) by mail-relay.amazon.com (10.43.161.249) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Tue, 16 Apr 2019 12:07:36 +0000 From: Pawel Wieczorkiewicz To: Date: Tue, 16 Apr 2019 12:07:13 +0000 Message-ID: <20190416120716.26269-3-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 3/6] create-diff-object: Add is_special_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 This function determines, based on the given section name, if the sections belongs to the special sections category. It treats a name from the special_sections array as a prefix. Any sections whose name starts with special section prefix is considered a special section. Signed-off-by: Pawel Wieczorkiewicz Reviewed-by: Andra-Irina Paraschiv Reviewed-by: Bjoern Doebel Reviewed-by: Norbert Manthey --- common.c | 23 +++++++++++++++++++++++ common.h | 1 + 2 files changed, 24 insertions(+) diff --git a/common.c b/common.c index c968299..a2c860b 100644 --- a/common.c +++ b/common.c @@ -290,6 +290,29 @@ int is_referenced_section(const struct section *sec, const struct kpatch_elf *ke return false; } +int is_special_section(struct section *sec) +{ + static struct special_section_names { + const char *name; + } names[] = { + { .name = ".bug_frames" }, + { .name = ".fixup" }, + { .name = ".ex_table" }, + { .name = ".altinstructions" }, + { .name = ".altinstr_replacement" }, + { .name = ".livepatch.hooks" }, + { .name = NULL }, + }; + struct special_section_names *special; + + for (special = names; special->name; special++) { + if (!strncmp(sec->name, special->name, strlen(special->name))) + return true; + } + + 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 affe16b..6d38e88 100644 --- a/common.h +++ b/common.h @@ -152,6 +152,7 @@ int is_debug_section(struct section *sec); int is_rela_section(struct section *sec); int is_standard_section(struct section *sec); int is_referenced_section(const struct section *sec, const struct kpatch_elf *kelf); +int is_special_section(struct section *sec); int is_local_sym(struct symbol *sym); void rela_insn(struct section *sec, struct rela *rela, struct insn *insn);