public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* s390-linux FAIL: pr22269-1 (static pie undefined weak)
@ 2024-02-13 23:15 Alan Modra
  2024-02-15 16:09 ` Andreas Krebbel
  0 siblings, 1 reply; 2+ messages in thread
From: Alan Modra @ 2024-02-13 23:15 UTC (permalink / raw)
  To: binutils; +Cc: Andreas Krebbel

Like 10e7c0457cb7 but for elf32-s390.c.  Andreas is there a reason why
this patch of yours for elf64-s390.c should not be applied to
elf32-s390.c?  I see there may be a bfd_link_dll vs. bfd_link_pic
patch missing too.

	* elf32-s390.c (elf_s390_adjust_dynamic_symbol): Use
	UNDEFWEAK_NO_DYNAMIC_RELOC.
	(allocate_dynrelocs): Likewise.
	(elf_s390_relocate_section): Check resolved_to_zero.
	(elf_s390_finish_dynamic_symbol): Don't generate runtime reloc if
	UNDEFWEAK_NO_DYNAMIC_RELOC.

diff --git a/bfd/elf32-s390.c b/bfd/elf32-s390.c
index 1a2ade0414e..bd9eb1ea31b 100644
--- a/bfd/elf32-s390.c
+++ b/bfd/elf32-s390.c
@@ -1447,8 +1447,7 @@ elf_s390_adjust_dynamic_symbol (struct bfd_link_info *info,
     {
       if (h->plt.refcount <= 0
 	  || SYMBOL_CALLS_LOCAL (info, h)
-	  || (ELF_ST_VISIBILITY (h->other) != STV_DEFAULT
-	      && h->root.type != bfd_link_hash_undefweak))
+	  || UNDEFWEAK_NO_DYNAMIC_RELOC (info, h))
 	{
 	  /* This case can occur if we saw a PLT32 reloc in an input
 	     file, but the symbol was never referred to by a dynamic
@@ -1677,8 +1676,7 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void * inf)
 	htab->elf.srelgot->size += sizeof (Elf32_External_Rela);
       else if (tls_type == GOT_TLS_GD)
 	htab->elf.srelgot->size += 2 * sizeof (Elf32_External_Rela);
-      else if ((ELF_ST_VISIBILITY (h->other) == STV_DEFAULT
-		|| h->root.type != bfd_link_hash_undefweak)
+      else if (!UNDEFWEAK_NO_DYNAMIC_RELOC (info, h)
 	       && (bfd_link_pic (info)
 		   || WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, 0, h)))
 	htab->elf.srelgot->size += sizeof (Elf32_External_Rela);
@@ -2240,9 +2238,7 @@ elf_s390_relocate_section (bfd *output_bfd,
 							  h)
 		       || (bfd_link_pic (info)
 			   && SYMBOL_REFERENCES_LOCAL (info, h))
-		       || (ELF_ST_VISIBILITY (h->other)
-			   && h->root.type == bfd_link_hash_undefweak))
-
+		       || resolved_to_zero)
 		{
 		  /* This is actually a static link, or it is a
 		     -Bsymbolic link and the symbol is defined
@@ -3499,6 +3495,9 @@ elf_s390_finish_dynamic_symbol (bfd *output_bfd,
       else if (bfd_link_pic (info)
 	       && SYMBOL_REFERENCES_LOCAL (info, h))
 	{
+	  if (UNDEFWEAK_NO_DYNAMIC_RELOC (info, h))
+	    return true;
+
 	  /* If this is a static link, or it is a -Bsymbolic link and
 	     the symbol is defined locally or was forced to be local
 	     because of a version file, we just want to emit a

-- 
Alan Modra
Australia Development Lab, IBM

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: s390-linux FAIL: pr22269-1 (static pie undefined weak)
  2024-02-13 23:15 s390-linux FAIL: pr22269-1 (static pie undefined weak) Alan Modra
@ 2024-02-15 16:09 ` Andreas Krebbel
  0 siblings, 0 replies; 2+ messages in thread
From: Andreas Krebbel @ 2024-02-15 16:09 UTC (permalink / raw)
  To: Alan Modra, binutils

On 2/14/24 00:15, Alan Modra wrote:
> Like 10e7c0457cb7 but for elf32-s390.c.  Andreas is there a reason why
> this patch of yours for elf64-s390.c should not be applied to
> elf32-s390.c?  I see there may be a bfd_link_dll vs. bfd_link_pic
> patch missing too.

Hi Alan,

I don't think there is a technical reason. I'm fine with this this patch. Thanks!

Andreas

> 
> 	* elf32-s390.c (elf_s390_adjust_dynamic_symbol): Use
> 	UNDEFWEAK_NO_DYNAMIC_RELOC.
> 	(allocate_dynrelocs): Likewise.
> 	(elf_s390_relocate_section): Check resolved_to_zero.
> 	(elf_s390_finish_dynamic_symbol): Don't generate runtime reloc if
> 	UNDEFWEAK_NO_DYNAMIC_RELOC.
> 
> diff --git a/bfd/elf32-s390.c b/bfd/elf32-s390.c
> index 1a2ade0414e..bd9eb1ea31b 100644
> --- a/bfd/elf32-s390.c
> +++ b/bfd/elf32-s390.c
> @@ -1447,8 +1447,7 @@ elf_s390_adjust_dynamic_symbol (struct bfd_link_info *info,
>      {
>        if (h->plt.refcount <= 0
>  	  || SYMBOL_CALLS_LOCAL (info, h)
> -	  || (ELF_ST_VISIBILITY (h->other) != STV_DEFAULT
> -	      && h->root.type != bfd_link_hash_undefweak))
> +	  || UNDEFWEAK_NO_DYNAMIC_RELOC (info, h))
>  	{
>  	  /* This case can occur if we saw a PLT32 reloc in an input
>  	     file, but the symbol was never referred to by a dynamic
> @@ -1677,8 +1676,7 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void * inf)
>  	htab->elf.srelgot->size += sizeof (Elf32_External_Rela);
>        else if (tls_type == GOT_TLS_GD)
>  	htab->elf.srelgot->size += 2 * sizeof (Elf32_External_Rela);
> -      else if ((ELF_ST_VISIBILITY (h->other) == STV_DEFAULT
> -		|| h->root.type != bfd_link_hash_undefweak)
> +      else if (!UNDEFWEAK_NO_DYNAMIC_RELOC (info, h)
>  	       && (bfd_link_pic (info)
>  		   || WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, 0, h)))
>  	htab->elf.srelgot->size += sizeof (Elf32_External_Rela);
> @@ -2240,9 +2238,7 @@ elf_s390_relocate_section (bfd *output_bfd,
>  							  h)
>  		       || (bfd_link_pic (info)
>  			   && SYMBOL_REFERENCES_LOCAL (info, h))
> -		       || (ELF_ST_VISIBILITY (h->other)
> -			   && h->root.type == bfd_link_hash_undefweak))
> -
> +		       || resolved_to_zero)
>  		{
>  		  /* This is actually a static link, or it is a
>  		     -Bsymbolic link and the symbol is defined
> @@ -3499,6 +3495,9 @@ elf_s390_finish_dynamic_symbol (bfd *output_bfd,
>        else if (bfd_link_pic (info)
>  	       && SYMBOL_REFERENCES_LOCAL (info, h))
>  	{
> +	  if (UNDEFWEAK_NO_DYNAMIC_RELOC (info, h))
> +	    return true;
> +
>  	  /* If this is a static link, or it is a -Bsymbolic link and
>  	     the symbol is defined locally or was forced to be local
>  	     because of a version file, we just want to emit a
> 


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-02-15 16:09 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-13 23:15 s390-linux FAIL: pr22269-1 (static pie undefined weak) Alan Modra
2024-02-15 16:09 ` Andreas Krebbel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).