[PATCH v3] LTO: Properly check wrapper symbol

Alan Modra amodra@gmail.com
Tue Jul 9 09:48:59 GMT 2024


On Tue, Jul 09, 2024 at 01:30:19AM -0700, H.J. Lu wrote:
> Add wrapper_symbol to bfd_link_hash_entry and set it to true for wrapper
> symbol. Set wrap_status to wrapper if wrapper_symbol is true in LTO.
> 
> Note: Calling unwrap_hash_lookup to check for the wrapper symbol works
> only when there is a definition for the wrapped symbol since references
> to the wrapped symbol have been redirected to the wrapper symbol.

I'm not suggesting you revert your patch, fewer hash lookups in good,
just showing an alternative here that works.

diff --git a/ld/plugin.c b/ld/plugin.c
index 8107841407a..7672fbc6e08 100644
--- a/ld/plugin.c
+++ b/ld/plugin.c
@@ -782,7 +782,7 @@ get_symbols (const void *handle, int nsyms, struct ld_plugin_symbol *syms,
 	      /* Check if a symbol is a wrapper symbol.  */
 	      struct bfd_link_hash_entry *unwrap
 		= unwrap_hash_lookup (&link_info, (bfd *) abfd, blhe);
-	      if (unwrap && unwrap != h)
+	      if (unwrap != h)
 		wrap_status = wrapper;
 	     }
 	}

-- 
Alan Modra


More information about the Binutils mailing list