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: David Mosberger <davidm at napali dot hpl dot hp dot com>
- To: Alan Modra <amodra at bigpond dot net dot au>
- Cc: "H . J . Lu" <hjl at lucon dot org>, 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 09:19:16 -0800
- 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><20020302101931.GM1059@bubble.sa.bigpond.net.au>
- Reply-to: davidm at hpl dot hp dot com
>>>>> On Sat, 2 Mar 2002 20:49:31 +1030, Alan Modra <amodra@bigpond.net.au> said:
Alan> 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.
Alan> 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++;
Alan> Presumably, initfini_array is trying to cut short the section
Alan> search after finding one of each of the section types. I
Alan> can't see anything in the ELF spec that precludes having, say,
Alan> three SHT_PREINIT_ARRAY input sections. Best get rid of
Alan> initfini_array entirely.
The loop really only needs to determine whether any _input_ sections
contain the preinit/init/fini arrays. You could use a bitmask and
stop the search as soon as all three array sections have occurred at
least once.
I considered doing that but opted not to do so for clarity and because
I wasn't sure how often preinit arrays will be used: if it turns out
that most executables do not use preinit arrays, then the optimization
won't be very useful.
Alan> The other thing is that you'll need to extend your patch a
Alan> little to handle these section types in bfd_section_from_shdr.
Also, note that elfxx-ia64.c already has code to set the section
types. It's good if this can be moved to elf.c, but there is no point
in keeping two copies of this code.
--david