This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: [PATCH] Fix tst-array* on x86_64
- From: Jakub Jelinek <jakub at redhat dot com>
- To: "H. J. Lu" <hjl at lucon dot org>
- Cc: Roland McGrath <roland at redhat dot com>, Ulrich Drepper <drepper at redhat dot com>, Glibc hackers <libc-hacker at sources dot redhat dot com>, binutils at sources dot redhat dot com
- Date: Tue, 10 Dec 2002 19:06:27 +0100
- Subject: Re: [PATCH] Fix tst-array* on x86_64
- References: <20021210145250.M1310@sunsite.ms.mff.cuni.cz> <20021210094308.A11254@lucon.org>
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
On Tue, Dec 10, 2002 at 09:43:08AM -0800, H. J. Lu wrote:
> On Tue, Dec 10, 2002 at 02:52:50PM +0100, Jakub Jelinek wrote:
> > Hi!
> >
> > This is actually the same crap as I had to work around in test-string.h,
> > ie. x86_64 aligns preinit_array etc. to 16 bytes because they are >=
> > 16 bytes, yet its actual size is 24 bytes.
> > /* x86-64 ABI requires arrays greater than 16 bytes to be aligned
> > to 16byte boundary. */
> > Linker script of course doesn't expect .init_array/.fini_array/.preinit_array
> > sections to be more than word aligned and thus the labels around them
> > are on wrong positions.
> >
> > 2002-12-10 Jakub Jelinek <jakub@redhat.com>
> >
> > * elf/tst-array1.c (preinit_array, init_array, fini_array):
> > Explicitely align the array to sizeof (void *).
> > * elf/tst-array2dep.c (init_array, fini_array): Likewise.
> >
> > --- libc/elf/tst-array1.c.jj 2002-11-07 23:28:04.000000000 +0100
> > +++ libc/elf/tst-array1.c 2002-12-10 16:01:54.000000000 +0100
> > @@ -35,7 +35,7 @@ preinit_2 (void)
> > }
> >
> > void (*const preinit_array []) (void)
> > - __attribute__ ((section (".preinit_array"))) =
> > + __attribute__ ((section (".preinit_array"), aligned (sizeof (void *)))) =
> > {
> > &preinit_0,
> > &preinit_1,
>
> I assume size of void * is 8 byte for x86_64. Will it align at 16 byte?
Yes. It will align that way any array whose entries are aligned to <= 16 bytes
and whose size is >= 16 bytes.
E.g. if:
void (*const preinit_array_0) (void) __attribute__ ((section (".preinit_array"))) = &preinit_0;
void (*const preinit_array_1) (void) __attribute__ ((section (".preinit_array"))) = &preinit_1;
void (*const preinit_array_2) (void) __attribute__ ((section (".preinit_array"))) = &preinit_2;
was used instead, it would be just 8 aligned.
> Those *_array sections are special sections. Should they be handled by
> gas/ld automatically?
It is gcc's problem (and in this case testcase writer's problem) to follow
the rules.
Jakub