From patchwork Thu Nov 24 09:49:20 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ross Lagerwall X-Patchwork-Id: 9445079 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 4531860235 for ; Thu, 24 Nov 2016 09:52:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 43D24276D7 for ; Thu, 24 Nov 2016 09:52:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 38508279E0; Thu, 24 Nov 2016 09:52:05 +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 54BC2276D7 for ; Thu, 24 Nov 2016 09:52:04 +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 1c9qep-0004vu-BJ; Thu, 24 Nov 2016 09:49:31 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1c9qeo-0004vn-FR for xen-devel@lists.xen.org; Thu, 24 Nov 2016 09:49:30 +0000 Received: from [85.158.143.35] by server-5.bemta-6.messagelabs.com id EE/23-19272-9A7B6385; Thu, 24 Nov 2016 09:49:29 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrHLMWRWlGSWpSXmKPExsXitHSDve7K7WY RBvMuCVss+biYxYHR4+ju30wBjFGsmXlJ+RUJrBndLUcZC5YJVjQd+cvcwLiDr4uRk0NCwF/i Zf8JZhCbTcBA4tal72C2iICsxOquOexdjFwczALNjBJbTyxkAkkIC7hLPGp9zQpiswioSpzsP cACYvMKeErM2d3DDjFUTuLmuU6wQUICahJvl5+BqhGUODnzCZjNLCAhcfDFC+YJjNyzkKRmIU ktYGRaxahRnFpUllqka2isl1SUmZ5RkpuYmaNraGCml5taXJyYnpqTmFSsl5yfu4kRGA4MQLC D8cuygEOMkhxMSqK8YovMIoT4kvJTKjMSizPii0pzUosPMcpwcChJ8JpvA8oJFqWmp1akZeYA AxMmLcHBoyTCu2krUJq3uCAxtzgzHSJ1ilFRSpyXCaRPACSRUZoH1waLhkuMslLCvIxAhwjxF KQW5WaWoMq/YhTnYFQS5o0DmcKTmVcCN/0V0GImoMWS34xBFpckIqSkGhh3Lav93Gqzb5LV13 u3f7+o/STa7Gka0LV45Y2538x5Furc7DG3Y39mwbLk184LckGB0dxV929WKjIpsP7x5L168RH 3xInuG/e5JTrf6Dn89URCpravxsygj4cPql7JvCB3Plw53/qv8DHVWUl2cncSYi5yKtkFsB3q m2CpsWDPz2P/l+xpvqShxFKckWioxVxUnAgAO3y9QIECAAA= X-Env-Sender: prvs=1295a69e4=ross.lagerwall@citrix.com X-Msg-Ref: server-13.tower-21.messagelabs.com!1479980967!44968199!1 X-Originating-IP: [66.165.176.63] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogNjYuMTY1LjE3Ni42MyA9PiAzMDYwNDg=\n, received_headers: No Received headers X-StarScan-Received: X-StarScan-Version: 9.0.16; banners=-,-,- X-VirusChecked: Checked Received: (qmail 47725 invoked from network); 24 Nov 2016 09:49:29 -0000 Received: from smtp02.citrix.com (HELO SMTP02.CITRIX.COM) (66.165.176.63) by server-13.tower-21.messagelabs.com with RC4-SHA encrypted SMTP; 24 Nov 2016 09:49:29 -0000 X-IronPort-AV: E=Sophos;i="5.31,690,1473120000"; d="scan'208";a="399976850" From: Ross Lagerwall To: Date: Thu, 24 Nov 2016 09:49:20 +0000 Message-ID: <1479980960-11046-1-git-send-email-ross.lagerwall@citrix.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 Cc: Ross Lagerwall , M A Young Subject: [Xen-devel] [PATCH 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.str* sections are now split by function. We could probably be smarter about including just the sections we need, but for now, include all .rodata.str* sections as is done for previous versions of GCC. This manifests itself as symbol error. E.g.: (XEN) Unknown symbol: .LC0 Signed-off-by: Ross Lagerwall Reported-by: M A Young --- 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;