This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

PATCH: Re: Bug when merging visibility?


On Fri, Mar 28, 2003 at 11:55:56AM -0800, H. J. Lu wrote:
> Therea are
> 
> #define STV_DEFAULT     0               /* Visibility is specified by binding
> type */
> #define STV_INTERNAL    1               /* OS specific version of STV_HIDDEN */
> #define STV_HIDDEN      2               /* Can only be seen inside currect
> component */
> #define STV_PROTECTED   3               /* Treat as STB_LOCAL inside current
> component */
> g
> 
> We do
> 
>              unsigned char hvis, symvis, other;
>                                                                                 
>               /* Take the balance of OTHER from the definition.  */
>               other = (definition ? isym->st_other : h->other);
>               other &= ~ ELF_ST_VISIBILITY (-1);
>                                                                                 
>               /* Combine visibilities, using the most constraining one.  */
>               hvis   = ELF_ST_VISIBILITY (h->other);
>               symvis = ELF_ST_VISIBILITY (isym->st_other);
>                                                                                 
>               h->other = other | (hvis > symvis ? hvis : symvis);
>  
> It asssumes that the higher the value is, the more constraining the
> visibility is. That means the order is
> 
> STV_DEFAULT < STV_INTERNAL < STV_HIDDEN < STV_PROTECTED
> 
> It doesn't look right to me. Should that be
> 
> STV_DEFAULT < STV_PROTECTED < STV_HIDDEN < STV_INTERNAL
> 
> 

Here is a patch.


H.J.
---
2003-03-28  H.J. Lu <hjl at gnu dot org>

	* elflink.h (elf_link_add_object_symbols): Correctly combine
	visibilities.

--- bfd/elflink.h.vsb-merge	2003-03-07 16:44:56.000000000 -0800
+++ bfd/elflink.h	2003-03-28 12:49:24.000000000 -0800
@@ -1940,7 +1940,7 @@ elf_link_add_object_symbols (abfd, info)
 	     might be needed here.  */
 	  if (isym->st_other != 0)
 	    {
-	      unsigned char hvis, symvis, other;
+	      unsigned char hvis, symvis, other, nvis;
 
 	      /* Take the balance of OTHER from the definition.  */
 	      other = (definition ? isym->st_other : h->other);
@@ -1949,8 +1949,14 @@ elf_link_add_object_symbols (abfd, info)
 	      /* Combine visibilities, using the most constraining one.  */
 	      hvis   = ELF_ST_VISIBILITY (h->other);
 	      symvis = ELF_ST_VISIBILITY (isym->st_other);
+	      if (! hvis)
+		nvis = symvis;
+	      else if (! symvis)
+		nvis = hvis;
+	      else
+		nvis = hvis < symvis ? hvis : symvis;
 
-	      h->other = other | (hvis > symvis ? hvis : symvis);
+	      h->other = other | nvis;
 	    }
 
 	  /* Set a flag in the hash table entry indicating the type of


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]