[RFC] Providing init_fini_syms earlier?

Michael Matz matz@suse.de
Fri Aug 5 06:05:00 GMT 2005


Hi,

On Thu, 14 Jul 2005, Alan Modra wrote:

> This is how I think we should handle these symbols.
> 
> bfd/
> 	* bfd-in.h (_bfd_elf_fix_excluded_sec_syms): Declare.
> 	(_bfd_elf_provide_section_bound_symbols): Remove param name.
> 	Formatting.
> 	* bfd-in2.h: Regenerate.
> 	* elflink.c (bfd_elf_gc_sections): Don't call generic function.
> 	(_bfd_elf_provide_symbol): Formatting.
> 	(_bfd_elf_provide_section_bound_symbols): Remove all hacks, just
> 	create section relative syms.
> 	(fix_syms, _bfd_elf_fix_excluded_sec_syms): New functions.

How I wish having more time following the binutils@ list.  Then I would 
have noticed this earlier, so sorry.  This patch which in one or the other 
form seems now to be in binutils breaks alpha again.  The problem is, that 
there _is no_ section .init_array to which these symbols could be relative 
to.  Hence all the new fixup code (fix_syms which is supposed to convert 
the value to absolute should the base section be a discarded one) doesn't 
apply.

This results in the values of all these symbols being 0 and hence
resulting in the errors which "all hacks" originally there were supposed
to solve, namely relocation overflows.  These symbols must (on axp):
  1) exist
  2) be in 2GB range of the base address
even if there's no section.

The second invariant plus the "no section" part made me base these symbols 
values on .bss, which HJ later refined to "base of first ALLOC section".  
You removed this fall-back handling of non-existent sections again, so do 
you have perhaps a better idea how to solve this issue (short of going 
back to let the linker script provide them, as that was the initial reason 
to let the linker provide these symbols)?

> !   if (sec != NULL)
> !     {
> !       start_val = sec->vma;
> !       end_val = start_val + sec->size;
> !     }
> !   else
>       {
> !       /* We have to choose those values very carefully.  Some targets,
> ! 	 like alpha, may have relocation overflow with 0. "__bss_start"
> ! 	 should be defined in all cases.  */
> !       struct elf_link_hash_entry *h
> ! 	= elf_link_hash_lookup (elf_hash_table (info), "__bss_start",
> ! 				FALSE, FALSE, FALSE);
> !       if (h != NULL && h->root.type == bfd_link_hash_defined)
> ! 	start_val = h->root.u.def.value;
> !       else
> ! 	start_val = 0;
> !       end_val = start_val;
>       }

Just for reference, this was the original code.  Note how the value is set 
to something sane when sec==NULL.  Your replacement just uses 0 in that 
case.


Ciao,
Michael.



More information about the Binutils mailing list