This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: [David Mosberger <davidm@hpl.hp.com>] problem with unwind info for .init/.fini sections
- From: Alan Modra <amodra at bigpond dot net dot au>
- To: "H . J . Lu" <hjl at lucon dot org>
- Cc: davidm at hpl dot hp dot com, Richard Henderson <rth at redhat dot com>, Ulrich Drepper <drepper at redhat dot com>, GNU libc hacker <libc-hacker at sources dot redhat dot com>, binutils at sources dot redhat dot com
- Date: Sat, 2 Mar 2002 20:49:31 +1030
- Subject: Re: [David Mosberger <davidm@hpl.hp.com>] problem with unwind info for .init/.fini sections
- References: <m3g03lfd1g.fsf@myware.mynet> <20020228165851.A26168@lucon.org> <15486.55079.333535.999190@napali.hpl.hp.com> <20020228173311.A26728@lucon.org> <15486.56491.696020.742674@napali.hpl.hp.com> <20020228175426.A30756@redhat.com> <15487.8879.719511.86715@napali.hpl.hp.com> <20020228225757.A30933@redhat.com> <15487.51034.573513.390031@napali.hpl.hp.com> <20020302003645.A20582@lucon.org>
On Sat, Mar 02, 2002 at 12:36:45AM -0800, H . J . Lu wrote:
>
> .init_array, .fini_array and .preinit_array are new special sections.
> We need to make sure their types and attributes are correct. Here is
> a patch.
I like this, but there is a mistake in the following
> @@ -3370,18 +3371,27 @@ NAME(bfd_elf,size_dynamic_sections) (out
> return false;
> }
>
> - for (sub = info->input_bfds; sub != NULL; sub = sub->link_next)
> - for (o = sub->sections; o != NULL; o = o->next)
> - {
> - /* yuck, more matching by name... */
> -
> - if (strcmp (bfd_section_name (sub, o), ".preinit_array") == 0)
> + for (sub = info->input_bfds; sub != NULL && initfini_array != 3;
> + sub = sub->link_next)
> + for (o = sub->sections; o != NULL && initfini_array != 3;
> + o = o->next)
> + switch (elf_section_data (o->output_section)->this_hdr.sh_type)
> + {
> + case SHT_PREINIT_ARRAY:
> need_preinit_array = 1;
> - if (strcmp (bfd_section_name (sub, o), ".init_array") == 0)
> + initfini_array++;
Presumably, initfini_array is trying to cut short the section search
after finding one of each of the section types. I can't see anything
in the ELF spec that precludes having, say, three SHT_PREINIT_ARRAY
input sections. Best get rid of initfini_array entirely.
The other thing is that you'll need to extend your patch a little
to handle these section types in bfd_section_from_shdr.
--
Alan Modra
IBM OzLabs - Linux Technology Centre