From patchwork Mon Dec 12 14:55:51 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ross Lagerwall X-Patchwork-Id: 9470799 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 6A79860573 for ; Mon, 12 Dec 2016 14:58:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5D0F6284AA for ; Mon, 12 Dec 2016 14:58:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 519ED284B2; Mon, 12 Dec 2016 14:58:08 +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, 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 AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 6F841284AA for ; Mon, 12 Dec 2016 14:58:07 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cGS1H-0000ob-Ht; Mon, 12 Dec 2016 14:55:59 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cGS1G-0000oV-Ey for xen-devel@lists.xen.org; Mon, 12 Dec 2016 14:55:58 +0000 Received: from [85.158.143.35] by server-4.bemta-6.messagelabs.com id 29/34-28568-D7ABE485; Mon, 12 Dec 2016 14:55:57 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrDLMWRWlGSWpSXmKPExsXitHRDpG7tLr8 Ig5aXvBZLPi5mcWD0OLr7N1MAYxRrZl5SfkUCa8btDdvZCxYLVrz8fZelgXErXxcjJ4eEgL/E zZb9jCA2m4CBxK1L35lBbBEBWYnVXXPYQWxmgXiJ9XMmsnYxcnAIC3hJnJtiBxJmEVCVuPvtB Vgrr4CHRMvSlywQI+Ukbp7rBBsjJKAm8Xb5GRaIGkGJkzOfsECMlJA4+OIF8wRG7llIUrOQpB YwMq1i1ChOLSpLLdI1NNRLKspMzyjJTczM0TU0MNPLTS0uTkxPzUlMKtZLzs/dxAgMBQYg2MH 4aVnAIUZJDiYlUd4f3n4RQnxJ+SmVGYnFGfFFpTmpxYcYZTg4lCR41+wEygkWpaanVqRl5gCD EiYtwcGjJMLbB5LmLS5IzC3OTIdInWJUlBLnDQdJCIAkMkrz4NpgkXCJUVZKmJcR6BAhnoLUo tzMElT5V4ziHIxKwrzNIFN4MvNK4Ka/AlrMBLT4+T5vkMUliQgpqQbGaDuDtMaNyvZvjnV/0l +xd2PKB9eAiGIrHe+C+6UfDokkS/qEXd52//TB9eo97NIpxWvOitj0xjuF7PsRKMLgv8ci9db c+ukCt+uf1rGIqwg6MTS3PgnRbMtYFLfFobWwfaLgi3mvVO7v8Gy/9Lgmhe3QiaD0S7KTy75k 8HFNWlYdozLh6DwlluKMREMt5qLiRABX9KFcfwIAAA== X-Env-Sender: prvs=147044df7=ross.lagerwall@citrix.com X-Msg-Ref: server-5.tower-21.messagelabs.com!1481554555!39862805!1 X-Originating-IP: [66.165.176.89] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogNjYuMTY1LjE3Ni44OSA9PiAyMDMwMDc=\n, received_headers: No Received headers X-StarScan-Received: X-StarScan-Version: 9.1.1; banners=-,-,- X-VirusChecked: Checked Received: (qmail 61957 invoked from network); 12 Dec 2016 14:55:56 -0000 Received: from smtp.citrix.com (HELO SMTP.CITRIX.COM) (66.165.176.89) by server-5.tower-21.messagelabs.com with RC4-SHA encrypted SMTP; 12 Dec 2016 14:55:56 -0000 X-IronPort-AV: E=Sophos;i="5.33,336,1477958400"; d="scan'208";a="394285029" From: Ross Lagerwall To: Date: Mon, 12 Dec 2016 14:55:51 +0000 Message-ID: <1481554551-2116-1-git-send-email-ross.lagerwall@citrix.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 Cc: Ross Lagerwall Subject: [Xen-devel] [PATCH v2 LIVEPATCH-BUILD-TOOLS] Fix patch creation with GCC 6.1+ X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP GCC 6.1+ fixed https://gcc.gnu.org/bugzilla/show_bug.cgi?id=192 which means that .rodata.str1.[0-9]+ sections are now split by function. We could probably be smarter about including just the sections we need, but for now, simply include the string sections for all functions as is done for previous versions of GCC. Signed-off-by: Ross Lagerwall Reported-by: M A Young Reviewed-by: Konrad Rzeszutek Wilk --- Changed in v2: * Clarified commit message. create-diff-object.c | 39 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/create-diff-object.c b/create-diff-object.c index 69bcd88..b0d1348 100644 --- a/create-diff-object.c +++ b/create-diff-object.c @@ -1184,6 +1184,43 @@ static void kpatch_process_special_sections(struct kpatch_elf *kelf) } } +/* Returns true if s is a string of only numbers with length > 0. */ +static int isnumber(const char *s) +{ + do { + if (!*s || !isdigit(*s)) + return 0; + } while (*++s); + + return 1; +} + +/* + * String sections are always included even if unchanged. + * The format is either: + * .rodata..str1.[0-9]+ (new in GCC 6.1.0) + * or .rodata.str1.[0-9]+ (older versions of GCC) + * For the new format we could be smarter and only include the needed + * strings sections. + */ +static int should_include_str_section(const char *name) +{ + const char *s; + + if (strncmp(name, ".rodata.", 8)) + return 0; + + /* Check if name matches ".rodata.str1.[0-9]+" */ + if (!strncmp(name, ".rodata.str1.", 13)) + return isnumber(name + 13); + + /* Check if name matches ".rodata..str1.[0-9]+" */ + s = strstr(name, ".str1."); + if (!s) + return 0; + return isnumber(s + 6); +} + static void kpatch_include_standard_elements(struct kpatch_elf *kelf) { struct section *sec; @@ -1193,7 +1230,7 @@ static void kpatch_include_standard_elements(struct kpatch_elf *kelf) if (!strcmp(sec->name, ".shstrtab") || !strcmp(sec->name, ".strtab") || !strcmp(sec->name, ".symtab") || - !strncmp(sec->name, ".rodata.str1.", 13)) { + should_include_str_section(sec->name)) { sec->include = 1; if (sec->secsym) sec->secsym->include = 1;