On 2019-12-19 11:06 +0100, Jan Hubicka wrote:
> This is variant of your patch I comitted. It also adds verification so
> we get ICE rather then wrong code.  In addition I moved the checks away
> rom used_from_object_file.  This function is about non-LTO objects
> linked into the DSO and thus does not really fit for the check.
> Lastly we can not rely on symver attribute to still be present here.
> 
> Regtested x86_64-linux and comitted.
> Honza
>       * 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

/* snip */

> Index: ipa-visibility.c
> ===================================================================
> --- ipa-visibility.c  (revision 279523)
> +++ ipa-visibility.c  (working copy)
> @@ -220,6 +220,14 @@ cgraph_externally_visible_p (struct cgra
>        && 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;

Are these two lines removed intentionally?

>    if (resolution == LDPR_PREVAILING_DEF_IRONLY)
>      return false;
>  
> Index: lto/lto-common.c
> ===================================================================
-- 
Xi Ruoyao <xry...@mengyan1223.wang>
School of Aerospace Science and Technology, Xidian University

Reply via email to