This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: PATCH: Fix ELF visibility handling
- From: Jakub Jelinek <jakub at redhat dot com>
- To: "H. J. Lu" <hjl at lucon dot org>
- Cc: binutils at sources dot redhat dot com, amodra at bigpond dot net dot au
- Date: Tue, 20 May 2003 00:19:19 +0200
- Subject: Re: PATCH: Fix ELF visibility handling
- References: <20030401121958.A6545@lucon.org> <20030409092252.A6924@lucon.org>
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
On Wed, Apr 09, 2003 at 09:22:52AM -0700, H. J. Lu wrote:
> 2003-04-01 H.J. Lu <hjl@gnu.org>
>
> (elf_link_output_extsym): Warn if a forced local symbol is
> referenced from dynamic objects. Make non-weak undefined symbol
> with non-default visibility a fatal error.
This change broke static linking with hidden common symbols
(testcase included in the patch below).
Any reason why you use h->root.type != bfd_link_hash_undefweak
which can well be a normal bfd_link_hash_defined symbol?
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.
* ld-elfvsb/sh3.c: New test.
* ld-elfvsb/elfvsb.exp: Add sh3.
--- bfd/elflink.h.jj 2003-05-19 17:12:39.000000000 -0400
+++ bfd/elflink.h 2003-05-19 17:43:12.000000000 -0400
@@ -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)
--- ld/testsuite/ld-elfvsb/sh3.c.jj 2003-05-19 17:51:14.000000000 -0400
+++ ld/testsuite/ld-elfvsb/sh3.c 2003-05-19 17:51:08.000000000 -0400
@@ -0,0 +1,7 @@
+int foo;
+asm (".hidden foo");
+
+int main (void)
+{
+ return foo;
+}
--- ld/testsuite/ld-elfvsb/elfvsb.exp.jj 2003-05-19 17:12:47.000000000 -0400
+++ ld/testsuite/ld-elfvsb/elfvsb.exp 2003-05-19 18:08:22.000000000 -0400
@@ -412,6 +412,16 @@ visibility_run protected_undef_def
visibility_run protected_weak
visibility_run normal
+if { ![ld_compile "$CC -g $CFLAGS $SHCFLAG" $srcdir/$subdir/sh3.c $tmpdir/sh3.o] } {
+ unresolved "static visibility"
+} else {
+ if ![ld_simple_link $CC $tmpdir/sh3 "-static $tmpdir/sh3.o"] {
+ fail "static visibility"
+ } else {
+ pass "static visibility"
+ }
+}
+
if { [istarget rs6000*-*-aix*] || [istarget powerpc*-*-aix*] } {
# Remove the temporary directory.
catch "exec rm -rf $tmpdir" exec_status
Jakub