From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1851) id 2347E3857C44; Fri, 21 May 2021 08:27:26 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2347E3857C44 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Martin Liska To: gcc-cvs@gcc.gnu.org Subject: [gcc(refs/users/marxin/heads/lto_priv-partial-linking)] LTO: add lto_priv suffixfor LTO_LINKER_OUTPUT_NOLTOREL. X-Act-Checkin: gcc X-Git-Author: Martin Liska X-Git-Refname: refs/users/marxin/heads/lto_priv-partial-linking X-Git-Oldrev: dcde81134cb24da8e261a4346c806c676297922b X-Git-Newrev: 372d2944571906932fd1419bfc51a949d67b857e Message-Id: <20210521082726.2347E3857C44@sourceware.org> Date: Fri, 21 May 2021 08:27:26 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 21 May 2021 08:27:26 -0000 https://gcc.gnu.org/g:372d2944571906932fd1419bfc51a949d67b857e commit 372d2944571906932fd1419bfc51a949d67b857e Author: Martin Liska Date: Fri May 21 10:25:49 2021 +0200 LTO: add lto_priv suffixfor LTO_LINKER_OUTPUT_NOLTOREL. gcc/lto/ChangeLog: * lto-partition.c (privatize_symbol_name_1): Add random suffix based on hash of the object file and -frandom-seed. Diff: --- gcc/lto/lto-partition.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/gcc/lto/lto-partition.c b/gcc/lto/lto-partition.c index 15761ac9eb5..fef48c869a2 100644 --- a/gcc/lto/lto-partition.c +++ b/gcc/lto/lto-partition.c @@ -35,6 +35,7 @@ along with GCC; see the file COPYING3. If not see #include "ipa-fnsummary.h" #include "lto-partition.h" #include "sreal.h" +#include "toplev.h" vec ltrans_partitions; @@ -941,9 +942,23 @@ privatize_symbol_name_1 (symtab_node *node, tree decl) name = maybe_rewrite_identifier (name); unsigned &clone_number = lto_clone_numbers->get_or_insert (name); - symtab->change_decl_assembler_name (decl, - clone_function_name ( - name, "lto_priv", clone_number)); + + char *suffix = NULL; + if (flag_lto_linker_output == LTO_LINKER_OUTPUT_NOLTOREL) + { + hashval_t fnhash = 0; + if (node->lto_file_data != NULL) + fnhash = htab_hash_string (node->lto_file_data->file_name); + suffix = XNEWVEC (char, 128); + char sep = symbol_table::symbol_suffix_separator (); + sprintf (suffix, "lto_priv%c%u%c%" PRIu64, sep, fnhash, sep, + (unsigned HOST_WIDE_INT)get_random_seed (false)); + } + + tree clone + = clone_function_name (name, suffix ? suffix : "lto_priv", clone_number); + symtab->change_decl_assembler_name (decl, clone); + free (suffix); clone_number++; if (node->lto_file_data)