Add support for Andes NDS32:

BFD:
	* Makefile.am (BFD32_BACKENDS, BFD32_BACKENDS_CFILES): Add nds32
	files.
	* Makefile.in: Regenerate.
	* archures.c (bfd_nds32_arch): Add nds32 target.
	* bfd-in2.h: Regenerate.
	* config.bfd (nds32*le-*-linux): Add bfd_elf32_nds32lelin_vec
	and bfd_elf32_nds32belin_vec.
	(nds32*be-*-linux*): Likewise.
	(nds32*le-*-*): Add bfd_elf32_nds32le_vec and bfd_elf32_nds32be_vec.
	(nds32*be-*-*): Likewise.
	* configure.in (bfd_elf32_nds32be_vec): Add elf32-nds32.lo.
	(bfd_elf32_nds32le_vec): Likewise.
	(bfd_elf32_nds32belin_vec): Likewise.
	(bfd_elf32_nds32lelin_vec): Likewise.
	* configure: Regenerate.
	* cpu-nds32.c: New file for nds32.
	* elf-bfd.h: Add NDS32_ELF_DATA.
	* elf32-nds32.c: New file for nds32.
	* elf32-nds32.h: New file for nds32.
	* libbfd.h: Regenerate.
	* reloc.c: Add relocations for nds32.
	* targets.c (bfd_elf32_nds32be_vec): New declaration for nds32.
	(bfd_elf32_nds32le_vec): Likewise.
	(bfd_elf32_nds32belin_vec): Likewise.
	(bfd_elf32_nds32lelin_vec): Likewise.

BINUTILS:
	* 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.
  TESTSUITE:
	* binutils-all/objdump.exp: Add NDS32 cpu.
	* binutils-all/readelf.r: Skip extra reloc created by NDS32.

GAS:
	* Makefile.am (TARGET_CPU_CFILES): Add config/tc-nds32.c.
	(TARGET_CPU_HFILES): Add config/tc-nds32.h.
	* Makefile.in: Regenerate.
	* configure.in (nds32): Add nds32 target extension config support.
	* configure.tgt : Add case for nds32-*-elf* and nds32-*-linux*.
	* configure: Regenerate.
	* config/tc-nds32.c: New file for nds32.
	* config/tc-nds32.h: New file for nds32.
	* doc/Makefile.am (CPU_DOCS): Add c-nds32.texi.
	* doc/Makefile.in: Regenerate.
	* doc/as.texinfo: Add nds32 options.
	* doc/all.texi: Set NDS32.
	* doc/c-nds32.texi: New file dor nds32 document.
	* NEWS: Announce Andes nds32 support.
  TESTSUITE:
	* gas/all/gas.exp: Add expected failures for NDS32.
	* gas/elf/elf.exp: Likewise.
	* gas/lns/lns.exp: Use alternate test.
	* gas/macros/irp.d: Skip for NDS32.
	* gas/macros/macros.exp: Skip some tests for the NDS32.
	* gas/macros/rept.d: Skip for NDS32.
	* gas/macros/test3.d: Skip for NDS32.
	* gas/nds32: New directory.
	* gas/nds32/alu-1.s: New test.
	* gas/nds32/alu-1.d: Likewise.
	* gas/nds32/alu-2.s: Likewise.
	* gas/nds32/alu-2.d: Likewise.
	* gas/nds32/br-1.d: Likewise.
	* gas/nds32/br-1.s: Likewise.
	* gas/nds32/br-2.d: Likewise.
	* gas/nds32/br-2.s: Likewise.
	* gas/nds32/ji-jr.d: Likewise.
	* gas/nds32/ji-jr.s: Likewise.
	* gas/nds32/ls.d: Likewise.
	* gas/nds32/ls.s: Likewise.
	* gas/nds32/lsi.d: Likewise.
	* gas/nds32/lsi.s: Likewise.
	* gas/nds32/to-16bit-v1.d: Likewise.
	* gas/nds32/to-16bit-v1.s: Likewise.
	* gas/nds32/to-16bit-v2.d: Likewise.
	* gas/nds32/to-16bit-v2.s: Likewise.
	* gas/nds32/to-16bit-v3.d: Likewise.
	* gas/nds32/to-16bit-v3.s: Likewise.
	* gas/nds32/nds32.exp: New test driver.

LD:
	* Makefile.am (ALL_EMULATION_SOURCES): Add nds32 target.
	* Makefile.in: Regenerate.
	* configure.tgt: Add case for nds32*le-*-elf*, nds32*be-*-elf*,
	nds32*le-*-linux-gnu*, and nds32*be-*-linux-gnu*.
	* emulparams/nds32belf.sh: New file for nds32.
	* emulparams/nds32belf_linux.sh: Likewise.
	* emulparams/nds32belf16m.sh: Likewise.
	* emulparams/nds32elf.sh: Likewise.
	* emulparams/nds32elf_linux.sh: Likewise.
	* emulparams/nds32elf16m.sh: Likewise.
	* emultempl/nds32elf.em: Likewise.
	* scripttempl/nds32elf.sc}: Likewise.
	* gen-doc.texi: Set NDS32.
	* ld.texinfo: Set NDS32.
	* NEWS: Announce Andes nds32 support.
  TESTSUITE:
	* lib/ld-lib.exp: Add NDS32 to list of targets that do not support
	shared library generation.
	* ld-nds32: New directory.
	* ld-nds32/branch.d: New test.
	* ld-nds32/branch.ld: New test.
	* ld-nds32/branch.s: New test.
	* ld-nds32/diff.d: New test.
	* ld-nds32/diff.ld: New test.
	* ld-nds32/diff.s: New test.
	* ld-nds32/gp.d: New test.
	* ld-nds32/gp.ld: New test.
	* ld-nds32/gp.s: New test.
	* ld-nds32/imm.d: New test.
	* ld-nds32/imm.ld: New test.
	* ld-nds32/imm.s: New test.
	* ld-nds32/imm_symbol.s: New test.
	* ld-nds32/relax_jmp.d: New test.
	* ld-nds32/relax_jmp.ld: New test.
	* ld-nds32/relax_jmp.s: New test.
	* ld-nds32/relax_load_store.d: New test.
	* ld-nds32/relax_load_store.ld: New test.
	* ld-nds32/relax_load_store.s: New test.
	* ld-nds32/nds32.exp: New file.

OPCODES:
	* Makefile.am (TARGET_LIBOPCODES_CFILES): Add nds32-asm.c
	and nds32-dis.c.
	* Makefile.in: Regenerate.
	* configure.in: Add case for bfd_nds32_arch.
	* configure: Regenerate.
	* disassemble.c (ARCH_nds32): Define.
	* nds32-asm.c: New file for nds32.
	* nds32-asm.h: New file for nds32.
	* nds32-dis.c: New file for nds32.
	* nds32-opc.h: New file for nds32.

INCLUDE:
	* dis-asm.h (print_insn_nds32): Add nds32 target.
	* elf/nds32.h: New file for nds32.
	* opcode/nds32.h: New file for nds32.
This commit is contained in:
Kuan-Lin Chen 2013-12-13 11:52:32 +00:00 committed by Nick Clifton
parent 8a48ac9579
commit 35c081572f
119 changed files with 28734 additions and 18 deletions

View file

@ -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. */
@ -12981,6 +13202,40 @@ process_mips_specific (FILE * file)
return 1;
}
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)
{
@ -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;