aboutsummaryrefslogtreecommitdiff
path: root/binutils
diff options
context:
space:
mode:
Diffstat (limited to 'binutils')
-rw-r--r--binutils/ChangeLog15
-rw-r--r--binutils/MAINTAINERS2
-rw-r--r--binutils/NEWS2
-rw-r--r--binutils/readelf.c258
-rw-r--r--binutils/testsuite/ChangeLog6
-rw-r--r--binutils/testsuite/binutils-all/objdump.exp4
-rw-r--r--binutils/testsuite/binutils-all/readelf.r4
-rw-r--r--binutils/testsuite/binutils-all/readelf.s2
8 files changed, 289 insertions, 4 deletions
diff --git a/binutils/ChangeLog b/binutils/ChangeLog
index 9a3d22a..49f1b74 100644
--- a/binutils/ChangeLog
+++ b/binutils/ChangeLog
@@ -1,3 +1,18 @@
+2013-12-13 Kuan-Lin Chen <kuanlinchentw@gmail.com>
+ Wei-Cheng Wang <cole945@gmail.com>
+
+ * readelf.c: Include elf/nds32.h
+ (guess_is_rela): Add case for EM_NDS32.
+ (dump_relocations): Add case for EM_NDS32.
+ (decode_NDS32_machine_flags): New.
+ (get_machine_flags): Add case for EM_NDS32.
+ (is_32bit_abs_reloc): Likewise.
+ (is_16bit_abs_reloc): Likewise.
+ (process_nds32_specific): New.
+ (process_arch_specific): Add case for EM_NDS32.
+ * NEWS: Announce Andes nds32 support.
+ * MAINTAINERS: Add nds32 maintainers.
+
2013-12-10 Roland McGrath <mcgrathr@google.com>
* Makefile.am (install-exec-local): Prefix libtool invocation with
diff --git a/binutils/MAINTAINERS b/binutils/MAINTAINERS
index f3ecf09..cb6aa03 100644
--- a/binutils/MAINTAINERS
+++ b/binutils/MAINTAINERS
@@ -109,6 +109,8 @@ responsibility among the other maintainers.
MN10300 Alexandre Oliva <aoliva@redhat.com>
Moxie Anthony Green <green@moxielogic.com>
MSP430 Dmitry Diky <diwil@spec.ru>
+ NDS32 Kuan-Lin Chen <kuanlinchentw@gmail.com>
+ NDS32 Wei-Cheng Wang <cole945@gmail.com>
NetBSD support Matt Thomas <matt@netbsd.org>
Nios II Sandra Loosemore <sandra@codesourcery.com>
Nios II Andrew Jenner <andrew@codesourcery.com>
diff --git a/binutils/NEWS b/binutils/NEWS
index 26555b0..f1f0061 100644
--- a/binutils/NEWS
+++ b/binutils/NEWS
@@ -1,5 +1,7 @@
-*- text -*-
+* Add support for the Andes NDS32.
+
Changes in 2.24:
* Objcopy now supports wildcard characters in command line options that take
diff --git a/binutils/readelf.c b/binutils/readelf.c
index b9b06a1..7d228d6 100644
--- a/binutils/readelf.c
+++ b/binutils/readelf.c
@@ -131,6 +131,7 @@
#include "elf/moxie.h"
#include "elf/mt.h"
#include "elf/msp430.h"
+#include "elf/nds32.h"
#include "elf/nios2.h"
#include "elf/or32.h"
#include "elf/pj.h"
@@ -626,6 +627,7 @@ guess_is_rela (unsigned int e_machine)
case EM_MSP430:
case EM_MSP430_OLD:
case EM_MT:
+ case EM_NDS32:
case EM_NIOS32:
case EM_PPC64:
case EM_PPC:
@@ -1144,6 +1146,10 @@ dump_relocations (FILE * file,
rtype = elf_msp430_reloc_type (type);
break;
+ case EM_NDS32:
+ rtype = elf_nds32_reloc_type (type);
+ break;
+
case EM_PPC:
rtype = elf_ppc_reloc_type (type);
break;
@@ -2307,6 +2313,207 @@ decode_ARM_machine_flags (unsigned e_flags, char buf[])
strcat (buf,_(", <unknown>"));
}
+static void
+decode_NDS32_machine_flags (unsigned e_flags, char buf[], size_t size)
+{
+ unsigned abi;
+ unsigned arch;
+ unsigned config;
+ unsigned version;
+ int has_fpu = 0;
+ int r = 0;
+
+ static const char *ABI_STRINGS[] =
+ {
+ "ABI v0", /* use r5 as return register; only used in N1213HC */
+ "ABI v1", /* use r0 as return register */
+ "ABI v2", /* use r0 as return register and don't reserve 24 bytes for arguments */
+ "ABI v2fp", /* for FPU */
+ "AABI"
+ };
+ static const char *VER_STRINGS[] =
+ {
+ "Andes ELF V1.3 or older",
+ "Andes ELF V1.3.1",
+ "Andes ELF V1.4"
+ };
+ static const char *ARCH_STRINGS[] =
+ {
+ "",
+ "Andes Star v1.0",
+ "Andes Star v2.0",
+ "Andes Star v3.0",
+ "Andes Star v3.0m"
+ };
+
+ abi = EF_NDS_ABI & e_flags;
+ arch = EF_NDS_ARCH & e_flags;
+ config = EF_NDS_INST & e_flags;
+ version = EF_NDS32_ELF_VERSION & e_flags;
+
+ memset (buf, 0, size);
+
+ switch (abi)
+ {
+ case E_NDS_ABI_V0:
+ case E_NDS_ABI_V1:
+ case E_NDS_ABI_V2:
+ case E_NDS_ABI_V2FP:
+ case E_NDS_ABI_AABI:
+ /* In case there are holes in the array. */
+ r += snprintf (buf + r, size - r, ", %s", ABI_STRINGS[abi >> EF_NDS_ABI_SHIFT]);
+ break;
+
+ default:
+ r += snprintf (buf + r, size - r, ", <unrecognized ABI>");
+ break;
+ }
+
+ switch (version)
+ {
+ case E_NDS32_ELF_VER_1_2:
+ case E_NDS32_ELF_VER_1_3:
+ case E_NDS32_ELF_VER_1_4:
+ r += snprintf (buf + r, size - r, ", %s", VER_STRINGS[version >> EF_NDS32_ELF_VERSION_SHIFT]);
+ break;
+
+ default:
+ r += snprintf (buf + r, size - r, ", <unrecognized ELF version number>");
+ break;
+ }
+
+ if (E_NDS_ABI_V0 == abi)
+ {
+ /* OLD ABI; only used in N1213HC, has performance extension 1. */
+ r += snprintf (buf + r, size - r, ", Andes Star v1.0, N1213HC, MAC, PERF1");
+ if (arch == E_NDS_ARCH_STAR_V1_0)
+ r += snprintf (buf + r, size -r, ", 16b"); /* has 16-bit instructions */
+ return;
+ }
+
+ switch (arch)
+ {
+ case E_NDS_ARCH_STAR_V1_0:
+ case E_NDS_ARCH_STAR_V2_0:
+ case E_NDS_ARCH_STAR_V3_0:
+ case E_NDS_ARCH_STAR_V3_M:
+ r += snprintf (buf + r, size - r, ", %s", ARCH_STRINGS[arch >> EF_NDS_ARCH_SHIFT]);
+ break;
+
+ default:
+ r += snprintf (buf + r, size - r, ", <unrecognized architecture>");
+ /* ARCH version determines how the e_flags are interpreted.
+ If it is unknown, we cannot proceed. */
+ return;
+ }
+
+ /* Newer ABI; Now handle architecture specific flags. */
+ if (arch == E_NDS_ARCH_STAR_V1_0)
+ {
+ if (config & E_NDS32_HAS_MFUSR_PC_INST)
+ r += snprintf (buf + r, size -r, ", MFUSR_PC");
+
+ if (!(config & E_NDS32_HAS_NO_MAC_INST))
+ r += snprintf (buf + r, size -r, ", MAC");
+
+ if (config & E_NDS32_HAS_DIV_INST)
+ r += snprintf (buf + r, size -r, ", DIV");
+
+ if (config & E_NDS32_HAS_16BIT_INST)
+ r += snprintf (buf + r, size -r, ", 16b");
+ }
+ else
+ {
+ if (config & E_NDS32_HAS_MFUSR_PC_INST)
+ {
+ if (version <= E_NDS32_ELF_VER_1_3)
+ r += snprintf (buf + r, size -r, ", [B8]");
+ else
+ r += snprintf (buf + r, size -r, ", EX9");
+ }
+
+ if (config & E_NDS32_HAS_MAC_DX_INST)
+ r += snprintf (buf + r, size -r, ", MAC_DX");
+
+ if (config & E_NDS32_HAS_DIV_DX_INST)
+ r += snprintf (buf + r, size -r, ", DIV_DX");
+
+ if (config & E_NDS32_HAS_16BIT_INST)
+ {
+ if (version <= E_NDS32_ELF_VER_1_3)
+ r += snprintf (buf + r, size -r, ", 16b");
+ else
+ r += snprintf (buf + r, size -r, ", IFC");
+ }
+ }
+
+ if (config & E_NDS32_HAS_EXT_INST)
+ r += snprintf (buf + r, size -r, ", PERF1");
+
+ if (config & E_NDS32_HAS_EXT2_INST)
+ r += snprintf (buf + r, size -r, ", PERF2");
+
+ if (config & E_NDS32_HAS_FPU_INST)
+ {
+ has_fpu = 1;
+ r += snprintf (buf + r, size -r, ", FPU_SP");
+ }
+
+ if (config & E_NDS32_HAS_FPU_DP_INST)
+ {
+ has_fpu = 1;
+ r += snprintf (buf + r, size -r, ", FPU_DP");
+ }
+
+ if (config & E_NDS32_HAS_FPU_MAC_INST)
+ {
+ has_fpu = 1;
+ r += snprintf (buf + r, size -r, ", FPU_MAC");
+ }
+
+ if (has_fpu)
+ {
+ switch ((config & E_NDS32_FPU_REG_CONF) >> E_NDS32_FPU_REG_CONF_SHIFT)
+ {
+ case E_NDS32_FPU_REG_8SP_4DP:
+ r += snprintf (buf + r, size -r, ", FPU_REG:8/4");
+ break;
+ case E_NDS32_FPU_REG_16SP_8DP:
+ r += snprintf (buf + r, size -r, ", FPU_REG:16/8");
+ break;
+ case E_NDS32_FPU_REG_32SP_16DP:
+ r += snprintf (buf + r, size -r, ", FPU_REG:32/16");
+ break;
+ case E_NDS32_FPU_REG_32SP_32DP:
+ r += snprintf (buf + r, size -r, ", FPU_REG:32/32");
+ break;
+ }
+ }
+
+ if (config & E_NDS32_HAS_AUDIO_INST)
+ r += snprintf (buf + r, size -r, ", AUDIO");
+
+ if (config & E_NDS32_HAS_STRING_INST)
+ r += snprintf (buf + r, size -r, ", STR");
+
+ if (config & E_NDS32_HAS_REDUCED_REGS)
+ r += snprintf (buf + r, size -r, ", 16REG");
+
+ if (config & E_NDS32_HAS_VIDEO_INST)
+ {
+ if (version <= E_NDS32_ELF_VER_1_3)
+ r += snprintf (buf + r, size -r, ", VIDEO");
+ else
+ r += snprintf (buf + r, size -r, ", SATURATION");
+ }
+
+ if (config & E_NDS32_HAS_ENCRIPT_INST)
+ r += snprintf (buf + r, size -r, ", ENCRP");
+
+ if (config & E_NDS32_HAS_L2C_INST)
+ r += snprintf (buf + r, size -r, ", L2C");
+}
+
static char *
get_machine_flags (unsigned e_flags, unsigned e_machine)
{
@@ -2649,6 +2856,10 @@ get_machine_flags (unsigned e_flags, unsigned e_machine)
}
break;
+ case EM_NDS32:
+ decode_NDS32_machine_flags (e_flags, buf, sizeof buf);
+ break;
+
case EM_SH:
switch ((e_flags & EF_SH_MACH_MASK))
{
@@ -10261,6 +10472,8 @@ is_32bit_abs_reloc (unsigned int reloc_type)
return reloc_type == 1; /* R_MSP430_32 or R_MSP320_ABS32. */
case EM_MT:
return reloc_type == 2; /* R_MT_32. */
+ case EM_NDS32:
+ return reloc_type == 20; /* R_NDS32_RELA. */
case EM_ALTERA_NIOS2:
return reloc_type == 12; /* R_NIOS2_BFD_RELOC_32. */
case EM_NIOS32:
@@ -10514,6 +10727,8 @@ is_16bit_abs_reloc (unsigned int reloc_type)
return reloc_type == 2; /* R_MSP430_ABS16. */
case EM_MSP430_OLD:
return reloc_type == 5; /* R_MSP430_16_BYTE. */
+ case EM_NDS32:
+ return reloc_type == 19; /* R_NDS32_RELA. */
case EM_ALTERA_NIOS2:
return reloc_type == 13; /* R_NIOS2_BFD_RELOC_16. */
case EM_NIOS32:
@@ -10577,6 +10792,12 @@ is_none_reloc (unsigned int reloc_type)
return reloc_type == 0;
case EM_AARCH64:
return reloc_type == 0 || reloc_type == 256;
+ case EM_NDS32:
+ return (reloc_type == 0 /* R_XTENSA_NONE. */
+ || reloc_type == 204 /* R_NDS32_DIFF8. */
+ || reloc_type == 205 /* R_NDS32_DIFF16. */
+ || reloc_type == 206 /* R_NDS32_DIFF32. */
+ || reloc_type == 207 /* R_NDS32_ULEB128. */);
case EM_XTENSA_OLD:
case EM_XTENSA:
return (reloc_type == 0 /* R_XTENSA_NONE. */
@@ -12982,6 +13203,40 @@ process_mips_specific (FILE * file)
}
static int
+process_nds32_specific (FILE * file)
+{
+ Elf_Internal_Shdr *sect = NULL;
+
+ sect = find_section (".nds32_e_flags");
+ if (sect != NULL)
+ {
+ unsigned int *flag;
+
+ printf ("\nNDS32 elf flags section:\n");
+ flag = get_data (NULL, file, sect->sh_offset, 1,
+ sect->sh_size, _("NDS32 elf flags section"));
+
+ switch ((*flag) & 0x3)
+ {
+ case 0:
+ printf ("(VEC_SIZE):\tNo entry.\n");
+ break;
+ case 1:
+ printf ("(VEC_SIZE):\t4 bytes\n");
+ break;
+ case 2:
+ printf ("(VEC_SIZE):\t16 bytes\n");
+ break;
+ case 3:
+ printf ("(VEC_SIZE):\treserved\n");
+ break;
+ }
+ }
+
+ return TRUE;
+}
+
+static int
process_gnu_liblist (FILE * file)
{
Elf_Internal_Shdr * section;
@@ -13807,6 +14062,9 @@ process_arch_specific (FILE * file)
case EM_MIPS_RS3_LE:
return process_mips_specific (file);
break;
+ case EM_NDS32:
+ return process_nds32_specific (file);
+ break;
case EM_PPC:
return process_power_specific (file);
break;
diff --git a/binutils/testsuite/ChangeLog b/binutils/testsuite/ChangeLog
index 26cda41..1023526 100644
--- a/binutils/testsuite/ChangeLog
+++ b/binutils/testsuite/ChangeLog
@@ -1,3 +1,9 @@
+2013-12-13 Kuan-Lin Chen <kuanlinchentw@gmail.com>
+ Wei-Cheng Wang <cole945@gmail.com>
+
+ * binutils-all/objdump.exp: Add NDS32 cpu.
+ * binutils-all/readelf.r: Skip extra reloc created by NDS32.
+
2013-12-12 H.J. Lu <hongjiu.lu@intel.com>
PR binutils/16318
diff --git a/binutils/testsuite/binutils-all/objdump.exp b/binutils/testsuite/binutils-all/objdump.exp
index adb7a79..aa1ff2c 100644
--- a/binutils/testsuite/binutils-all/objdump.exp
+++ b/binutils/testsuite/binutils-all/objdump.exp
@@ -39,8 +39,8 @@ set cpus_expected [list]
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 MSP430 ns32k pj powerpc pyramid
-lappend cpus_expected romp rs6000 s390 sh sparc
+lappend cpus_expected mips mn10200 mn10300 ms1 msp MSP430 nds32 n1h_v3 ns32k
+lappend cpus_expected pj powerpc pyramid romp rs6000 s390 sh sparc
lappend cpus_expected tahoe tic54x tic80 tilegx tms320c30 tms320c4x tms320c54x
lappend cpus_expected v850 vax we32k x86-64 xscale xtensa z8k z8001 z8002
diff --git a/binutils/testsuite/binutils-all/readelf.r b/binutils/testsuite/binutils-all/readelf.r
index 689049f..065fccf 100644
--- a/binutils/testsuite/binutils-all/readelf.r
+++ b/binutils/testsuite/binutils-all/readelf.r
@@ -1,4 +1,6 @@
-Relocation section '.rel.*text' at offset 0x.* contains 1 entries:
+Relocation section '.rel.*text' at offset 0x.* contains . entries:
Offset Info Type Sym.Value Sym. Name.*
+# NDS32 targets puts R_NDS32_RELAX_ENT here
+#...
00000004 [0-9A-Fa-f]+ *R_.*00000000 external_symbol.*
diff --git a/binutils/testsuite/binutils-all/readelf.s b/binutils/testsuite/binutils-all/readelf.s
index 8361a7e..22fb5d1 100644
--- a/binutils/testsuite/binutils-all/readelf.s
+++ b/binutils/testsuite/binutils-all/readelf.s
@@ -6,7 +6,7 @@ Section Headers:
# On the normal MIPS systems, sections must be aligned to 16 byte
# boundaries. On IA64, text sections are aligned to 16 byte boundaries.
+\[ 1\] .text +PROGBITS +00000000 0000(34|40) 0000(08|10) 00 +AX +0 +0 +(.|..)
- +\[ 2\] .rel.+text +REL. +0+ 0+.* 00000. 0. +. +1 +4
+ +\[ 2\] .rel.+text +REL. +0+ 0+.* 0000.. 0. +. +1 +4
# MIPS targets put .rela.text here.
#...
+\[ .\] .data +PROGBITS +00000000 0000(3c|48|50) 0000(04|10) 00 +WA +0 +0 +(.|..)