This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]