This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: PATCH: ld/3351: aborting at elflink.c line 6778 in elf_link_check_versioned_symbol
- From: "H. J. Lu" <hjl at lucon dot org>
- To: binutils at sources dot redhat dot com
- Date: Tue, 17 Oct 2006 17:57:12 -0700
- Subject: Re: PATCH: ld/3351: aborting at elflink.c line 6778 in elf_link_check_versioned_symbol
- References: <20061017233105.GA15015@lucon.org>
On Tue, Oct 17, 2006 at 04:31:05PM -0700, H. J. Lu wrote:
> When a shared library references a forced local symbol in executable,
> linker tries to issue an error. But it doesn't check indirect symbols.
> Also, when we update real symbol reference flags, we fail to update
> indirect symbol reference flags. This patch fixes both.
>
We have to be very careful about indiret symbol created by symbol
versioning. This patch only updates some indirect symbol flags Should
_bfd_elf_merge_symbol and elf_link_add_object_symbols update all
indirect symbol flags at the same time when we update real symbol
flags?
H.J.
----
2006-10-17 H.J. Lu <hongjiu.lu@intel.com>
PR ld/3351
* elflink.c (_bfd_elf_merge_symbol): Update indirect symbol
flags.
(elf_link_add_object_symbols): Likewise.
(elf_link_check_versioned_symbol): Check indirect symbol.
(elf_link_output_extsym): Use real symbol definition when
reporting indirect symbol error.
--- bfd/elflink.c.version 2006-10-17 07:11:12.000000000 -0700
+++ bfd/elflink.c 2006-10-17 17:49:32.000000000 -0700
@@ -829,6 +829,7 @@ _bfd_elf_merge_symbol (bfd *abfd,
{
asection *sec, *oldsec;
struct elf_link_hash_entry *h;
+ struct elf_link_hash_entry *hi;
struct elf_link_hash_entry *flip;
int bind;
bfd *oldbfd;
@@ -866,7 +867,7 @@ _bfd_elf_merge_symbol (bfd *abfd,
return TRUE;
/* For merging, we only care about real symbols. */
-
+ hi = h;
while (h->root.type == bfd_link_hash_indirect
|| h->root.type == bfd_link_hash_warning)
h = (struct elf_link_hash_entry *) h->root.u.i.link;
@@ -1021,7 +1022,12 @@ _bfd_elf_merge_symbol (bfd *abfd,
if (newdyn && !h->dynamic_def)
{
if (!bfd_is_und_section (sec))
- h->dynamic_def = 1;
+ {
+ h->dynamic_def = 1;
+ /* We need to make sure that indirect symbol flags are
+ updated. */
+ hi->dynamic_def = 1;
+ }
else
{
/* Check if this symbol is weak in all dynamic objects. If it
@@ -3644,6 +3650,7 @@ elf_link_add_object_symbols (bfd *abfd,
flagword flags;
const char *name;
struct elf_link_hash_entry *h;
+ struct elf_link_hash_entry *hi;
bfd_boolean definition;
bfd_boolean size_change_ok;
bfd_boolean type_change_ok;
@@ -3934,6 +3941,7 @@ elf_link_add_object_symbols (bfd *abfd,
goto error_free_vers;
h = *sym_hash;
+ hi = h;
while (h->root.type == bfd_link_hash_indirect
|| h->root.type == bfd_link_hash_warning)
h = (struct elf_link_hash_entry *) h->root.u.i.link;
@@ -4145,7 +4153,12 @@ elf_link_add_object_symbols (bfd *abfd,
else
{
if (! definition)
- h->ref_dynamic = 1;
+ {
+ h->ref_dynamic = 1;
+ /* We need to make sure that indirect symbol flags are
+ updated. */
+ hi->ref_dynamic = 1;
+ }
else
h->def_dynamic = 1;
if (h->def_regular
@@ -6729,6 +6742,10 @@ elf_link_check_versioned_symbol (struct
if (!is_elf_hash_table (info->hash))
return FALSE;
+ /* Check indirect symbol. */
+ while (h->root.type == bfd_link_hash_indirect)
+ h = (struct elf_link_hash_entry *) h->root.u.i.link;
+
switch (h->root.type)
{
default:
@@ -6937,11 +6954,17 @@ elf_link_output_extsym (struct elf_link_
&& !h->dynamic_weak
&& ! elf_link_check_versioned_symbol (finfo->info, bed, h))
{
+ struct elf_link_hash_entry *hi = h;
+
+ /* Check indirect symbol. */
+ while (hi->root.type == bfd_link_hash_indirect)
+ hi = (struct elf_link_hash_entry *) hi->root.u.i.link;
+
(*_bfd_error_handler)
(_("%B: %s symbol `%s' in %B is referenced by DSO"),
finfo->output_bfd,
- h->root.u.def.section == bfd_abs_section_ptr
- ? finfo->output_bfd : h->root.u.def.section->owner,
+ hi->root.u.def.section == bfd_abs_section_ptr
+ ? finfo->output_bfd : hi->root.u.def.section->owner,
ELF_ST_VISIBILITY (h->other) == STV_INTERNAL
? "internal"
: ELF_ST_VISIBILITY (h->other) == STV_HIDDEN