mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-06-20 01:50:24 +08:00
bfd/
2003-05-04 H.J. Lu <hjl@gnu.org> * elf32-i386.c (allocate_dynrelocs): Don't allocate dynamic relocation entries for weak undefined symbols with non-default visibility. (elf_i386_relocate_section): Initialize the GOT entries and skip R_386_32/R_386_PC32 for weak undefined symbols with non-default visibility. * elfxx-ia64.c (allocate_fptr): Don't allocate function descriptors for weak undefined symbols with non-default visibility. (allocate_dynrel_entries): Don't allocate relocation entries for symbols resolved to 0. (set_got_entry): Don't install dynamic relocation for weak undefined symbols with non-default visibility. (set_pltoff_entry): Likewise. * elflink.h (elf_fix_symbol_flags): Hide weak undefined symbols with non-default visibility. (elf_link_output_extsym): Don't make weak undefined symbols with non-default visibility dynamic. ld/testsuite/ 2003-05-04 H.J. Lu <hjl@gnu.org> * ld-elfvsb/main.c: Updated. * ld-elfvsb/sh1.c: Likewise.
This commit is contained in:
@ -1,3 +1,26 @@
|
|||||||
|
2003-05-04 H.J. Lu <hjl@gnu.org>
|
||||||
|
|
||||||
|
* elf32-i386.c (allocate_dynrelocs): Don't allocate dynamic
|
||||||
|
relocation entries for weak undefined symbols with non-default
|
||||||
|
visibility.
|
||||||
|
(elf_i386_relocate_section): Initialize the GOT entries and
|
||||||
|
skip R_386_32/R_386_PC32 for weak undefined symbols with
|
||||||
|
non-default visibility.
|
||||||
|
|
||||||
|
* elfxx-ia64.c (allocate_fptr): Don't allocate function
|
||||||
|
descriptors for weak undefined symbols with non-default
|
||||||
|
visibility.
|
||||||
|
(allocate_dynrel_entries): Don't allocate relocation entries
|
||||||
|
for symbols resolved to 0.
|
||||||
|
(set_got_entry): Don't install dynamic relocation for weak
|
||||||
|
undefined symbols with non-default visibility.
|
||||||
|
(set_pltoff_entry): Likewise.
|
||||||
|
|
||||||
|
* elflink.h (elf_fix_symbol_flags): Hide weak undefined symbols
|
||||||
|
with non-default visibility.
|
||||||
|
(elf_link_output_extsym): Don't make weak undefined symbols
|
||||||
|
with non-default visibility dynamic.
|
||||||
|
|
||||||
2003-05-04 H.J. Lu <hjl@gnu.org>
|
2003-05-04 H.J. Lu <hjl@gnu.org>
|
||||||
|
|
||||||
* elflink.h (elf_merge_symbol): Correctly handle weak definiton.
|
* elflink.h (elf_merge_symbol): Correctly handle weak definiton.
|
||||||
|
@ -1569,8 +1569,10 @@ allocate_dynrelocs (h, inf)
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (info->shared
|
if ((ELF_ST_VISIBILITY (h->other) == STV_DEFAULT
|
||||||
|| WILL_CALL_FINISH_DYNAMIC_SYMBOL (1, 0, h))
|
|| h->root.type != bfd_link_hash_undefweak)
|
||||||
|
&& (info->shared
|
||||||
|
|| WILL_CALL_FINISH_DYNAMIC_SYMBOL (1, 0, h)))
|
||||||
{
|
{
|
||||||
asection *s = htab->splt;
|
asection *s = htab->splt;
|
||||||
|
|
||||||
@ -1656,8 +1658,10 @@ allocate_dynrelocs (h, inf)
|
|||||||
htab->srelgot->_raw_size += sizeof (Elf32_External_Rel);
|
htab->srelgot->_raw_size += sizeof (Elf32_External_Rel);
|
||||||
else if (tls_type == GOT_TLS_GD)
|
else if (tls_type == GOT_TLS_GD)
|
||||||
htab->srelgot->_raw_size += 2 * sizeof (Elf32_External_Rel);
|
htab->srelgot->_raw_size += 2 * sizeof (Elf32_External_Rel);
|
||||||
else if (info->shared
|
else if ((ELF_ST_VISIBILITY (h->other) == STV_DEFAULT
|
||||||
|| WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, 0, h))
|
|| h->root.type != bfd_link_hash_undefweak)
|
||||||
|
&& (info->shared
|
||||||
|
|| WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, 0, h)))
|
||||||
htab->srelgot->_raw_size += sizeof (Elf32_External_Rel);
|
htab->srelgot->_raw_size += sizeof (Elf32_External_Rel);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -2298,7 +2302,9 @@ elf_i386_relocate_section (output_bfd, info, input_bfd, input_section,
|
|||||||
&& (info->symbolic
|
&& (info->symbolic
|
||||||
|| h->dynindx == -1
|
|| h->dynindx == -1
|
||||||
|| (h->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL))
|
|| (h->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL))
|
||||||
&& (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR)))
|
&& (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR))
|
||||||
|
|| (ELF_ST_VISIBILITY (h->other)
|
||||||
|
&& h->root.type == bfd_link_hash_undefweak))
|
||||||
{
|
{
|
||||||
/* This is actually a static link, or it is a
|
/* This is actually a static link, or it is a
|
||||||
-Bsymbolic link and the symbol is defined
|
-Bsymbolic link and the symbol is defined
|
||||||
@ -2422,6 +2428,9 @@ elf_i386_relocate_section (output_bfd, info, input_bfd, input_section,
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
if ((info->shared
|
if ((info->shared
|
||||||
|
&& (h == NULL
|
||||||
|
|| ELF_ST_VISIBILITY (h->other) == STV_DEFAULT
|
||||||
|
|| h->root.type != bfd_link_hash_undefweak)
|
||||||
&& (r_type != R_386_PC32
|
&& (r_type != R_386_PC32
|
||||||
|| (h != NULL
|
|| (h != NULL
|
||||||
&& h->dynindx != -1
|
&& h->dynindx != -1
|
||||||
|
@ -4151,6 +4151,16 @@ elf_fix_symbol_flags (h, eif)
|
|||||||
(*bed->elf_backend_hide_symbol) (eif->info, h, force_local);
|
(*bed->elf_backend_hide_symbol) (eif->info, h, force_local);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* If a weak undefined symbol has non-default visibility, we also
|
||||||
|
hide it from the dynamic linker. */
|
||||||
|
if (ELF_ST_VISIBILITY (h->other)
|
||||||
|
&& h->root.type == bfd_link_hash_undefweak)
|
||||||
|
{
|
||||||
|
struct elf_backend_data *bed;
|
||||||
|
bed = get_elf_backend_data (elf_hash_table (eif->info)->dynobj);
|
||||||
|
(*bed->elf_backend_hide_symbol) (eif->info, h, TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
/* If this is a weak defined symbol in a dynamic object, and we know
|
/* If this is a weak defined symbol in a dynamic object, and we know
|
||||||
the real definition in the dynamic object, copy interesting flags
|
the real definition in the dynamic object, copy interesting flags
|
||||||
over to the real definition. */
|
over to the real definition. */
|
||||||
@ -6546,7 +6556,9 @@ elf_link_output_extsym (h, data)
|
|||||||
forced local syms when non-shared is due to a historical quirk. */
|
forced local syms when non-shared is due to a historical quirk. */
|
||||||
if ((h->dynindx != -1
|
if ((h->dynindx != -1
|
||||||
|| (h->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) != 0)
|
|| (h->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) != 0)
|
||||||
&& (finfo->info->shared
|
&& ((finfo->info->shared
|
||||||
|
&& (ELF_ST_VISIBILITY (h->other) == STV_DEFAULT
|
||||||
|
|| h->root.type != bfd_link_hash_undefweak))
|
||||||
|| (h->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) == 0)
|
|| (h->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) == 0)
|
||||||
&& elf_hash_table (finfo->info)->dynamic_sections_created)
|
&& elf_hash_table (finfo->info)->dynamic_sections_created)
|
||||||
{
|
{
|
||||||
|
@ -2635,7 +2635,10 @@ allocate_fptr (dyn_i, data)
|
|||||||
|| h->root.type == bfd_link_hash_warning)
|
|| h->root.type == bfd_link_hash_warning)
|
||||||
h = (struct elf_link_hash_entry *) h->root.u.i.link;
|
h = (struct elf_link_hash_entry *) h->root.u.i.link;
|
||||||
|
|
||||||
if (x->info->shared
|
if ((x->info->shared
|
||||||
|
&& (!h
|
||||||
|
|| ELF_ST_VISIBILITY (h->other) == STV_DEFAULT
|
||||||
|
|| h->root.type != bfd_link_hash_undefweak))
|
||||||
/* AIX needs an FPTR in this case. */
|
/* AIX needs an FPTR in this case. */
|
||||||
|| (elfNN_ia64_aix_vec (x->info->hash->creator)
|
|| (elfNN_ia64_aix_vec (x->info->hash->creator)
|
||||||
&& (!h
|
&& (!h
|
||||||
@ -2760,15 +2763,18 @@ allocate_dynrel_entries (dyn_i, data)
|
|||||||
struct elfNN_ia64_allocate_data *x = (struct elfNN_ia64_allocate_data *)data;
|
struct elfNN_ia64_allocate_data *x = (struct elfNN_ia64_allocate_data *)data;
|
||||||
struct elfNN_ia64_link_hash_table *ia64_info;
|
struct elfNN_ia64_link_hash_table *ia64_info;
|
||||||
struct elfNN_ia64_dyn_reloc_entry *rent;
|
struct elfNN_ia64_dyn_reloc_entry *rent;
|
||||||
bfd_boolean dynamic_symbol, shared;
|
bfd_boolean dynamic_symbol, shared, resolved_zero;
|
||||||
|
|
||||||
ia64_info = elfNN_ia64_hash_table (x->info);
|
ia64_info = elfNN_ia64_hash_table (x->info);
|
||||||
dynamic_symbol = elfNN_ia64_dynamic_symbol_p (dyn_i->h, x->info)
|
dynamic_symbol = elfNN_ia64_dynamic_symbol_p (dyn_i->h, x->info)
|
||||||
|| (elfNN_ia64_aix_vec (x->info->hash->creator)
|
|| (elfNN_ia64_aix_vec (x->info->hash->creator)
|
||||||
/* Don't allocate an entry for __GLOB_DATA_PTR */
|
/* Don't allocate an entry for __GLOB_DATA_PTR */
|
||||||
&& (!dyn_i->h || strcmp (dyn_i->h->root.root.string,
|
&& (!dyn_i->h || strcmp (dyn_i->h->root.root.string,
|
||||||
"__GLOB_DATA_PTR") != 0));
|
"__GLOB_DATA_PTR") != 0));
|
||||||
shared = x->info->shared;
|
shared = x->info->shared;
|
||||||
|
resolved_zero = (dyn_i->h
|
||||||
|
&& ELF_ST_VISIBILITY (dyn_i->h->other)
|
||||||
|
&& dyn_i->h->root.type == bfd_link_hash_undefweak);
|
||||||
|
|
||||||
/* Take care of the normal data relocations. */
|
/* Take care of the normal data relocations. */
|
||||||
|
|
||||||
@ -2813,8 +2819,12 @@ allocate_dynrel_entries (dyn_i, data)
|
|||||||
|
|
||||||
/* Take care of the GOT and PLT relocations. */
|
/* Take care of the GOT and PLT relocations. */
|
||||||
|
|
||||||
if (((dynamic_symbol || shared) && (dyn_i->want_got || dyn_i->want_gotx))
|
if ((!resolved_zero
|
||||||
|| (dyn_i->want_ltoff_fptr && dyn_i->h && dyn_i->h->dynindx != -1))
|
&& (dynamic_symbol || shared)
|
||||||
|
&& (dyn_i->want_got || dyn_i->want_gotx))
|
||||||
|
|| (dyn_i->want_ltoff_fptr
|
||||||
|
&& dyn_i->h
|
||||||
|
&& dyn_i->h->dynindx != -1))
|
||||||
ia64_info->rel_got_sec->_raw_size += sizeof (ElfNN_External_Rela);
|
ia64_info->rel_got_sec->_raw_size += sizeof (ElfNN_External_Rela);
|
||||||
if ((dynamic_symbol || shared) && dyn_i->want_tprel)
|
if ((dynamic_symbol || shared) && dyn_i->want_tprel)
|
||||||
ia64_info->rel_got_sec->_raw_size += sizeof (ElfNN_External_Rela);
|
ia64_info->rel_got_sec->_raw_size += sizeof (ElfNN_External_Rela);
|
||||||
@ -2823,7 +2833,7 @@ allocate_dynrel_entries (dyn_i, data)
|
|||||||
if (dynamic_symbol && dyn_i->want_dtprel)
|
if (dynamic_symbol && dyn_i->want_dtprel)
|
||||||
ia64_info->rel_got_sec->_raw_size += sizeof (ElfNN_External_Rela);
|
ia64_info->rel_got_sec->_raw_size += sizeof (ElfNN_External_Rela);
|
||||||
|
|
||||||
if (dyn_i->want_pltoff)
|
if (!resolved_zero && dyn_i->want_pltoff)
|
||||||
{
|
{
|
||||||
bfd_size_type t = 0;
|
bfd_size_type t = 0;
|
||||||
|
|
||||||
@ -3431,7 +3441,11 @@ set_got_entry (abfd, info, dyn_i, dynindx, addend, value, dyn_r_type)
|
|||||||
bfd_put_64 (abfd, value, got_sec->contents + got_offset);
|
bfd_put_64 (abfd, value, got_sec->contents + got_offset);
|
||||||
|
|
||||||
/* Install a dynamic relocation if needed. */
|
/* Install a dynamic relocation if needed. */
|
||||||
if ((info->shared && dyn_r_type != R_IA64_DTPREL64LSB)
|
if ((info->shared
|
||||||
|
&& (!dyn_i->h
|
||||||
|
|| ELF_ST_VISIBILITY (dyn_i->h->other) == STV_DEFAULT
|
||||||
|
|| dyn_i->h->root.type != bfd_link_hash_undefweak)
|
||||||
|
&& dyn_r_type != R_IA64_DTPREL64LSB)
|
||||||
|| elfNN_ia64_dynamic_symbol_p (dyn_i->h, info)
|
|| elfNN_ia64_dynamic_symbol_p (dyn_i->h, info)
|
||||||
|| elfNN_ia64_aix_vec (abfd->xvec)
|
|| elfNN_ia64_aix_vec (abfd->xvec)
|
||||||
|| (dynindx != -1 && dyn_r_type == R_IA64_FPTR64LSB))
|
|| (dynindx != -1 && dyn_r_type == R_IA64_FPTR64LSB))
|
||||||
@ -3552,7 +3566,11 @@ set_pltoff_entry (abfd, info, dyn_i, value, is_plt)
|
|||||||
bfd_put_64 (abfd, gp, pltoff_sec->contents + dyn_i->pltoff_offset + 8);
|
bfd_put_64 (abfd, gp, pltoff_sec->contents + dyn_i->pltoff_offset + 8);
|
||||||
|
|
||||||
/* Install dynamic relocations if needed. */
|
/* Install dynamic relocations if needed. */
|
||||||
if (!is_plt && info->shared)
|
if (!is_plt
|
||||||
|
&& info->shared
|
||||||
|
&& (!dyn_i->h
|
||||||
|
|| ELF_ST_VISIBILITY (dyn_i->h->other) == STV_DEFAULT
|
||||||
|
|| dyn_i->h->root.type != bfd_link_hash_undefweak))
|
||||||
{
|
{
|
||||||
unsigned int dyn_r_type;
|
unsigned int dyn_r_type;
|
||||||
|
|
||||||
|
@ -1,3 +1,8 @@
|
|||||||
|
2003-05-04 H.J. Lu <hjl@gnu.org>
|
||||||
|
|
||||||
|
* ld-elfvsb/main.c: Updated.
|
||||||
|
* ld-elfvsb/sh1.c: Likewise.
|
||||||
|
|
||||||
2003-05-04 H.J. Lu <hjl@gnu.org>
|
2003-05-04 H.J. Lu <hjl@gnu.org>
|
||||||
|
|
||||||
* ld-elfvers/vers18.dsym: Updated for weak definiton change.
|
* ld-elfvers/vers18.dsym: Updated for weak definiton change.
|
||||||
|
@ -165,6 +165,37 @@ main_visibility_checkweak ()
|
|||||||
{
|
{
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
#elif defined (HIDDEN_WEAK_TEST)
|
||||||
|
int
|
||||||
|
main_visibility_checkcom ()
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma weak visibility_undef_var_weak
|
||||||
|
extern int visibility_undef_var_weak;
|
||||||
|
asm (".hidden visibility_undef_var_weak");
|
||||||
|
|
||||||
|
#pragma weak visibility_undef_func_weak
|
||||||
|
extern int visibility_undef_func_weak ();
|
||||||
|
asm (".hidden visibility_undef_func_weak");
|
||||||
|
|
||||||
|
#pragma weak visibility_var_weak
|
||||||
|
extern int visibility_var_weak;
|
||||||
|
asm (".hidden visibility_var_weak");
|
||||||
|
|
||||||
|
#pragma weak visibility_func_weak
|
||||||
|
extern int visibility_func_weak ();
|
||||||
|
asm (".hidden visibility_func_weak");
|
||||||
|
|
||||||
|
int
|
||||||
|
main_visibility_checkweak ()
|
||||||
|
{
|
||||||
|
return &visibility_undef_var_weak == NULL
|
||||||
|
&& &visibility_undef_func_weak == NULL
|
||||||
|
&& &visibility_func_weak == NULL
|
||||||
|
&& &visibility_var_weak == NULL;
|
||||||
|
}
|
||||||
#elif defined (HIDDEN_UNDEF_TEST)
|
#elif defined (HIDDEN_UNDEF_TEST)
|
||||||
extern int visibility_def;
|
extern int visibility_def;
|
||||||
asm (".hidden visibility_def");
|
asm (".hidden visibility_def");
|
||||||
|
@ -339,6 +339,37 @@ shlib_visibility_checkweak ()
|
|||||||
{
|
{
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
#elif defined (HIDDEN_WEAK_TEST)
|
||||||
|
#pragma weak shlib_visibility_undef_var_weak
|
||||||
|
extern int shlib_visibility_undef_var_weak;
|
||||||
|
asm (".hidden shlib_visibility_undef_var_weak");
|
||||||
|
|
||||||
|
#pragma weak shlib_visibility_undef_func_weak
|
||||||
|
extern int shlib_visibility_undef_func_weak ();
|
||||||
|
asm (".hidden shlib_visibility_undef_func_weak");
|
||||||
|
|
||||||
|
#pragma weak shlib_visibility_var_weak
|
||||||
|
extern int shlib_visibility_var_weak;
|
||||||
|
asm (".hidden shlib_visibility_var_weak");
|
||||||
|
|
||||||
|
#pragma weak shlib_visibility_func_weak
|
||||||
|
extern int shlib_visibility_func_weak ();
|
||||||
|
asm (".hidden shlib_visibility_func_weak");
|
||||||
|
|
||||||
|
int
|
||||||
|
shlib_visibility_checkcom ()
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
shlib_visibility_checkweak ()
|
||||||
|
{
|
||||||
|
return &shlib_visibility_undef_var_weak == NULL
|
||||||
|
&& &shlib_visibility_undef_func_weak == NULL
|
||||||
|
&& &shlib_visibility_func_weak == NULL
|
||||||
|
&& &shlib_visibility_var_weak == NULL;
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
int
|
int
|
||||||
shlib_visibility_checkcom ()
|
shlib_visibility_checkcom ()
|
||||||
|
Reference in New Issue
Block a user