From patchwork Sat Jun 16 03:07:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Marchi X-Patchwork-Id: 27887 Received: (qmail 94566 invoked by alias); 16 Jun 2018 03:07:58 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 94546 invoked by uid 89); 16 Jun 2018 03:07:57 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.2 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_SOFTFAIL autolearn=ham version=3.3.2 spammy=H*Ad:U*amodra, DEST, strcat, 2018-05-30 X-HELO: barracuda.ebox.ca Received: from barracuda.ebox.ca (HELO barracuda.ebox.ca) (96.127.255.19) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 16 Jun 2018 03:07:56 +0000 X-ASG-Debug-ID: 1529118470-0c856e7f58384af0001-fS2M51 Received: from smtp.ebox.ca (smtp.electronicbox.net [96.127.255.82]) by barracuda.ebox.ca with ESMTP id PR4bnDkGFuAuAhFt (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 15 Jun 2018 23:07:50 -0400 (EDT) X-Barracuda-Envelope-From: simon.marchi@polymtl.ca X-Barracuda-RBL-Trusted-Forwarder: 96.127.255.82 Received: from localhost.localdomain (unknown [192.222.164.54]) by smtp.ebox.ca (Postfix) with ESMTP id 05D68441D64; Fri, 15 Jun 2018 23:07:50 -0400 (EDT) From: Simon Marchi X-Barracuda-Effective-Source-IP: 192-222-164-54.qc.cable.ebox.net[192.222.164.54] X-Barracuda-Apparent-Source-IP: 192.222.164.54 X-Barracuda-RBL-IP: 192.222.164.54 To: gdb-patches@sourceware.org, binutils@sourceware.org Cc: Nick Clifton , Alan Modra , Joseph Myers , Simon Marchi Subject: [PATCH 2/4] libiberty: Sync with GCC Date: Fri, 15 Jun 2018 23:07:42 -0400 X-ASG-Orig-Subj: [PATCH 2/4] libiberty: Sync with GCC Message-Id: <20180616030744.12913-3-simon.marchi@polymtl.ca> In-Reply-To: <20180616030744.12913-1-simon.marchi@polymtl.ca> References: <20180616030744.12913-1-simon.marchi@polymtl.ca> X-Barracuda-Connect: smtp.electronicbox.net[96.127.255.82] X-Barracuda-Start-Time: 1529118470 X-Barracuda-Encrypted: DHE-RSA-AES256-SHA X-Barracuda-URL: https://96.127.255.19:443/cgi-mod/mark.cgi X-Barracuda-Scan-Msg-Size: 5564 X-Barracuda-BRTS-Status: 1 X-Barracuda-Spam-Score: 0.00 X-Barracuda-Spam-Status: No, SCORE=0.00 using global scores of TAG_LEVEL=1000.0 QUARANTINE_LEVEL=1000.0 KILL_LEVEL=8.0 tests= X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.3.52001 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- X-IsSubscribed: yes From: Simon Marchi Also sync include/simple-object.h, which goes together with the change in libiberty. --- include/simple-object.h | 5 ++++- libiberty/ChangeLog | 7 ++++++ libiberty/simple-object.c | 45 +++++++++++++++++++++++++++++---------- 3 files changed, 45 insertions(+), 12 deletions(-) diff --git a/include/simple-object.h b/include/simple-object.h index db72f86de179..496d8cc107e7 100644 --- a/include/simple-object.h +++ b/include/simple-object.h @@ -198,12 +198,15 @@ extern void simple_object_release_write (simple_object_write *); /* Copy LTO debug sections from SRC_OBJECT to DEST. + If RENAME is true, rename LTO debug section into debug section (i.e. + when producing final binary) and if it is false, keep the sections with + original names (when incrementally linking). If an error occurs, return the errno value in ERR and an error string. */ extern const char * simple_object_copy_lto_debug_sections (simple_object_read *src_object, const char *dest, - int *err); + int *err, int rename); #ifdef __cplusplus } diff --git a/libiberty/ChangeLog b/libiberty/ChangeLog index 19c62699c07a..578da58181f5 100644 --- a/libiberty/ChangeLog +++ b/libiberty/ChangeLog @@ -1,3 +1,10 @@ +2018-05-30 Jan Hubicka + + * simple-object.c (handle_lto_debug_sections): Add rename parameter. + (handle_lto_debug_sections_rename): New function. + (handle_lto_debug_sections_norename): New function. + (simple_object_copy_lto_debug_sections): Add rename parameter. + 2018-05-28 Bernd Edlinger * splay-tree.c (splay_tree_compare_strings, diff --git a/libiberty/simple-object.c b/libiberty/simple-object.c index 42aa6ac4e609..82a8cff9644b 100644 --- a/libiberty/simple-object.c +++ b/libiberty/simple-object.c @@ -251,12 +251,15 @@ simple_object_find_section (simple_object_read *sobj, const char *name, } /* Callback to identify and rename LTO debug sections by name. - Returns 1 if NAME is a LTO debug section, 0 if not. */ + Returns non-NULL if NAME is a LTO debug section, NULL if not. + If RENAME is true it will rename LTO debug sections to non-LTO + ones. */ static char * -handle_lto_debug_sections (const char *name) +handle_lto_debug_sections (const char *name, int rename) { - char *newname = XCNEWVEC (char, strlen (name) + 1); + char *newname = rename ? XCNEWVEC (char, strlen (name) + 1) + : xstrdup (name); /* ??? So we can't use .gnu.lto_ prefixed sections as the assembler complains about bogus section flags. Which means we need to arrange @@ -265,22 +268,24 @@ handle_lto_debug_sections (const char *name) /* Also include corresponding reloc sections. */ if (strncmp (name, ".rela", sizeof (".rela") - 1) == 0) { - strncpy (newname, name, sizeof (".rela") - 1); + if (rename) + strncpy (newname, name, sizeof (".rela") - 1); name += sizeof (".rela") - 1; } else if (strncmp (name, ".rel", sizeof (".rel") - 1) == 0) { - strncpy (newname, name, sizeof (".rel") - 1); + if (rename) + strncpy (newname, name, sizeof (".rel") - 1); name += sizeof (".rel") - 1; } /* ??? For now this handles both .gnu.lto_ and .gnu.debuglto_ prefixed sections. */ /* Copy LTO debug sections and rename them to their non-LTO name. */ if (strncmp (name, ".gnu.debuglto_", sizeof (".gnu.debuglto_") - 1) == 0) - return strcat (newname, name + sizeof (".gnu.debuglto_") - 1); + return rename ? strcat (newname, name + sizeof (".gnu.debuglto_") - 1) : newname; else if (strncmp (name, ".gnu.lto_.debug_", sizeof (".gnu.lto_.debug_") -1) == 0) - return strcat (newname, name + sizeof (".gnu.lto_") - 1); + return rename ? strcat (newname, name + sizeof (".gnu.lto_") - 1) : newname; /* Copy over .note.GNU-stack section under the same name if present. */ else if (strcmp (name, ".note.GNU-stack") == 0) return strcpy (newname, name); @@ -289,14 +294,31 @@ handle_lto_debug_sections (const char *name) COMDAT sections in objects produced by GCC. */ else if (strcmp (name, ".comment") == 0) return strcpy (newname, name); + free (newname); return NULL; } +/* Wrapper for handle_lto_debug_sections. */ + +static char * +handle_lto_debug_sections_rename (const char *name) +{ + return handle_lto_debug_sections (name, 1); +} + +/* Wrapper for handle_lto_debug_sections. */ + +static char * +handle_lto_debug_sections_norename (const char *name) +{ + return handle_lto_debug_sections (name, 0); +} + /* Copy LTO debug sections. */ const char * simple_object_copy_lto_debug_sections (simple_object_read *sobj, - const char *dest, int *err) + const char *dest, int *err, int rename) { const char *errmsg; simple_object_write *dest_sobj; @@ -317,9 +339,10 @@ simple_object_copy_lto_debug_sections (simple_object_read *sobj, if (! dest_sobj) return errmsg; - errmsg = sobj->functions->copy_lto_debug_sections (sobj, dest_sobj, - handle_lto_debug_sections, - err); + errmsg = sobj->functions->copy_lto_debug_sections + (sobj, dest_sobj, + rename ? handle_lto_debug_sections_rename + : handle_lto_debug_sections_norename, err); if (errmsg) { simple_object_release_write (dest_sobj);