diff mbox

POWERPC64_TOC_POINTER_ALIGNMENT

Message ID 20151117232241.GF8120@bubble.grove.modra.org
State New
Headers show

Commit Message

Alan Modra Nov. 17, 2015, 11:22 p.m. UTC
David noticed that gcc112 was generating gcc/auto-host.h with
#define POWERPC64_TOC_POINTER_ALIGNMENT 32768

This is not the correct value of either 8 or 256 depending on how old
ld is.  On investigating I found the cause is Fedora 21 modifying the
toolchain to default to -z relro.  ld -z relro puts the relro gap just
before .got (prior to my patches reordering sections for relro on
powerpc64).  That unfortunately aligns .got, defeating the deliberate
mis-alignment of .got in the testcase.

Fixed with the following obvious patch and committed to mainline.

Incidentally, bootstrap fails for me on powerpc64 due to "comparison
is always true due to limited range of data type [-Wtype-limits]"
        && GET_MODE_SIZE (mode) <= POWERPC64_TOC_POINTER_ALIGNMENT));
since my POWERPC64_TOC_POINTER_ALIGNMENT is 256 and mode_size is an
unsigned char array.  Grrr, so what code obfuscation do we use here to
work around this annoying warning?

Cross compiling from x86_64..
/src/gcc-virgin/configure \
--with-sysroot=/powerpc64le-linux --prefix=/usr/local \
--target=powerpc64le-linux --with-cpu=power8 \
--enable-targets=powerpc64-linux,powerpc-linux,powerpcle-linux \
--disable-multilib --disable-nls --enable-__cxa_atexit \
--enable-gnu-indirect-function --enable-secureplt --with-long-double-128 \
--enable-languages=all,go

..fails with:
In file included from /src/gcc-virgin/libgcc/libgcov-driver.c:49:0:
/src/gcc-virgin/libgcc/../gcc/gcov-io.c: In function 'gcov_do_dump':
/src/gcc-virgin/libgcc/../gcc/gcov-io.c:731:51: internal compiler error: in convert_move, at expr.c:286
       r = sizeof (long long) * __CHAR_BIT__ - 1 - __builtin_clzll (v);
                                                   ^~~~~~~~~~~~~~~~~~~
0x7d5250 convert_move(rtx_def*, rtx_def*, int)
        /src/gcc-virgin/gcc/expr.c:286
0x8b0e67 expand_direct_optab_fn
        /src/gcc-virgin/gcc/internal-fn.c:2132
0x6cfd9b expand_call_stmt
        /src/gcc-virgin/gcc/cfgexpand.c:2565
0x6cfd9b expand_gimple_stmt_1
        /src/gcc-virgin/gcc/cfgexpand.c:3525
0x6cfd9b expand_gimple_stmt
        /src/gcc-virgin/gcc/cfgexpand.c:3688
0x6d171e expand_gimple_basic_block
        /src/gcc-virgin/gcc/cfgexpand.c:5694
0x6d7f96 execute
        /src/gcc-virgin/gcc/cfgexpand.c:6309
diff mbox

Patch

Index: gcc/ChangeLog
===================================================================
--- gcc/ChangeLog	(revision 230508)
+++ gcc/ChangeLog	(working copy)
@@ -1,3 +1,9 @@ 
+2015-11-18  Alan Modra  <amodra@gmail.com>
+
+	* configure.ac (POWERPC64_TOC_POINTER_ALIGNMENT): Pass -z norelro
+	to ld.
+	* configure: Regenerate.
+
 2015-11-17  Tom de Vries  <tom@codesourcery.com>
 
 	* tree-ssa-loop.c (pass_tree_loop_init::execute): Improve comments.
Index: gcc/configure.ac
===================================================================
--- gcc/configure.ac	(revision 230508)
+++ gcc/configure.ac	(working copy)
@@ -5257,7 +5257,7 @@ 
 x:	.quad .TOC.
 EOF
       if $gcc_cv_as -a64 -o conftest.o conftest.s > /dev/null 2>&1 \
-         && $gcc_cv_ld $emul_name -o conftest conftest.o > /dev/null 2>&1; then
+         && $gcc_cv_ld $emul_name -z norelro -o conftest conftest.o > /dev/null 2>&1; then
         gcc_cv_ld_toc_align=`$gcc_cv_nm conftest | ${AWK} '/\.TOC\./ { match ($0, "0[[[:xdigit:]]]*", a); print strtonum ("0x" substr(a[[0]], length(a[[0]])-3)) }'`
       fi
       rm -f conftest conftest.o conftest.s