This is the mail archive of the
binutils@sourceware.cygnus.com
mailing list for the binutils project.
Another patch for visibility.
- To: Martin von Loewis <loewis at informatik dot hu-berlin dot de>
- Subject: Another patch for visibility.
- From: "H . J . Lu" <hjl at valinux dot com>
- Date: Tue, 30 May 2000 12:31:11 -0700
- Cc: drepper at cygnus dot com, binutils at sourceware dot cygnus dot com
I'd like to check in this patch if it is ok with everyone. There is
no need to check if the visibility is changed. We can have
1. "xxxx" is weak undefined with the hidden visibility in foo.o.
2. "xxxx" is defined with the normal visibility in bar.o.
When we link
# ld .... foo.o bar.o
The visibility is not changed when we process bar.o. But we still
need to hide it since we cannot hide it for weak undefined even with
the hidden visibility when we first process foo.o.
Thanks.
H.J.
----
2000-05-30 H.J. Lu <hjl@gnu.org>
* elflink.c (_bfd_elf_link_record_dynamic_symbol): Clear the
visibility bits if the symbol is undefined. Correctly handle
weak undefined symbols with hidden and internal attributes.
* elflink.h (elf_link_add_object_symbols): Always turn the
symbol into local if it has the hidden or internal attribute.
Index: elflink.c
===================================================================
RCS file: /work/cvs/gnu/binutils/bfd/elflink.c,v
retrieving revision 1.3
diff -u -p -r1.3 elflink.c
--- elflink.c 2000/05/02 17:23:17 1.3
+++ elflink.c 2000/05/30 19:15:04
@@ -235,10 +235,16 @@ _bfd_elf_link_record_dynamic_symbol (inf
(*info->callbacks->undefined_symbol)
(info, name, abfd, bfd_und_section_ptr, 0, true);
+
+ /* We have flaged a fatal error. We now treat this as
+ a normal symbol to avoid further error messages. */
+ h->other ^= ELF_ST_VISIBILITY (h->other);
}
-
- h->elf_link_hash_flags |= ELF_LINK_FORCED_LOCAL;
- return true;
+ else if (h->root.type != bfd_link_hash_undefweak)
+ {
+ h->elf_link_hash_flags |= ELF_LINK_FORCED_LOCAL;
+ return true;
+ }
default:
break;
Index: elflink.h
===================================================================
RCS file: /work/cvs/gnu/binutils/bfd/elflink.h,v
retrieving revision 1.28
diff -u -p -r1.28 elflink.h
--- elflink.h 2000/05/22 16:24:25 1.28
+++ elflink.h 2000/05/30 19:15:52
@@ -890,7 +890,6 @@ elf_link_add_object_symbols (abfd, info)
Elf_External_Sym *esym;
Elf_External_Sym *esymend;
struct elf_backend_data *bed;
- boolean visibility_changed = false;
bed = get_elf_backend_data (abfd);
add_symbol_hook = bed->elf_add_symbol_hook;
@@ -1581,10 +1580,7 @@ elf_link_add_object_symbols (abfd, info)
unsigned char symvis = ELF_ST_VISIBILITY (sym.st_other);
if (symvis && (hvis > symvis || hvis == 0))
- {
- visibility_changed = true;
- h->other = sym.st_other;
- }
+ h->other = sym.st_other;
/* If neither has visibility, use the st_other of the
definition. This is an arbitrary choice, since the
@@ -1855,7 +1851,7 @@ elf_link_add_object_symbols (abfd, info)
goto error_return;
}
}
- else if (dynsym && h->dynindx != -1 && visibility_changed)
+ else if (dynsym && h->dynindx != -1)
/* If the symbol already has a dynamic index, but
visibility says it should not be visible, turn it into
a local symbol. */