[AArch64] Fall back to -fPIC if no support of -fpic in binutils
authorJiong Wang <jiong.wang@arm.com>
Wed, 1 Jul 2015 08:45:08 +0000 (08:45 +0000)
committerJiong Wang <jiwang@gcc.gnu.org>
Wed, 1 Jul 2015 08:45:08 +0000 (08:45 +0000)
2015-07-01  Jiong Wang  <jiong.wang@arm.com>

* configure.ac: Add check for aarch64 assembler -fpic relocation
modifier support.
* configure: Regenerate.
* config.in: Regenerate.
* config/aarch64/aarch64.c (initialize_aarch64_code_model): Fall back
to -fPIC if not support of -fpic relocation modifier in assembler.

From-SVN: r225231

gcc/ChangeLog
gcc/config.in
gcc/config/aarch64/aarch64.c
gcc/configure
gcc/configure.ac

index 40754f10c944c48af249e11c827f42511710b34c..e9ba35fbfe1f4805ea7cbf7368bc2dad4e8f1bd6 100644 (file)
@@ -1,3 +1,12 @@
+2015-07-01  Jiong Wang  <jiong.wang@arm.com>
+
+       * configure.ac: Add check for aarch64 assembler -fpic relocation
+       modifier support.
+       * configure: Regenerate.
+       * config.in: Regenerate.
+       * config/aarch64/aarch64.c (initialize_aarch64_code_model): Fall back
+       to -fPIC if not support of -fpic relocation modifier in assembler.
+
 2015-07-01  Richard Sandiford  <richard.sandiford@arm.com>
 
        PR bootstrap/66685
index 3aee936c473e2e316bf0bc807df264a4eeaf8fcf..b031a62e838327232a62e4eac6aa127402ab7dbc 100644 (file)
 #endif
 
 
+/* Define if your assembler supports relocs needed by -fpic. */
+#ifndef USED_FOR_TARGET
+#undef HAVE_AS_SMALL_PIC_RELOCS
+#endif
+
+
 /* Define if your assembler and linker support thread-local storage. */
 #ifndef USED_FOR_TARGET
 #undef HAVE_AS_TLS
index 0079c82b0f83966942fedf0d02a06bbca35bed62..5d4dc83f44816a5f2ff9e780ce402a634ad1fd83 100644 (file)
@@ -7581,9 +7581,13 @@ initialize_aarch64_code_model (void)
           aarch64_cmodel = AARCH64_CMODEL_TINY_PIC;
           break;
         case AARCH64_CMODEL_SMALL:
+#ifdef HAVE_AS_SMALL_PIC_RELOCS
           aarch64_cmodel = (flag_pic == 2
                             ? AARCH64_CMODEL_SMALL_PIC
                             : AARCH64_CMODEL_SMALL_SPIC);
+#else
+          aarch64_cmodel = AARCH64_CMODEL_SMALL_PIC;
+#endif
           break;
         case AARCH64_CMODEL_LARGE:
           sorry ("code model %qs with -f%s", "large",
index 50d7037c37ead98d9abc00d7f22e4aa04c2c1f53..9561e5c71cc19fedb0d70104c509f0d6b1a90fa5 100755 (executable)
@@ -24228,6 +24228,40 @@ $as_echo "#define HAVE_AS_MABI_OPTION 1" >>confdefs.h
         done
       fi
     fi
+    # Check if we have binutils support for relocations types needed by -fpic
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking assembler for -fpic relocs" >&5
+$as_echo_n "checking assembler for -fpic relocs... " >&6; }
+if test "${gcc_cv_as_aarch64_picreloc+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  gcc_cv_as_aarch64_picreloc=no
+  if test x$gcc_cv_as != x; then
+    $as_echo '
+       .text
+       ldr     x0, [x2, #:gotpage_lo15:globalsym]
+    ' > conftest.s
+    if { ac_try='$gcc_cv_as $gcc_cv_as_flags  -o conftest.o conftest.s >&5'
+  { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; }
+    then
+       gcc_cv_as_aarch64_picreloc=yes
+    else
+      echo "configure: failed program was" >&5
+      cat conftest.s >&5
+    fi
+    rm -f conftest.o conftest.s
+  fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_as_aarch64_picreloc" >&5
+$as_echo "$gcc_cv_as_aarch64_picreloc" >&6; }
+if test $gcc_cv_as_aarch64_picreloc = yes; then
+
+$as_echo "#define HAVE_AS_SMALL_PIC_RELOCS 1" >>confdefs.h
+
+fi
     # Enable default workaround for AArch64 Cortex-A53 erratum 835769.
     # Check whether --enable-fix-cortex-a53-835769 was given.
 if test "${enable_fix_cortex_a53_835769+set}" = set; then :
index 88aecdbf3e1c26dc305e77c6550151675d0dee3b..cb1463930c640e9600b9d3329f3683bb4f0bba13 100644 (file)
@@ -3562,6 +3562,13 @@ case "$target" in
         done
       fi
     fi
+    # Check if we have binutils support for relocations types needed by -fpic
+    gcc_GAS_CHECK_FEATURE([-fpic relocs], gcc_cv_as_aarch64_picreloc,,,
+    [
+       .text
+       ldr     x0, [[x2, #:gotpage_lo15:globalsym]]
+    ],,[AC_DEFINE(HAVE_AS_SMALL_PIC_RELOCS, 1,
+       [Define if your assembler supports relocs needed by -fpic.])])
     # Enable default workaround for AArch64 Cortex-A53 erratum 835769.
     AC_ARG_ENABLE(fix-cortex-a53-835769,
     [