From patchwork Wed Aug 21 08:20:41 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wieczorkiewicz, Pawel" X-Patchwork-Id: 11106081 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DB7081395 for ; Wed, 21 Aug 2019 08:23:24 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B77CF22DA7 for ; Wed, 21 Aug 2019 08:23:24 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=amazon.de header.i=@amazon.de header.b="IGx22fe8" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B77CF22DA7 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=amazon.de Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1i0LsE-0001T0-5K; Wed, 21 Aug 2019 08:21:42 +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 1i0LsC-0001PS-Ao for xen-devel@lists.xen.org; Wed, 21 Aug 2019 08:21:40 +0000 X-Inumbo-ID: ade9578e-c3ec-11e9-adc2-12813bfff9fa Received: from smtp-fw-6001.amazon.com (unknown [52.95.48.154]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id ade9578e-c3ec-11e9-adc2-12813bfff9fa; Wed, 21 Aug 2019 08:21:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.de; i=@amazon.de; q=dns/txt; s=amazon201209; t=1566375690; x=1597911690; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=SpnBPboP1CnYCqUkqCRpzA3Mo3QOK41CZ1FNd6HCGVo=; b=IGx22fe8Zk3HTWW4P/d6J3x5EMTKblXM7F1Mdl4jrs8/I1YN7TjlIRm5 SugpMlaW+AosAXhmfdeXaiN1j5ruIhM6yo8YPldw6vMVnyxI7g8JTBmaQ dd79waonKKSggHCbG/SnSj3/9Lzttpfjc4yGVPVjShM0nx8drEQe4FVwk k=; X-IronPort-AV: E=Sophos;i="5.64,412,1559520000"; d="scan'208";a="410765145" Received: from iad6-co-svc-p1-lb1-vlan3.amazon.com (HELO email-inbound-relay-2b-55156cd4.us-west-2.amazon.com) ([10.124.125.6]) by smtp-border-fw-out-6001.iad6.amazon.com with ESMTP; 21 Aug 2019 08:21:29 +0000 Received: from EX13MTAUEA001.ant.amazon.com (pdx4-ws-svc-p6-lb7-vlan2.pdx.amazon.com [10.170.41.162]) by email-inbound-relay-2b-55156cd4.us-west-2.amazon.com (Postfix) with ESMTPS id 65D53A1F4A; Wed, 21 Aug 2019 08:21:29 +0000 (UTC) Received: from EX13D03EUA004.ant.amazon.com (10.43.165.93) by EX13MTAUEA001.ant.amazon.com (10.43.61.82) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Wed, 21 Aug 2019 08:21:14 +0000 Received: from EX13MTAUEB001.ant.amazon.com (10.43.60.96) by EX13D03EUA004.ant.amazon.com (10.43.165.93) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Wed, 21 Aug 2019 08:21:13 +0000 Received: from dev-dsk-wipawel-1a-0c4e6d58.eu-west-1.amazon.com (10.4.134.33) by mail-relay.amazon.com (10.43.60.129) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Wed, 21 Aug 2019 08:21:11 +0000 From: Pawel Wieczorkiewicz To: Date: Wed, 21 Aug 2019 08:20:41 +0000 Message-ID: <20190821082056.91090-6-wipawel@amazon.de> X-Mailer: git-send-email 2.16.5 In-Reply-To: <20190821082056.91090-1-wipawel@amazon.de> References: <20190821082056.91090-1-wipawel@amazon.de> MIME-Version: 1.0 Precedence: Bulk Subject: [Xen-devel] [PATCH 05/20] 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: wipawel@amazon.com, Konrad Rzeszutek Wilk , Andrew Cooper , Ross Lagerwall , mpohlack@amazon.com, Pawel Wieczorkiewicz Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" 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 --- 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)