binutils-gdb/include/elf/nds32.h
Kuan-Lin Chen 35c081572f 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.
2013-12-13 11:52:32 +00:00

283 lines
11 KiB
C

/* NDS32 ELF support for BFD.
Copyright (C) 2012-2013 Free Software Foundation, Inc.
Contributed by Andes Technology Corporation.
This file is part of BFD, the Binary File Descriptor library.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
02110-1301, USA. */
#ifndef _ELF_NDS32_H
#define _ELF_NDS32_H
#include "elf/reloc-macros.h"
/* Relocations. */
START_RELOC_NUMBERS (elf_nds32_reloc_type)
RELOC_NUMBER (R_NDS32_NONE, 0)
/* REL relocations. */
RELOC_NUMBER (R_NDS32_16, 1)
RELOC_NUMBER (R_NDS32_32, 2)
RELOC_NUMBER (R_NDS32_20, 3)
RELOC_NUMBER (R_NDS32_9_PCREL, 4)
RELOC_NUMBER (R_NDS32_15_PCREL, 5)
RELOC_NUMBER (R_NDS32_17_PCREL, 6)
RELOC_NUMBER (R_NDS32_25_PCREL, 7)
RELOC_NUMBER (R_NDS32_HI20, 8)
RELOC_NUMBER (R_NDS32_LO12S3, 9)
RELOC_NUMBER (R_NDS32_LO12S2, 10)
RELOC_NUMBER (R_NDS32_LO12S1, 11)
RELOC_NUMBER (R_NDS32_LO12S0, 12)
RELOC_NUMBER (R_NDS32_SDA15S3, 13)
RELOC_NUMBER (R_NDS32_SDA15S2, 14)
RELOC_NUMBER (R_NDS32_SDA15S1, 15)
RELOC_NUMBER (R_NDS32_SDA15S0, 16)
RELOC_NUMBER (R_NDS32_GNU_VTINHERIT, 17)
RELOC_NUMBER (R_NDS32_GNU_VTENTRY, 18)
/* RELA relocations. */
RELOC_NUMBER (R_NDS32_16_RELA, 19)
RELOC_NUMBER (R_NDS32_32_RELA, 20)
RELOC_NUMBER (R_NDS32_20_RELA, 21)
RELOC_NUMBER (R_NDS32_9_PCREL_RELA, 22)
RELOC_NUMBER (R_NDS32_15_PCREL_RELA, 23)
RELOC_NUMBER (R_NDS32_17_PCREL_RELA, 24)
RELOC_NUMBER (R_NDS32_25_PCREL_RELA, 25)
RELOC_NUMBER (R_NDS32_HI20_RELA, 26)
RELOC_NUMBER (R_NDS32_LO12S3_RELA, 27)
RELOC_NUMBER (R_NDS32_LO12S2_RELA, 28)
RELOC_NUMBER (R_NDS32_LO12S1_RELA, 29)
RELOC_NUMBER (R_NDS32_LO12S0_RELA, 30)
RELOC_NUMBER (R_NDS32_SDA15S3_RELA, 31)
RELOC_NUMBER (R_NDS32_SDA15S2_RELA, 32)
RELOC_NUMBER (R_NDS32_SDA15S1_RELA, 33)
RELOC_NUMBER (R_NDS32_SDA15S0_RELA, 34)
RELOC_NUMBER (R_NDS32_RELA_GNU_VTINHERIT, 35)
RELOC_NUMBER (R_NDS32_RELA_GNU_VTENTRY, 36)
RELOC_NUMBER (R_NDS32_GOT20, 37)
RELOC_NUMBER (R_NDS32_25_PLTREL, 38)
RELOC_NUMBER (R_NDS32_COPY, 39)
RELOC_NUMBER (R_NDS32_GLOB_DAT, 40)
RELOC_NUMBER (R_NDS32_JMP_SLOT, 41)
RELOC_NUMBER (R_NDS32_RELATIVE, 42)
RELOC_NUMBER (R_NDS32_GOTOFF, 43)
RELOC_NUMBER (R_NDS32_GOTPC20, 44)
RELOC_NUMBER (R_NDS32_GOT_HI20, 45)
RELOC_NUMBER (R_NDS32_GOT_LO12, 46)
RELOC_NUMBER (R_NDS32_GOTPC_HI20, 47)
RELOC_NUMBER (R_NDS32_GOTPC_LO12, 48)
RELOC_NUMBER (R_NDS32_GOTOFF_HI20, 49)
RELOC_NUMBER (R_NDS32_GOTOFF_LO12, 50)
RELOC_NUMBER (R_NDS32_INSN16, 51)
RELOC_NUMBER (R_NDS32_LABEL, 52)
RELOC_NUMBER (R_NDS32_LONGCALL1, 53)
RELOC_NUMBER (R_NDS32_LONGCALL2, 54)
RELOC_NUMBER (R_NDS32_LONGCALL3, 55)
RELOC_NUMBER (R_NDS32_LONGJUMP1, 56)
RELOC_NUMBER (R_NDS32_LONGJUMP2, 57)
RELOC_NUMBER (R_NDS32_LONGJUMP3, 58)
RELOC_NUMBER (R_NDS32_LOADSTORE, 59)
RELOC_NUMBER (R_NDS32_9_FIXED_RELA, 60)
RELOC_NUMBER (R_NDS32_15_FIXED_RELA, 61)
RELOC_NUMBER (R_NDS32_17_FIXED_RELA, 62)
RELOC_NUMBER (R_NDS32_25_FIXED_RELA, 63)
RELOC_NUMBER (R_NDS32_PLTREL_HI20, 64)
RELOC_NUMBER (R_NDS32_PLTREL_LO12, 65)
RELOC_NUMBER (R_NDS32_PLT_GOTREL_HI20, 66)
RELOC_NUMBER (R_NDS32_PLT_GOTREL_LO12, 67)
RELOC_NUMBER (R_NDS32_SDA12S2_DP_RELA, 68)
RELOC_NUMBER (R_NDS32_SDA12S2_SP_RELA, 69)
RELOC_NUMBER (R_NDS32_LO12S2_DP_RELA, 70)
RELOC_NUMBER (R_NDS32_LO12S2_SP_RELA, 71)
RELOC_NUMBER (R_NDS32_LO12S0_ORI_RELA, 72)
RELOC_NUMBER (R_NDS32_SDA16S3_RELA, 73)
RELOC_NUMBER (R_NDS32_SDA17S2_RELA, 74)
RELOC_NUMBER (R_NDS32_SDA18S1_RELA, 75)
RELOC_NUMBER (R_NDS32_SDA19S0_RELA, 76)
RELOC_NUMBER (R_NDS32_DWARF2_OP1_RELA, 77)
RELOC_NUMBER (R_NDS32_DWARF2_OP2_RELA, 78)
RELOC_NUMBER (R_NDS32_DWARF2_LEB_RELA, 79)
RELOC_NUMBER (R_NDS32_UPDATE_TA_RELA, 80) /* This is obsoleted. */
RELOC_NUMBER (R_NDS32_9_PLTREL, 81)
RELOC_NUMBER (R_NDS32_PLT_GOTREL_LO20, 82)
RELOC_NUMBER (R_NDS32_PLT_GOTREL_LO15, 83)
RELOC_NUMBER (R_NDS32_PLT_GOTREL_LO19, 84)
RELOC_NUMBER (R_NDS32_GOT_LO15, 85)
RELOC_NUMBER (R_NDS32_GOT_LO19, 86)
RELOC_NUMBER (R_NDS32_GOTOFF_LO15, 87)
RELOC_NUMBER (R_NDS32_GOTOFF_LO19, 88)
RELOC_NUMBER (R_NDS32_GOT15S2_RELA, 89)
RELOC_NUMBER (R_NDS32_GOT17S2_RELA, 90)
RELOC_NUMBER (R_NDS32_5_RELA, 91)
RELOC_NUMBER (R_NDS32_10_UPCREL_RELA, 92)
RELOC_NUMBER (R_NDS32_SDA_FP7U2_RELA, 93)
RELOC_NUMBER (R_NDS32_WORD_9_PCREL_RELA, 94)
RELOC_NUMBER (R_NDS32_25_ABS_RELA, 95)
RELOC_NUMBER (R_NDS32_17IFC_PCREL_RELA, 96)
RELOC_NUMBER (R_NDS32_10IFCU_PCREL_RELA, 97)
RELOC_NUMBER (R_NDS32_RELAX_ENTRY, 192)
RELOC_NUMBER (R_NDS32_GOT_SUFF, 193)
RELOC_NUMBER (R_NDS32_GOTOFF_SUFF, 194)
RELOC_NUMBER (R_NDS32_PLT_GOT_SUFF, 195)
RELOC_NUMBER (R_NDS32_MULCALL_SUFF, 196)
RELOC_NUMBER (R_NDS32_PTR, 197)
RELOC_NUMBER (R_NDS32_PTR_COUNT, 198)
RELOC_NUMBER (R_NDS32_PTR_RESOLVED, 199)
RELOC_NUMBER (R_NDS32_PLTBLOCK, 200)
RELOC_NUMBER (R_NDS32_RELAX_REGION_BEGIN, 201)
RELOC_NUMBER (R_NDS32_RELAX_REGION_END, 202)
RELOC_NUMBER (R_NDS32_MINUEND, 203)
RELOC_NUMBER (R_NDS32_SUBTRAHEND, 204)
RELOC_NUMBER (R_NDS32_DIFF8, 205)
RELOC_NUMBER (R_NDS32_DIFF16, 206)
RELOC_NUMBER (R_NDS32_DIFF32, 207)
RELOC_NUMBER (R_NDS32_DIFF_ULEB128, 208)
RELOC_NUMBER (R_NDS32_DATA, 209)
RELOC_NUMBER (R_NDS32_TRAN, 210)
RELOC_NUMBER (R_NDS32_FPBASE, 211)
END_RELOC_NUMBERS (R_NDS32_max)
/* Processor specific section indices. These sections do not actually
exist. Symbols with a st_shndx field corresponding to one of these
values have a special meaning. */
/* Processor specific flags for the ELF header e_flags field.
31 28 27 8 7 4 3 0
---------------------------------------------
| ARCH | CONFUGURAION FIELD | ABI | ELF_VER |
--------------------------------------------- */
/* Architechure definition. */
/* 4-bit (b31-b28) nds32 architecture field.
We can have up to 15 architectures; 0000 is for unknown. */
#define EF_NDS_ARCH 0xF0000000
#define EF_NDS_ARCH_SHIFT 28
/* There could be more architectures. For now, only n1 and n1h. */
#define E_NDS_ARCH_STAR_RESERVED 0x00000000
#define E_NDS_ARCH_STAR_V1_0 0x10000000
#define E_NDS_ARCH_STAR_V2_0 0x20000000
#define E_NDS_ARCH_STAR_V3_0 0x30000000
#define E_NDS_ARCH_STAR_V3_M 0x40000000
#define E_NDS_ARCH_STAR_V0_9 0x90000000 /* Obsoleted. */
/* n1 code. */
#define E_N1_ARCH E_NDS_ARCH_STAR_V0_9
/* n1h code. */
#define E_N1H_ARCH E_NDS_ARCH_STAR_V1_0
/* Configuration field definitioans. */
#define EF_NDS_INST 0x0FFFFF00
/* E_NDS_ARCH_STAR_V1_0 configuration fields.
E_NDS_ARCH_STAR_V2_0 configuration fields.
These are discarded in v2.
* E_NDS32_HAS_MFUSR_PC_INST 0x00000100
* E_NDS32_HAS_DIV_INST 0x00002000
* E_NDS32_HAS_NO_MAC_INST 0x00100000
These are added in v2.
* E_NDS32_HAS_DIV_DX_INST 0x00002000
* E_NDS32_HAS_MAC_DX_INST 0x00100000 */
/* MFUSR rt, PC and correct ISYNC, MSYNC instructions.
Old N1213HC has no such instructions. */
#define E_NDS32_HAS_MFUSR_PC_INST 0x00000100 /* Reclaimed. */
#define E_NDS32_HAS_EX9_INST 0x00000100 /* v3, ELF 1.4. */
/* C/C++ performance extension instructions. */
#define E_NDS32_HAS_EXT_INST 0x00000200
/* Performance extension set II instructions. */
#define E_NDS32_HAS_EXT2_INST 0x00000400
/* Single precision Floating point processor instructions. */
#define E_NDS32_HAS_FPU_INST 0x00000800
/* Audio instructions with 32-bit audio dx.lo register. */
#define E_NDS32_HAS_AUDIO_INST 0x00001000
/* DIV instructions. */
#define E_NDS32_HAS_DIV_INST 0x00002000 /* Reclaimed. */
/* DIV instructions using d0/d1. */
#define E_NDS32_HAS_DIV_DX_INST 0x00002000 /* v2. */
/* 16-bit instructions. */
#define E_NDS32_HAS_16BIT_INST 0x00004000 /* Reclaimed. */
#define E_NDS32_HAS_IFC_INST 0x00004000 /* v3, ELF 1.4. */
/* String operation instructions. */
#define E_NDS32_HAS_STRING_INST 0x00008000
/* Reduced register file. */
#define E_NDS32_HAS_REDUCED_REGS 0x00010000
/* Video instructions. */
#define E_NDS32_HAS_VIDEO_INST 0x00020000 /* Reclaimed. */
#define E_NDS32_HAS_SATURATION_INST 0x00020000 /* v3, ELF 1.4. */
/* Encription instructions. */
#define E_NDS32_HAS_ENCRIPT_INST 0x00040000
/* Doulbe Precision Floating point processor instructions. */
#define E_NDS32_HAS_FPU_DP_INST 0x00080000
/* No MAC instruction used. */
#define E_NDS32_HAS_NO_MAC_INST 0x00100000 /* Reclaimed when V2/V3. */
/* MAC instruction using d0/d1. */
#define E_NDS32_HAS_MAC_DX_INST 0x00100000 /* v2. */
/* L2 cache instruction. */
#define E_NDS32_HAS_L2C_INST 0x00200000
/* FPU registers configuration when FPU SP/DP presents; 0x00c00000. */
#define E_NDS32_FPU_REG_CONF_SHIFT 22
#define E_NDS32_FPU_REG_CONF (0x3 << E_NDS32_FPU_REG_CONF_SHIFT)
#define E_NDS32_FPU_REG_8SP_4DP 0x0
#define E_NDS32_FPU_REG_16SP_8DP 0x1
#define E_NDS32_FPU_REG_32SP_16DP 0x2
#define E_NDS32_FPU_REG_32SP_32DP 0x3
/* FPU MAC instruction used. */
#define E_NDS32_HAS_FPU_MAC_INST 0x01000000
/* <<<Empty Check>>>. */
#define E_NDS32_NULL 0x02000000
/* PIC enabled. */
#define E_NDS32_HAS_PIC 0x04000000
/* Use custom section. */
#define E_NDS32_HAS_CUSTOM_SEC 0x08000000
/* 4-bit for ABI signature, allow up to 16 ABIs
0: for OLD ABI V0, phase out
1: for V1 , starting with V0 toolchain
2: for V2
3: for V2FP (fs0, fs1 as function parameter)
4: for AABI */
/* Only old N1213HC use V0.
New ABI is used due to return register is changed to r0 from r5. */
#define EF_NDS_ABI 0x000000F0
#define EF_NDS_ABI_SHIFT 4
#define E_NDS_ABI_V0 0x00000000
#define E_NDS_ABI_V1 0x00000010
#define E_NDS_ABI_V2 0x00000020
#define E_NDS_ABI_V2FP 0x00000030
#define E_NDS_ABI_AABI 0x00000040
#define E_NDS_ABI_V2FP_PLUS 0x00000050
/* This flag signifies the version of Andes ELF.
Some more information may exist somewhere which is TBD. */
#define EF_NDS32_ELF_VERSION 0x0000000F
#define EF_NDS32_ELF_VERSION_SHIFT 0
/* Andes ELF Version 1.3 and before. */
#define E_NDS32_ELF_VER_1_2 0x0
/* Andes ELF Version 1.31. */
#define E_NDS32_ELF_VER_1_3 0x1
/* Andes ELF Version 1.4. Change the way we fix .debug_* and .gcc_except_table.
Change three bit for EX9, IFC and SAT. */
#define E_NDS32_ELF_VER_1_4 0x2
#endif