bfd/
authorH.J. Lu <hjl.tools@gmail.com>
Tue, 20 May 2003 14:35:01 +0000 (14:35 +0000)
committerH.J. Lu <hjl.tools@gmail.com>
Tue, 20 May 2003 14:35:01 +0000 (14:35 +0000)
2003-05-20  Jakub Jelinek  <jakub@redhat.com>

* elflink.h (elf_link_output_extsym): Only issue error about !=
STV_DEFAULT symbols if they are bfd_link_hash_undefined.

2003-05-20  H.J. Lu <hongjiu.lu@intel.com>

* elflink.c (_bfd_elf_merge_symbol): Check ELF_LINK_DYNAMIC_DEF
when removing the old definition for symbols with non-default
visibility.

ld/testsuite/

2003-05-20  Jakub Jelinek  <jakub@redhat.com>

* ld-elfvsb/common.c: New file.
* ld-elfvsb/elfvsb.exp: Add common.

2003-05-20  H.J. Lu <hongjiu.lu@intel.com>

* ld-elfvsb/sh3.c: New file.
* ld-elfvsb/test.c: Likewise.

* ld-elfvsb/elfvsb.exp: Add new weak hidden symbol tests.

bfd/ChangeLog
bfd/elflink.c
bfd/elflink.h
ld/testsuite/ChangeLog
ld/testsuite/ld-elfvsb/common.c [new file with mode: 0644]
ld/testsuite/ld-elfvsb/elfvsb.exp
ld/testsuite/ld-elfvsb/sh3.c [new file with mode: 0644]
ld/testsuite/ld-elfvsb/test.c [new file with mode: 0644]

index 646cdd5559b71ae032cd3f20eb4c6836629af40c..87117efe4b2a1926f75db064cbaad0e4607977c2 100644 (file)
@@ -1,3 +1,14 @@
+2003-05-20  Jakub Jelinek  <jakub@redhat.com>
+
+       * elflink.h (elf_link_output_extsym): Only issue error about !=
+       STV_DEFAULT symbols if they are bfd_link_hash_undefined.
+
+2003-05-20  H.J. Lu <hongjiu.lu@intel.com>
+
+       * elflink.c (_bfd_elf_merge_symbol): Check ELF_LINK_DYNAMIC_DEF
+       when removing the old definition for symbols with non-default
+       visibility.
+
 2003-05-18  Jason Eckhardt  <jle@rice.edu>
 
        * elf32-i860.c (elf32_i860_relocate_highadj): Simplify calculation.
index 3b0d3531f2d0015a83c57b5bcaf26d1860ae795b..cc311863e1aaaaee1a1a648e2f50e52a2cd66ac3 100644 (file)
@@ -884,7 +884,8 @@ _bfd_elf_merge_symbol (abfd, info, name, sym, psec, pvalue, sym_hash, skip,
       if (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_DYNAMIC)
        {
          h->elf_link_hash_flags &= ~ELF_LINK_HASH_DEF_DYNAMIC;
-         h->elf_link_hash_flags |= ELF_LINK_HASH_REF_DYNAMIC;
+         h->elf_link_hash_flags |= (ELF_LINK_HASH_REF_DYNAMIC
+                                    | ELF_LINK_DYNAMIC_DEF);
        }
       /* FIXME: Should we check type and size for protected symbol?  */
       h->size = 0;
index ab8c7dec3b483684b92cc71a058f00aea32cdf9d..7b32491d945a6b1ade7a91ad1c43af870f8e548f 100644 (file)
@@ -4622,7 +4622,7 @@ elf_link_output_extsym (h, data)
   if (! finfo->info->relocateable
       && ELF_ST_VISIBILITY (sym.st_other) != STV_DEFAULT
       && ELF_ST_BIND (sym.st_info) != STB_WEAK
-      && h->root.type != bfd_link_hash_undefweak
+      && h->root.type == bfd_link_hash_undefined
       && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0)
     {
       (*_bfd_error_handler)
index cb4f33db88edef5783600a5edac5986be901069a..7404d729565431d825f1b9e63f7f6b633396d546 100644 (file)
@@ -1,3 +1,15 @@
+2003-05-20  Jakub Jelinek  <jakub@redhat.com>
+
+       * ld-elfvsb/common.c: New file.
+       * ld-elfvsb/elfvsb.exp: Add common.
+
+2003-05-20  H.J. Lu <hongjiu.lu@intel.com>
+
+       * ld-elfvsb/sh3.c: New file.
+       * ld-elfvsb/test.c: Likewise.
+
+       * ld-elfvsb/elfvsb.exp: Add new weak hidden symbol tests.
+
 2003-05-15  H.J. Lu <hongjiu.lu@intel.com>
 
        * config/default.exp (gcc_ld_flag): New. Make the newly built
diff --git a/ld/testsuite/ld-elfvsb/common.c b/ld/testsuite/ld-elfvsb/common.c
new file mode 100644 (file)
index 0000000..7d05eb7
--- /dev/null
@@ -0,0 +1,14 @@
+int foo;
+asm (".hidden foo");
+
+int
+_start (void)
+{
+  return foo;
+}
+
+int
+__start (void)
+{
+  return _start ();
+}
index 66546dc8953ed9400a7592ce393554ec4479448c..d30858a76b68c7a258e72a39585b4c23aef53ed3 100644 (file)
@@ -412,6 +412,39 @@ visibility_run protected_undef_def
 visibility_run protected_weak
 visibility_run normal
 
+if { ![ld_compile "$CC -g $CFLAGS" $srcdir/$subdir/common.c tmpdir/common.o] } {
+    unresolved "common hidden symbol"
+} else {
+    if ![ld_simple_link $ld tmpdir/common "tmpdir/common.o"] {
+       fail "common hidden symbol"
+    } else {
+       pass "common hidden symbol"
+    }
+}
+
+if { ![ld_compile "$CC -g $CFLAGS" $srcdir/$subdir/test.c tmpdir/test.o] } {
+    unresolved "weak hidden symbol"
+} else {
+   if { ![ld_compile "$CC -g $CFLAGS $picflag" $srcdir/$subdir/sh3.c tmpdir/sh3.o] } {
+       unresolved "weak hidden symbol"
+    } else {
+       if ![ld_simple_link $ld tmpdir/sh3.so "-shared tmpdir/sh3.o"] {
+           fail "weak hidden symbol"
+       } else {
+           if ![ld_simple_link $ld tmpdir/weak "tmpdir/test.o tmpdir/sh3.o"] {
+               fail "weak hidden symbol DSO last"
+           } else {
+               pass "weak hidden symbol DSO last"
+           }
+           if ![ld_simple_link $ld tmpdir/weak "tmpdir/sh3.so tmpdir/test.o"] {
+               fail "weak hidden symbol DSO first"
+           } else {
+               pass "weak hidden symbol DSO first"
+           }
+       }
+    }
+}
+
 if { [istarget rs6000*-*-aix*] || [istarget powerpc*-*-aix*] } {
     # Remove the temporary directory.
     catch "exec rm -rf $tmpdir" exec_status
diff --git a/ld/testsuite/ld-elfvsb/sh3.c b/ld/testsuite/ld-elfvsb/sh3.c
new file mode 100644 (file)
index 0000000..a6d5dc8
--- /dev/null
@@ -0,0 +1,7 @@
+int main_hidden_data = 1;
+
+int
+main_hidden_func ()
+{
+  return 1;
+}
diff --git a/ld/testsuite/ld-elfvsb/test.c b/ld/testsuite/ld-elfvsb/test.c
new file mode 100644 (file)
index 0000000..ca23d38
--- /dev/null
@@ -0,0 +1,26 @@
+#pragma weak main_hidden_data
+extern int main_hidden_data;
+asm (".hidden main_hidden_data");
+#pragma weak main_hidden_func
+extern int main_hidden_func ();
+asm (".hidden main_hidden_func");
+
+int
+_start (void)
+{
+  int ret = 0;
+
+  if (&main_hidden_data != 0)
+    ret = 1;
+  if (main_hidden_func != 0)
+    ret = 1;
+
+  return ret;
+}
+
+int
+__start (void)
+{
+  return _start ();
+}