diff options
author | Jan Hubicka <hubicka@ucw.cz> | 2019-12-19 11:03:48 +0100 |
---|---|---|
committer | Jan Hubicka <hubicka@gcc.gnu.org> | 2019-12-19 10:03:48 +0000 |
commit | 40ebe1fc2f136a454b0d5efa119bb516ad767c91 (patch) | |
tree | 302cab4062b9e251794530c40e2009eb19eb7509 | |
parent | 44fca83228acc96c19c51e52b5c0448e09329170 (diff) |
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
-rw-r--r-- | gcc/ChangeLog | 10 | ||||
-rw-r--r-- | gcc/cgraph.c | 3 | ||||
-rw-r--r-- | gcc/ipa-visibility.c | 21 | ||||
-rw-r--r-- | gcc/lto/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/lto/lto-common.c | 5 | ||||
-rw-r--r-- | gcc/symtab.c | 16 |
6 files changed, 54 insertions, 7 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 3b703386ddd..5d938ae09d3 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,4 +1,14 @@ 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. diff --git a/gcc/cgraph.c b/gcc/cgraph.c index ba5f2767e4b..5ba33a5a0cc 100644 --- a/gcc/cgraph.c +++ b/gcc/cgraph.c @@ -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 () diff --git a/gcc/ipa-visibility.c b/gcc/ipa-visibility.c index f470465f935..d216a54a7ab 100644 --- a/gcc/ipa-visibility.c +++ b/gcc/ipa-visibility.c @@ -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. + /* 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; - 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 ()) - return true; if (resolution == LDPR_PREVAILING_DEF_IRONLY) return false; diff --git a/gcc/lto/ChangeLog b/gcc/lto/ChangeLog index 9f974afb123..d0b1dba740e 100644 --- a/gcc/lto/ChangeLog +++ b/gcc/lto/ChangeLog @@ -1,3 +1,9 @@ +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. diff --git a/gcc/lto/lto-common.c b/gcc/lto/lto-common.c index 76a9d9383d5..ee07730a27d 100644 --- a/gcc/lto/lto-common.c +++ b/gcc/lto/lto-common.c @@ -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; } diff --git a/gcc/symtab.c b/gcc/symtab.c index 10b8ed1d178..9c52192fced 100644 --- a/gcc/symtab.c +++ b/gcc/symtab.c @@ -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; |