This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[PATCH] Leave merging of non-visibility flags to the backends
- From: Thiemo Seufer <ths at networkno dot de>
- To: binutils at sourceware dot org
- Date: Thu, 10 Aug 2006 15:02:33 +0100
- Subject: [PATCH] Leave merging of non-visibility flags to the backends
Hello All,
the appended patch changes elf_link_add_object_symbols to leave
non-visibility st_other flags to the elf_backend_merge_symbol_attribute
function. This is needed on MIPS to handle STO_MIPS16 flags correctly.
Currently the generic code overwrites the flag with e.g. that of a
following WEAK definition.
Ok to apply?
Thiemo
2006-08-10 Thiemo Seufer <ths@mips.com>
Nigel Stephens <nigel@mips.com>
* elf32-mips.c, elf64-mips.c, elfn32-mips.c
(elf_backend_merge_symbol_attribute): Define.
* elflink.c (elf_link_add_object_symbols): Merge only the ELF
visibility flags.
* elfxx-mips.c (_bfd_mips_elf_merge_symbol_attribute): New function.
Index: bfd/elf32-mips.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-mips.c,v
retrieving revision 1.190
diff -u -p -r1.190 elf32-mips.c
--- bfd/elf32-mips.c 20 Jul 2006 16:46:29 -0000 1.190
+++ bfd/elf32-mips.c 10 Aug 2006 12:39:36 -0000
@@ -1505,6 +1505,8 @@ static const struct ecoff_debug_swap mip
#define elf_backend_create_dynamic_sections \
_bfd_mips_elf_create_dynamic_sections
#define elf_backend_check_relocs _bfd_mips_elf_check_relocs
+#define elf_backend_merge_symbol_attribute \
+ _bfd_mips_elf_merge_symbol_attribute
#define elf_backend_adjust_dynamic_symbol \
_bfd_mips_elf_adjust_dynamic_symbol
#define elf_backend_always_size_sections \
Index: bfd/elf64-mips.c
===================================================================
RCS file: /cvs/src/src/bfd/elf64-mips.c,v
retrieving revision 1.75
diff -u -p -r1.75 elf64-mips.c
--- bfd/elf64-mips.c 20 Jul 2006 16:46:29 -0000 1.75
+++ bfd/elf64-mips.c 10 Aug 2006 12:39:36 -0000
@@ -3026,6 +3026,8 @@ const struct elf_size_info mips_elf64_si
#define elf_backend_create_dynamic_sections \
_bfd_mips_elf_create_dynamic_sections
#define elf_backend_check_relocs _bfd_mips_elf_check_relocs
+#define elf_backend_merge_symbol_attribute \
+ _bfd_mips_elf_merge_symbol_attribute
#define elf_backend_adjust_dynamic_symbol \
_bfd_mips_elf_adjust_dynamic_symbol
#define elf_backend_always_size_sections \
Index: bfd/elflink.c
===================================================================
RCS file: /cvs/src/src/bfd/elflink.c,v
retrieving revision 1.226
diff -u -p -r1.226 elflink.c
--- bfd/elflink.c 4 Aug 2006 14:53:25 -0000 1.226
+++ bfd/elflink.c 10 Aug 2006 12:39:36 -0000
@@ -4058,13 +4058,13 @@ elf_link_add_object_symbols (bfd *abfd,
isym->st_other = (STV_HIDDEN
| (isym->st_other & ~ELF_ST_VISIBILITY (-1)));
- if (isym->st_other != 0 && !dynamic)
+ if (ELF_ST_VISIBILITY (isym->st_other) != 0 && !dynamic)
{
unsigned char hvis, symvis, other, nvis;
- /* Take the balance of OTHER from the definition. */
- other = (definition ? isym->st_other : h->other);
- other &= ~ ELF_ST_VISIBILITY (-1);
+ /* Only merge the visibility. Leave the remainder of the
+ st_other field to elf_backend_merge_symbol_attribute. */
+ other = h->other & ~ELF_ST_VISIBILITY (-1);
/* Combine visibilities, using the most constraining one. */
hvis = ELF_ST_VISIBILITY (h->other);
Index: bfd/elfn32-mips.c
===================================================================
RCS file: /cvs/src/src/bfd/elfn32-mips.c,v
retrieving revision 1.33
diff -u -p -r1.33 elfn32-mips.c
--- bfd/elfn32-mips.c 20 Jul 2006 16:46:29 -0000 1.33
+++ bfd/elfn32-mips.c 10 Aug 2006 12:39:36 -0000
@@ -2293,6 +2293,8 @@ static const struct ecoff_debug_swap mip
#define elf_backend_create_dynamic_sections \
_bfd_mips_elf_create_dynamic_sections
#define elf_backend_check_relocs _bfd_mips_elf_check_relocs
+#define elf_backend_merge_symbol_attribute \
+ _bfd_mips_elf_merge_symbol_attribute
#define elf_backend_adjust_dynamic_symbol \
_bfd_mips_elf_adjust_dynamic_symbol
#define elf_backend_always_size_sections \
Index: bfd/elfxx-mips.c
===================================================================
RCS file: /cvs/src/src/bfd/elfxx-mips.c,v
retrieving revision 1.178
diff -u -p -r1.178 elfxx-mips.c
--- bfd/elfxx-mips.c 25 Jul 2006 09:17:56 -0000 1.178
+++ bfd/elfxx-mips.c 10 Aug 2006 12:39:37 -0000
@@ -11114,15 +11114,25 @@ const struct bfd_elf_special_section _bf
{ NULL, 0, 0, 0, 0 }
};
-/* Ensure that the STO_OPTIONAL flag is copied into h->other,
- even if this is not a defintion of the symbol. */
+/* Merge non visibility st_other attributes. Ensure that the
+ STO_OPTIONAL flag is copied into h->other, even if this is not a
+ definiton of the symbol. */
void
_bfd_mips_elf_merge_symbol_attribute (struct elf_link_hash_entry *h,
const Elf_Internal_Sym *isym,
bfd_boolean definition,
bfd_boolean dynamic ATTRIBUTE_UNUSED)
{
- if (! definition
+ if ((isym->st_other & ~ELF_ST_VISIBILITY (-1)) != 0)
+ {
+ unsigned char other;
+
+ other = (definition ? isym->st_other : h->other);
+ other &= ~ELF_ST_VISIBILITY (-1);
+ h->other = other | ELF_ST_VISIBILITY (h->other);
+ }
+
+ if (!definition
&& ELF_MIPS_IS_OPTIONAL (isym->st_other))
h->other |= STO_OPTIONAL;
}