[v2] LTO: Restore the wrapper symbol check for indirect reference

Message ID 20240802114007.191332-1-hjl.tools@gmail.com
State Superseded
Headers
Series [v2] LTO: Restore the wrapper symbol check for indirect reference |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_binutils_build--master-arm success Build passed
linaro-tcwg-bot/tcwg_binutils_build--master-aarch64 success Build passed
linaro-tcwg-bot/tcwg_binutils_check--master-aarch64 success Test passed
linaro-tcwg-bot/tcwg_binutils_check--master-arm success Test passed

Commit Message

H.J. Lu Aug. 2, 2024, 11:40 a.m. UTC
  Call unwrap_hash_lookup to restore the wrapper symbol check for indirect
reference, like calloc@@GLIBC_2.2.5, which doesn't set wrapper_symbol
on __wrap_calloc.

	PR ld/31956
	* plugin.c (get_symbols): Restore the wrapper symbol check for
	indirect reference.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
---
 ld/plugin.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)
  

Comments

H.J. Lu Aug. 2, 2024, 11:48 a.m. UTC | #1
On Fri, Aug 2, 2024 at 4:40 AM H.J. Lu <hjl.tools@gmail.com> wrote:
>
> Call unwrap_hash_lookup to restore the wrapper symbol check for indirect
> reference, like calloc@@GLIBC_2.2.5, which doesn't set wrapper_symbol
> on __wrap_calloc.
>
>         PR ld/31956
>         * plugin.c (get_symbols): Restore the wrapper symbol check for
>         indirect reference.
>
> Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
> ---
>  ld/plugin.c | 14 ++++++++++++--
>  1 file changed, 12 insertions(+), 2 deletions(-)
>
> diff --git a/ld/plugin.c b/ld/plugin.c
> index 03ee9880d10..51c4765cc5b 100644
> --- a/ld/plugin.c
> +++ b/ld/plugin.c
> @@ -778,8 +778,18 @@ get_symbols (const void *handle, int nsyms, struct ld_plugin_symbol *syms,
>         {
>           blhe = h;
>           /* Check if a symbol is a wrapper symbol.  */
> -         if (blhe && blhe->wrapper_symbol)
> -           wrap_status = wrapper;
> +         if (blhe)
> +           {
> +             if (blhe->wrapper_symbol)
> +               wrap_status = wrapper;
> +             else if (link_info.wrap_hash != NULL)
> +               {
> +                 struct bfd_link_hash_entry *unwrap
> +                   = unwrap_hash_lookup (&link_info, (bfd *) abfd, blhe);
> +                 if (unwrap != NULL && unwrap != h)
> +                   wrap_status = wrapper;
> +               }
> +           }
>         }
>        else
>         {
> --
> 2.45.2
>

Please commit for me if it is OK since I may not have Internet access
in the next few days.

Thanks.
  
H.J. Lu Aug. 2, 2024, 5:21 p.m. UTC | #2
On Fri, Aug 2, 2024 at 4:48 AM H.J. Lu <hjl.tools@gmail.com> wrote:
>
> On Fri, Aug 2, 2024 at 4:40 AM H.J. Lu <hjl.tools@gmail.com> wrote:
> >
> > Call unwrap_hash_lookup to restore the wrapper symbol check for indirect
> > reference, like calloc@@GLIBC_2.2.5, which doesn't set wrapper_symbol
> > on __wrap_calloc.
> >
> >         PR ld/31956
> >         * plugin.c (get_symbols): Restore the wrapper symbol check for
> >         indirect reference.
> >
> > Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
> > ---
> >  ld/plugin.c | 14 ++++++++++++--
> >  1 file changed, 12 insertions(+), 2 deletions(-)
> >
> > diff --git a/ld/plugin.c b/ld/plugin.c
> > index 03ee9880d10..51c4765cc5b 100644
> > --- a/ld/plugin.c
> > +++ b/ld/plugin.c
> > @@ -778,8 +778,18 @@ get_symbols (const void *handle, int nsyms, struct ld_plugin_symbol *syms,
> >         {
> >           blhe = h;
> >           /* Check if a symbol is a wrapper symbol.  */
> > -         if (blhe && blhe->wrapper_symbol)
> > -           wrap_status = wrapper;
> > +         if (blhe)
> > +           {
> > +             if (blhe->wrapper_symbol)
> > +               wrap_status = wrapper;
> > +             else if (link_info.wrap_hash != NULL)
> > +               {
> > +                 struct bfd_link_hash_entry *unwrap
> > +                   = unwrap_hash_lookup (&link_info, (bfd *) abfd, blhe);
> > +                 if (unwrap != NULL && unwrap != h)
> > +                   wrap_status = wrapper;
> > +               }
> > +           }
> >         }
> >        else
> >         {
> > --
> > 2.45.2
> >
>
> Please commit for me if it is OK since I may not have Internet access
> in the next few days.

Please ignore this.
  

Patch

diff --git a/ld/plugin.c b/ld/plugin.c
index 03ee9880d10..51c4765cc5b 100644
--- a/ld/plugin.c
+++ b/ld/plugin.c
@@ -778,8 +778,18 @@  get_symbols (const void *handle, int nsyms, struct ld_plugin_symbol *syms,
 	{
 	  blhe = h;
 	  /* Check if a symbol is a wrapper symbol.  */
-	  if (blhe && blhe->wrapper_symbol)
-	    wrap_status = wrapper;
+	  if (blhe)
+	    {
+	      if (blhe->wrapper_symbol)
+		wrap_status = wrapper;
+	      else if (link_info.wrap_hash != NULL)
+		{
+		  struct bfd_link_hash_entry *unwrap
+		    = unwrap_hash_lookup (&link_info, (bfd *) abfd, blhe);
+		  if (unwrap != NULL && unwrap != h)
+		    wrap_status = wrapper;
+		}
+	    }
 	}
       else
 	{