Commit 40ebe1fc by Jan Hubicka Committed by Jan Hubicka

Fix symver attribute with LTO

	* cgraph.c (cgraph_node_cannot_be_local_p_1): Prevent targets of
	symver attributes to be localized.
	* ipa-visibility.c (cgraph_externally_visible_p,
	varpool_node::externally_visible_p): Likewise.
	* symtab.c (symtab_node::verify_base): Check visibility of symbol
	versions.

	* lto-common.c (read_cgraph_and_symbols): Work around binutils
	PR25424


Co-Authored-By: Xi Ruoyao <xry111@mengyan1223.wang>

From-SVN: r279566
parent 44fca832
2019-12-19 Jan Hubicka <hubicka@ucw.cz>
Xi Ruoyao <xry111@mengyan1223.wang>
* cgraph.c (cgraph_node_cannot_be_local_p_1): Prevent targets of
symver attributes to be localized.
* ipa-visibility.c (cgraph_externally_visible_p,
varpool_node::externally_visible_p): Likewise.
* symtab.c (symtab_node::verify_base): Check visibility of symbol
versions.
2019-12-19 Jan Hubicka <hubicka@ucw.cz>
Luo Xiong Hu <luoxhu@linux.ibm.com
* ipa-fnsummary.h (ipa_size_summary): Remove copy consturctor.
......@@ -2226,6 +2226,9 @@ cgraph_node_cannot_be_local_p_1 (cgraph_node *node, void *)
{
return !(!node->force_output
&& !node->ifunc_resolver
/* Limitation of gas requires us to output targets of symver aliases
as global symbols. This is binutils PR 25295. */
&& !node->symver
&& ((DECL_COMDAT (node->decl)
&& !node->forced_by_abi
&& !node->used_from_object_file_p ()
......
......@@ -220,6 +220,14 @@ cgraph_externally_visible_p (struct cgraph_node *node,
&& lookup_attribute ("dllexport",
DECL_ATTRIBUTES (node->decl)))
return true;
/* Limitation of gas requires us to output targets of symver aliases as
global symbols. This is binutils PR 25295. */
ipa_ref *ref;
FOR_EACH_ALIAS (node, ref)
if (ref->referring->symver)
return true;
if (node->resolution == LDPR_PREVAILING_DEF_IRONLY)
return false;
/* When doing LTO or whole program, we can bring COMDAT functoins static.
......@@ -284,14 +292,13 @@ varpool_node::externally_visible_p (void)
DECL_ATTRIBUTES (decl)))
return true;
/* See if we have linker information about symbol not being used or
if we need to make guess based on the declaration.
Even if the linker clams the symbol is unused, never bring internal
symbols that are declared by user as used or externally visible.
This is needed for i.e. references from asm statements. */
if (used_from_object_file_p ())
/* Limitation of gas requires us to output targets of symver aliases as
global symbols. This is binutils PR 25295. */
ipa_ref *ref;
FOR_EACH_ALIAS (this, ref)
if (ref->referring->symver)
return true;
if (resolution == LDPR_PREVAILING_DEF_IRONLY)
return false;
......
2019-12-19 Jan Hubicka <hubicka@ucw.cz>
Xi Ruoyao <xry111@mengyan1223.wang>
* lto-common.c (read_cgraph_and_symbols): Work around binutils
PR25424
2019-12-07 Jan Hubicka <hubicka@ucw.cz>
* lto-partition.c (lto_balanced_map): Fix printing of tp_first_run.
......
......@@ -2818,6 +2818,11 @@ read_cgraph_and_symbols (unsigned nfiles, const char **fnames)
IDENTIFIER_POINTER
(DECL_ASSEMBLER_NAME (snode->decl)));
}
/* Symbol versions are always used externally, but linker does not
report that correctly.
This is binutils PR25924. */
else if (snode->symver && *res == LDPR_PREVAILING_DEF_IRONLY)
snode->resolution = LDPR_PREVAILING_DEF_IRONLY_EXP;
else
snode->resolution = *res;
}
......
......@@ -1156,6 +1156,22 @@ symtab_node::verify_base (void)
error ("node is symver but not alias");
error_found = true;
}
/* Limitation of gas requires us to output targets of symver aliases as
global symbols. This is binutils PR 25295. */
if (symver
&& (!TREE_PUBLIC (get_alias_target ()->decl)
|| DECL_VISIBILITY (get_alias_target ()->decl) != VISIBILITY_DEFAULT))
{
error ("symver target is not exported with default visibility");
error_found = true;
}
if (symver
&& (!TREE_PUBLIC (decl)
|| DECL_VISIBILITY (decl) != VISIBILITY_DEFAULT))
{
error ("symver is not exported with default visibility");
error_found = true;
}
if (same_comdat_group)
{
symtab_node *n = same_comdat_group;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment