[David Mosberger <davidm@hpl.hp.com>] problem with unwind info for .init/.fini sections

Alan Modra amodra@bigpond.net.au
Sat Mar 2 02:19:00 GMT 2002


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



More information about the Binutils mailing list