This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

PATCH: Set forced_local for hidden and internal symbols


On Thu, Jul 07, 2005 at 09:32:35PM -0700, H. J. Lu wrote:
> On Thu, Jul 07, 2005 at 10:58:57PM -0400, Carlos O'Donell wrote:
> > > 2. __init_array_start/__init_array_end are provided by linker for
> > > static exexcutables since DT_INIT_ARRAY isn't available.
> > 
> > Linking a dynamic executable adds libc_nonshared.a, which has undefined
> > references to __init_array_start and associated symbols.
> > 
> > It looks to me that the linker provides these symbols in all links,
> > wether static or dynamic executables.
> > 
> > In the later case, because the linker provides the symbol so late, it's
> > impossible to know if I should or shouldn't allocate space. Space is
> > allocated, and after the section sizes have been fixed, the linker
> > provides the symbols. At this point we know we don't need them, and we
> > don't emit a relocation. However, we can no longer resize the section.
> > 
> 
> I have
> 
> bash-3.00$ readelf -s /usr/lib/libc_nonshared.a| grep _array_
>      5: 00000000     0 NOTYPE  GLOBAL HIDDEN  UND __preinit_array_start
>      6: 00000000     0 NOTYPE  GLOBAL HIDDEN  UND __preinit_array_end
>      7: 00000000     0 NOTYPE  GLOBAL HIDDEN  UND __init_array_start
>      8: 00000000     0 NOTYPE  GLOBAL HIDDEN  UND __init_array_end
>      9: 00000000     0 NOTYPE  GLOBAL HIDDEN  UND __fini_array_start
>     10: 00000000     0 NOTYPE  GLOBAL HIDDEN  UND __fini_array_end
> 
> What do you have?
> 
> 

It turns out that we need this patch to handle hidden symbols provided
by linker correctly. We should do it since non-weak hidden and internal
symbols must be resolved locally.


H.J.
----
2005-07-08  H.J. Lu  <hongjiu.lu@intel.com>

	* elflink.c (bfd_elf_link_record_dynamic_symbol): Set
	forced_local for hidden and internal symbols if they aren't
	weak undefined.

--- bfd/elflink.c.local	2005-07-07 13:44:40.000000000 -0700
+++ bfd/elflink.c	2005-07-08 11:10:03.432739913 -0700
@@ -380,10 +380,11 @@ bfd_elf_link_record_dynamic_symbol (stru
 	{
 	case STV_INTERNAL:
 	case STV_HIDDEN:
+	  if (h->root.type != bfd_link_hash_undefweak)
+	    h->forced_local = 1;
 	  if (h->root.type != bfd_link_hash_undefined
 	      && h->root.type != bfd_link_hash_undefweak)
 	    {
-	      h->forced_local = 1;
 	      if (!elf_hash_table (info)->is_relocatable_executable)
 		return TRUE;
 	    }


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]