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

H . J . Lu hjl@lucon.org
Sat Mar 2 13:43:00 GMT 2002


On Sat, Mar 02, 2002 at 12:57:11PM -0800, David Mosberger wrote:
> >>>>> On Sat, 2 Mar 2002 12:53:50 -0800, "H . J . Lu" <hjl@lucon.org> said:
> 
>   HJ> On Sat, Mar 02, 2002 at 12:40:27PM -0800, David Mosberger wrote:
>   >> >>>>> On Sat, 2 Mar 2002 12:28:20 -0800, "H . J . Lu" <hjl@lucon.org> said:
>   >> 
>   HJ> +      if (bfd_get_section_by_name (output_bfd, ".preinit_array") != NULL)
>   >> 
>   >> I don't think this works as intended: the section always exists in the
>   >> output_bfd at that time.  At least this is what it looked like when I
>   >> tried it.  That's why I switched to walking the input files and
>   >> sections.
> 
>   HJ> It seems to work for me.
> 
> Ah, that's good.  Perhaps it didn't work for me because I still had
> the start/end labels defined inside the sections at that time.

I noticed 2 problems:

1. glibc doesn't support .*_array in executales. elf/dl-init.c is not
used on executables. However, sysdeps/generic/libc-start.c doesn't
know how to do it. Glibc needs to be modified to call those functions
with __*_array_start/__*_array_end.
2. For

static void
foo ()
{
  printf ("hello world\n");
}

void (*array []) () __attribute__ ((section (".init_array"))) =
{
  &foo
};

main ()
{
 (array [0]) ();
}

I got

/tmp/f.s:23: Warning: setting incorrect section type for .init_array

The problem is

	.section        .init_array,"aw",@progbits

We can use

+  { ".init_array",SHT_PROGBITS, SHF_ALLOC + SHF_WRITE         }, 
+  { ".fini_array",SHT_PROGBITS, SHF_ALLOC + SHF_WRITE         },
+  { ".preinit_array",SHT_PROGBITS, SHF_ALLOC + SHF_WRITE   }, 

in gas and let bfd to set the section type. Or we can teach gcc about
those special sections.


H.J.



More information about the Binutils mailing list