Properly convert LTO plugin visibility to ELF visibility.
authorH.J. Lu <hjl.tools@gmail.com>
Mon, 6 Dec 2010 00:00:15 +0000 (00:00 +0000)
committerH.J. Lu <hjl.tools@gmail.com>
Mon, 6 Dec 2010 00:00:15 +0000 (00:00 +0000)
ld/

2010-12-05  H.J. Lu  <hongjiu.lu@intel.com>

* plugin.c (asymbol_from_plugin_symbol): Properly convert LTO
plugin visibility to ELF visibility.
(is_visible_from_outside): Re-indent.

ld/testsuite/

2010-12-05  H.J. Lu  <hongjiu.lu@intel.com>

* ld-plugin/plugin-vis-1.d: Updated.

ld/ChangeLog
ld/plugin.c
ld/testsuite/ChangeLog
ld/testsuite/ld-plugin/plugin-vis-1.d

index 66aee40ee99655f619db9cc91885afc78d8530b5..c1e59bfdac86aab70516b8b7b2725d981fe9052e 100644 (file)
@@ -1,3 +1,9 @@
+2010-12-05  H.J. Lu  <hongjiu.lu@intel.com>
+
+       * plugin.c (asymbol_from_plugin_symbol): Properly convert LTO
+       plugin visibility to ELF visibility.
+       (is_visible_from_outside): Re-indent.
+
 2010-12-04  Alan Modra  <amodra@gmail.com>
 
        * ldlang.c (lang_size_sections_1): Align lma using same alignment
index 6afc14baba1e19e26bdf31e0a80113daadc99b79..ae9c378c1a95f39f27c761bb659c56721a83daef 100644 (file)
@@ -307,10 +307,31 @@ asymbol_from_plugin_symbol (bfd *abfd, asymbol *asym,
   if (bfd_get_flavour (abfd) == bfd_target_elf_flavour)
     {
       elf_symbol_type *elfsym = elf_symbol_from (abfd, asym);
+      unsigned char visibility;
+
       if (!elfsym)
        einfo (_("%P%F: %s: non-ELF symbol in ELF BFD!"), asym->name);
-      elfsym->internal_elf_sym.st_other &= ~3;
-      elfsym->internal_elf_sym.st_other |= ldsym->visibility;
+      switch (ldsym->visibility)
+       {
+       default:
+         einfo (_("%P%F: unknown ELF symbol visibility: %d!"),
+                ldsym->visibility);
+       case LDPV_DEFAULT:
+         visibility = STV_DEFAULT;
+         break;
+       case LDPV_PROTECTED:
+         visibility = STV_PROTECTED;
+         break;
+       case LDPV_INTERNAL:
+         visibility = STV_INTERNAL;
+         break;
+       case LDPV_HIDDEN:
+         visibility = STV_HIDDEN;
+         break;
+       }
+      elfsym->internal_elf_sym.st_other
+       = (visibility | (elfsym->internal_elf_sym.st_other
+                        & ~ELF_ST_VISIBILITY (-1)));
     }
 
   return LDPS_OK;
@@ -416,8 +437,8 @@ is_visible_from_outside (struct ld_plugin_symbol *lsym, asection *section,
         opportunities during LTRANS at worst; it will not give false
         negatives, which can lead to the disastrous conclusion that the
         related symbol is IRONLY.  (See GCC PR46319 for an example.)  */
-      return lsym->visibility == LDPV_DEFAULT
-       || lsym->visibility == LDPV_PROTECTED;
+      return (lsym->visibility == LDPV_DEFAULT
+             || lsym->visibility == LDPV_PROTECTED);
     }
   return FALSE;
 }
index f0d81d37dc9dcf4632f631776ed715454c7c9686..6920a3721aa2cb2f88f2ee91cdceda9dfb2b46a8 100644 (file)
@@ -1,3 +1,7 @@
+2010-12-05  H.J. Lu  <hongjiu.lu@intel.com>
+
+       * ld-plugin/plugin-vis-1.d: Updated.
+
 2010-12-04  H.J. Lu  <hongjiu.lu@intel.com>
 
        * ld-selective/selective.exp: Don't pass -fvtable-gc to GCC
index 41f49713fdd8babf6b423db4f65da59657c36689..02c0e222aa520f0eabbf2e44974d47e53e231731 100644 (file)
@@ -1,9 +1,9 @@
 #...
-.*(PROTECTED.*func3|DEFAULT.*func|HIDDEN.*func2|INTERNAL.*func1)
+.*(PROTECTED.*func1|DEFAULT.*func|HIDDEN.*func3|INTERNAL.*func2)
 #...
-.*(PROTECTED.*func3|DEFAULT.*func|HIDDEN.*func2|INTERNAL.*func1)
+.*(PROTECTED.*func1|DEFAULT.*func|HIDDEN.*func3|INTERNAL.*func2)
 #...
-.*(PROTECTED.*func3|DEFAULT.*func|HIDDEN.*func2|INTERNAL.*func1)
+.*(PROTECTED.*func1|DEFAULT.*func|HIDDEN.*func3|INTERNAL.*func2)
 #...
-.*(PROTECTED.*func3|DEFAULT.*func|HIDDEN.*func2|INTERNAL.*func1)
+.*(PROTECTED.*func1|DEFAULT.*func|HIDDEN.*func3|INTERNAL.*func2)
 #...