This is the mail archive of the
libc-alpha@sources.redhat.com
mailing list for the glibc project.
Re: [David Mosberger <davidm@hpl.hp.com>] problem with unwind info for .init/.fini sections
- From: "H . J . Lu" <hjl at lucon dot org>
- To: davidm at hpl dot hp dot com
- Cc: binutils at sources dot redhat dot com,GNU C Library <libc-alpha at sources dot redhat dot com>, gcc at gcc dot gnu dot org
- Date: Sat, 2 Mar 2002 13:43:44 -0800
- Subject: Re: [David Mosberger <davidm@hpl.hp.com>] problem with unwind info for .init/.fini sections
- References: <20020302101931.GM1059@bubble.sa.bigpond.net.au> <15489.2452.737686.119846@napali.hpl.hp.com> <20020302105939.A29014@lucon.org> <15489.9289.875243.619282@napali.hpl.hp.com> <20020302112708.A29383@lucon.org> <15489.10696.478128.294511@napali.hpl.hp.com> <20020302122820.A30304@lucon.org> <15489.14523.106980.19024@napali.hpl.hp.com> <20020302125350.A30699@lucon.org> <15489.15527.409686.667458@napali.hpl.hp.com>
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.