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: [AArch64] Binutils/gas/ld port for ARM's new 64-bit architecture, AArch64 [6/6] binutils changes v2


Hi,

On 07/30/12 16:16, Joseph S. Myers wrote:
On Mon, 30 Jul 2012, Yufeng Zhang wrote:

This patch adds the binutils changes of the AArch64 target support.

Are you sure this is adding full support to readelf? You appear to have some architecture-specific PT_*, SHT_* and SHF_* values in elf/aarch64.h, so readelf should know how to display those - and in general such support is conditioned on the architecture, so even if the names and values are the same as for ARM, I'd expect you to need conditionals to enable the decoding for AArch64 as well as for ARM. (In general I'd advise going through the ELF ABI and making sure that all such architecture-specific values from the ABI are (a) present in elf/aarch64.h and (b) properly displayed by readelf.)

Thank you for your reviewing.


Please find the attached updated patch which has an improved implementation of the AArch64-port readelf.


Thanks, Yufeng


Updated change log:


binutils/ChangeLog
2012-08-07  Ian Bolton  <ian.bolton@arm.com>
            Laurent Desnogues  <laurent.desnogues@arm.com>
            Jim MacArthur  <jim.macarthur@arm.com>
            Marcus Shawcroft  <marcus.shawcroft@arm.com>
            Nigel Stephens  <nigel.stephens@arm.com>
            Ramana Radhakrishnan  <ramana.radhakrishnan@arm.com>
            Richard Earnshaw  <rearnsha@arm.com>
            Sofiane Naci  <sofiane.naci@arm.com>
            Tejas Belagod  <tejas.belagod@arm.com>
            Yufeng Zhang  <yufeng.zhang@arm.com>

* readelf.c (guess_is_rela): Handle EM_AARCH64.
(get_machine_name): Likewise.
(get_aarch64_segment_type): New function.
(get_segment_type): Handle EM_AARCH64 by calling the new function.
(get_aarch64_section_type_name): New function.
(get_section_type_name): Handle EM_AARCH64 by calling the new function.
(is_32bit_abs_reloc): Handle EM_AARCH64.
(is_32bit_pcrel_reloc): Likewise.
(is_64bit_abs_reloc): Likewise.
(is_64bit_pcrel_reloc): Likewise.
(is_none_reloc): Likewise.


binutils/testsuite/ChangeLog
2012-08-07  Ian Bolton  <ian.bolton@arm.com>
            Laurent Desnogues  <laurent.desnogues@arm.com>
            Jim MacArthur  <jim.macarthur@arm.com>
            Marcus Shawcroft  <marcus.shawcroft@arm.com>
            Nigel Stephens  <nigel.stephens@arm.com>
            Ramana Radhakrishnan  <ramana.radhakrishnan@arm.com>
            Richard Earnshaw  <rearnsha@arm.com>
            Sofiane Naci  <sofiane.naci@arm.com>
            Tejas Belagod  <tejas.belagod@arm.com>
            Yufeng Zhang  <yufeng.zhang@arm.com>

* objdump.exp: Add AArch64.
diff --git a/binutils/readelf.c b/binutils/readelf.c
index e6f2be6..5423c7f 100644
--- a/binutils/readelf.c
+++ b/binutils/readelf.c
@@ -91,6 +91,7 @@
 
 #define RELOC_MACROS_GEN_FUNC
 
+#include "elf/aarch64.h"
 #include "elf/alpha.h"
 #include "elf/arc.h"
 #include "elf/arm.h"
@@ -551,6 +552,7 @@ guess_is_rela (unsigned int e_machine)
       /* Targets that use RELA relocations.  */
     case EM_68K:
     case EM_860:
+    case EM_AARCH64:
     case EM_ADAPTEVA_EPIPHANY:
     case EM_ALPHA:
     case EM_ALTERA_NIOS2:
@@ -983,6 +985,10 @@ dump_relocations (FILE * file,
 	  rtype = NULL;
 	  break;
 
+	case EM_AARCH64:
+	  rtype = elf_aarch64_reloc_type (type);
+	  break;
+
 	case EM_M32R:
 	case EM_CYGNUS_M32R:
 	  rtype = elf_m32r_reloc_type (type);
@@ -1830,6 +1836,7 @@ get_machine_name (unsigned e_machine)
   switch (e_machine)
     {
     case EM_NONE:		return _("None");
+    case EM_AARCH64:		return "AArch64";
     case EM_M32:		return "WE32100";
     case EM_SPARC:		return "Sparc";
     case EM_SPU:		return "SPU";
@@ -2695,6 +2702,20 @@ get_osabi_name (unsigned int osabi)
 }
 
 static const char *
+get_aarch64_segment_type (unsigned long type)
+{
+  switch (type)
+    {
+    case PT_AARCH64_ARCHEXT:
+      return "AARCH64_ARCHEXT";
+    default:
+      break;
+    }
+
+  return NULL;
+}
+
+static const char *
 get_arm_segment_type (unsigned long type)
 {
   switch (type)
@@ -2816,6 +2837,9 @@ get_segment_type (unsigned long p_type)
 
 	  switch (elf_header.e_machine)
 	    {
+	    case EM_AARCH64:
+	      result = get_aarch64_segment_type (p_type);
+	      break;
 	    case EM_ARM:
 	      result = get_arm_segment_type (p_type);
 	      break;
@@ -2977,6 +3001,19 @@ get_x86_64_section_type_name (unsigned int sh_type)
 }
 
 static const char *
+get_aarch64_section_type_name (unsigned int sh_type)
+{
+  switch (sh_type)
+    {
+    case SHT_AARCH64_ATTRIBUTES:
+      return "AARCH64_ATTRIBUTES";
+    default:
+      break;
+    }
+  return NULL;
+}
+
+static const char *
 get_arm_section_type_name (unsigned int sh_type)
 {
   switch (sh_type)
@@ -3075,6 +3112,9 @@ get_section_type_name (unsigned int sh_type)
 	    case EM_K1OM:
 	      result = get_x86_64_section_type_name (sh_type);
 	      break;
+	    case EM_AARCH64:
+	      result = get_aarch64_section_type_name (sh_type);
+	      break;
 	    case EM_ARM:
 	      result = get_arm_section_type_name (sh_type);
 	      break;
@@ -9770,6 +9810,8 @@ is_32bit_abs_reloc (unsigned int reloc_type)
       return reloc_type == 1; /* R_860_32.  */
     case EM_960:
       return reloc_type == 2; /* R_960_32.  */
+    case EM_AARCH64:
+      return reloc_type == 258; /* R_AARCH64_ABS32 */
     case EM_ALPHA:
       return reloc_type == 1; /* R_ALPHA_REFLONG.  */
     case EM_ARC:
@@ -9924,6 +9966,8 @@ is_32bit_pcrel_reloc (unsigned int reloc_type)
       return reloc_type == 2;  /* R_386_PC32.  */
     case EM_68K:
       return reloc_type == 4;  /* R_68K_PC32.  */
+    case EM_AARCH64:
+      return reloc_type == 261; /* R_AARCH64_PREL32 */
     case EM_ADAPTEVA_EPIPHANY:
       return reloc_type == 6;
     case EM_ALPHA:
@@ -9978,6 +10022,8 @@ is_64bit_abs_reloc (unsigned int reloc_type)
 {
   switch (elf_header.e_machine)
     {
+    case EM_AARCH64:
+      return reloc_type == 257;	/* R_AARCH64_ABS64.  */
     case EM_ALPHA:
       return reloc_type == 2; /* R_ALPHA_REFQUAD.  */
     case EM_IA_64:
@@ -10014,6 +10060,8 @@ is_64bit_pcrel_reloc (unsigned int reloc_type)
 {
   switch (elf_header.e_machine)
     {
+    case EM_AARCH64:
+      return reloc_type == 260;	/* R_AARCH64_PREL64.  */
     case EM_ALPHA:
       return reloc_type == 11; /* R_ALPHA_SREL64.  */
     case EM_IA_64:
@@ -10143,6 +10191,8 @@ is_none_reloc (unsigned int reloc_type)
     case EM_XC16X:
     case EM_C166:    /* R_XC16X_NONE.  */
       return reloc_type == 0;
+    case EM_AARCH64:
+      return reloc_type == 0 || reloc_type == 256;
     case EM_XTENSA_OLD:
     case EM_XTENSA:
       return (reloc_type == 0      /* R_XTENSA_NONE.  */
diff --git a/binutils/testsuite/binutils-all/objdump.exp b/binutils/testsuite/binutils-all/objdump.exp
index 267bcbd..14d1860 100644
--- a/binutils/testsuite/binutils-all/objdump.exp
+++ b/binutils/testsuite/binutils-all/objdump.exp
@@ -36,7 +36,7 @@ send_user "Version [binutil_version $OBJDUMP]"
 set got [binutils_run $OBJDUMP "$OBJDUMPFLAGS -i"]
 
 set cpus_expected [list]
-lappend cpus_expected alpha arc arm cris
+lappend cpus_expected aarch64 alpha arc arm cris
 lappend cpus_expected d10v d30v fr30 fr500 fr550 h8 hppa i386 i860 i960 ip2022
 lappend cpus_expected m16c m32c m32r m68hc11 m68hc12 m68k m88k MCore MicroBlaze
 lappend cpus_expected mips mn10200 mn10300 ms1 msp ns32k pj powerpc pyramid

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