This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: [RFC] Providing init_fini_syms earlier?
- From: Michael Matz <matz at suse dot de>
- To: Alan Modra <amodra at bigpond dot net dot au>
- Cc: "H. J. Lu" <hjl at lucon dot org>, binutils at sources dot redhat dot com
- Date: Fri, 5 Aug 2005 08:05:39 +0200 (CEST)
- Subject: Re: [RFC] Providing init_fini_syms earlier?
- References: <20050711144500.GB31057@lucon.org> <20050711145106.GL5314@systemhalted.org><20050711174741.GA1456@lucon.org> <20050711180655.GN5314@systemhalted.org><20050711190623.GP4740@sunsite.mff.cuni.cz> <20050711212643.GA4707@lucon.org><20050712005740.GI30960@bubble.grove.modra.org> <20050713004712.GA27973@lucon.org><20050713133211.GN30960@bubble.grove.modra.org> <20050713134825.GO30960@bubble.grove.modra.org><20050714135406.GA28189@bubble.grove.modra.org>
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.