This is the mail archive of the 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: [PATCH, GCC 4.7] Backport fix for PR tree-optimization/53708

On Tue, 2012-10-30 at 11:58 -0500, Peter Bergner wrote:
> I'm hitting the same bug as in PR53708 when compiling GLIBC's dlfcn.c when
> vectorization is enabled on powerpc64-linux.  A reduced test case is:
> bergner@bns:~/gcc/BUGS> cat foo.i 
> static void (*const init_array []) (void)
>   __attribute__ ((section (".init_array"), aligned (sizeof (void *)), used))
> = { 0 };
> bergner@bns:~/gcc/BUGS> /home/bergner/gcc/build/gcc-fsf-4_7-base/gcc/xgcc
> -B/home/bergner/gcc/build/gcc-fsf-4_7-base/gcc -S -m64 -O3 -maltivec foo.i -o
> bad.s
> bergner@bns:~/gcc/BUGS> /home/bergner/gcc/build/gcc-fsf-4_7-pr53708/gcc/xgcc
> -B/home/bergner/gcc/build/gcc-fsf-4_7-pr53708/gcc -S -m64 -O3 -maltivec foo.i
> -o good.s
> bergner@bns:~/gcc/BUGS> diff -u bad.s good.s 
> --- bad.s    2012-10-30 10:41:15.000000000 -0500
> +++ good.s    2012-10-30 10:41:23.000000000 -0500
> @@ -2,7 +2,7 @@
>      .section    ".toc","aw"
>      .section    ".text"
>      .section    .init_array,"a"
> -    .align 4
> +    .align 3
>      .type    init_array, @object
>      .size    init_array, 8
>  init_array:
> The above is bad, because the extra alignment causes the linker to add some
> null padding to the init_array and the loader isn't expecting that and ends
> up segv'ing.  I'd like to backport Richard's patch below to the 4.7 branch.
> The patch bootstrapped and regtested on powerpc64-linux with no regressions.

Commenting on Richard's question from the bugzilla:

I suppose if attribute((__aligned__)) truly does just set a minimum alignment
value (and the documentation seems to say that) and the compiler is free to
arbitrarily increase it, then the GLIBC code to scan the init_array needs to
be tolerant of null values in init_array.

Does everyone agree with that assessment?


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