This is the mail archive of the binutils@sourceware.org mailing list for the binutils 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: [1/2][AArch64, gas] Support ILP32 triplet aarch64*-linux-gnu_ilp32


On 18/05/17 16:53, Nick Clifton wrote:
Hi Jiong,

+void
+aarch64_after_parse_args (void)
+{
+  if (aarch64_abi != AARCH64_ABI_NONE)
+    return;
+
+  if (default_arch[7] == '\0')
+    aarch64_abi = AARCH64_ABI_LP64;
+  else
+    aarch64_abi = AARCH64_ABI_ILP32;
The test here strikes me as being rather obtuse.  Presumably you are
checking to see if the default_arch string has the :32 extension,

That's exactly what I am doing.

but
this is not obvious from the code.  Plus it will break if there are
ever any other qualifiers added to the architecture string.  I would
suggest at least testing for:

   strlen (default_arch) > 7 && strcmp (default_arch + 7, ":32") == 0

I was borrowing check from i386_target_format, above suggestion make sense do look better.

I have updated the patch to use above condition.  Qualified triplet will
be treated as ILP32, otherwise simply defaulting to LP64.

Please review.

Thanks.

2017-05-22  Jiong Wang  <jiong.wang@arm.com>

gas/
* configure.tgt: Set "arch" to "aarch64" if ${cpu} equals "aarch64".
         Recognize the new triplet name aarch64*-linux-gnu_ilp32.
         * configure.ac: Output DEFAULT_ARCH macro for AArch64.
         * configure: Regenerate.
         * config/tc-aarch64.h (aarch64_after_parse_args): New declaration.
         (md_after_parse_args): New define.
         * config/tc-aarch64.c (aarch64_abi_type): New enumeration
         AARCH64_ABI_NONE.
         (DEFAULT_ARCH): New define.
         (aarch64_abi): Set default value to AARCH64_ABI_NONE.
         (aarch64_after_parse_args): New function.


diff --git a/gas/config/tc-aarch64.c b/gas/config/tc-aarch64.c
index a9dbd54..1b56282 100644
--- a/gas/config/tc-aarch64.c
+++ b/gas/config/tc-aarch64.c
@@ -62,12 +62,20 @@ static symbolS *GOT_symbol;
 /* Which ABI to use.  */
 enum aarch64_abi_type
 {
-  AARCH64_ABI_LP64 = 0,
-  AARCH64_ABI_ILP32 = 1
+  AARCH64_ABI_NONE = 0,
+  AARCH64_ABI_LP64 = 1,
+  AARCH64_ABI_ILP32 = 2
 };
 
+#ifndef DEFAULT_ARCH
+#define DEFAULT_ARCH "aarch64"
+#endif
+
+/* DEFAULT_ARCH is initialized in gas/configure.tgt.  */
+static const char *default_arch = DEFAULT_ARCH;
+
 /* AArch64 ABI for the output file.  */
-static enum aarch64_abi_type aarch64_abi = AARCH64_ABI_LP64;
+static enum aarch64_abi_type aarch64_abi = AARCH64_ABI_NONE;
 
 /* When non-zero, program to a 32-bit model, in which the C data types
    int, long and all pointer types are 32-bit objects (ILP32); or to a
@@ -7975,6 +7983,22 @@ aarch64_force_relocation (struct fix *fixp)
 
 #ifdef OBJ_ELF
 
+/* Implement md_after_parse_args.  This is the earliest time we need to decide
+   ABI.  If no -mabi specified, the ABI will be decided by target triplet.  */
+
+void
+aarch64_after_parse_args (void)
+{
+  if (aarch64_abi != AARCH64_ABI_NONE)
+    return;
+
+  /* DEFAULT_ARCH will have ":32" extension if it's configured for ILP32.  */
+  if (strlen (default_arch) > 7 && strcmp (default_arch + 7, ":32") == 0)
+    aarch64_abi = AARCH64_ABI_ILP32;
+  else
+    aarch64_abi = AARCH64_ABI_LP64;
+}
+
 const char *
 elf64_aarch64_target_format (void)
 {
diff --git a/gas/config/tc-aarch64.h b/gas/config/tc-aarch64.h
index d5bcce2..e7a8464 100644
--- a/gas/config/tc-aarch64.h
+++ b/gas/config/tc-aarch64.h
@@ -193,6 +193,9 @@ struct aarch64_segment_info_type
 #define tc_regname_to_dw2regnum            tc_aarch64_regname_to_dw2regnum
 #define tc_cfi_frame_initial_instructions  tc_aarch64_frame_initial_instructions
 
+extern void aarch64_after_parse_args (void);
+#define md_after_parse_args() aarch64_after_parse_args ()
+
 #else /* Not OBJ_ELF.  */
 #define GLOBAL_OFFSET_TABLE_NAME "__GLOBAL_OFFSET_TABLE_"
 #endif
diff --git a/gas/configure b/gas/configure
index d3ae96e..96fa7cb 100755
--- a/gas/configure
+++ b/gas/configure
@@ -12583,7 +12583,7 @@ $as_echo "#define NDS32_DEFAULT_AUDIO_EXT 1" >>confdefs.h
 $as_echo "$enable_audio_ext" >&6; }
 	;;
 
-      i386 | riscv | s390 | sparc)
+      aarch64 | i386 | riscv | s390 | sparc)
 	if test $this_target = $target ; then
 
 cat >>confdefs.h <<_ACEOF
diff --git a/gas/configure.ac b/gas/configure.ac
index cc70aa7..da161b7 100644
--- a/gas/configure.ac
+++ b/gas/configure.ac
@@ -511,7 +511,7 @@ changequote([,])dnl
 	AC_MSG_RESULT($enable_audio_ext)
 	;;
 
-      i386 | riscv | s390 | sparc)
+      aarch64 | i386 | riscv | s390 | sparc)
 	if test $this_target = $target ; then
 	  AC_DEFINE_UNQUOTED(DEFAULT_ARCH, "${arch}", [Default architecture.])
 	fi
diff --git a/gas/configure.tgt b/gas/configure.tgt
index ca58b69..9d5e781 100644
--- a/gas/configure.tgt
+++ b/gas/configure.tgt
@@ -46,8 +46,8 @@ eval `echo $targ | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/cpu=\1 vendor=\2 os=\3/'`
 # endian and arch.
 # Note: This table is alpha-sorted, please try to keep it that way.
 case ${cpu} in
-  aarch64)		cpu_type=aarch64 endian=little ;;
-  aarch64_be)		cpu_type=aarch64 endian=big ;;
+  aarch64)		cpu_type=aarch64 endian=little arch=aarch64;;
+  aarch64_be)		cpu_type=aarch64 endian=big arch=aarch64;;
   alpha*)		cpu_type=alpha ;;
   am33_2.0)		cpu_type=mn10300 endian=little ;;
   arc*eb)		cpu_type=arc endian=big ;;
@@ -126,7 +126,10 @@ generic_target=${cpu_type}-$vendor-$os
 case ${generic_target} in
   aarch64*-*-elf*)			fmt=elf;;
   aarch64*-*-fuchsia*)			fmt=elf;;
-  aarch64*-*-linux*)			fmt=elf em=linux ;;
+  aarch64*-*-linux*)			fmt=elf em=linux
+    case ${cpu}-${os} in
+      aarch64*-linux-gnu_ilp32)		arch=aarch64:32 ;;
+    esac ;;
 
   alpha-*-*vms*)			fmt=evax ;;
   alpha-*-osf*)				fmt=ecoff ;;


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