aboutsummaryrefslogtreecommitdiff
path: root/gas/config
diff options
context:
space:
mode:
authorSandra Loosemore <sandra@codesourcery.com>2015-07-01 15:55:28 -0700
committerSandra Loosemore <sandra@codesourcery.com>2015-07-01 15:55:28 -0700
commit965b1d80832fde9ba17a8b5f11b578a8f9e10581 (patch)
tree050d75d12b3342269911e3db42256309a1adaac1 /gas/config
parentdfc87947b5ac6d6382c225449d4fdce411c7ee66 (diff)
downloadgdb-965b1d80832fde9ba17a8b5f11b578a8f9e10581.zip
gdb-965b1d80832fde9ba17a8b5f11b578a8f9e10581.tar.gz
gdb-965b1d80832fde9ba17a8b5f11b578a8f9e10581.tar.bz2
Add Nios II arch flags and compatibility tests
2015-07-01 Sandra Loosemore <sandra@codesourcery.com> Cesar Philippidis <cesar@codesourcery.com> bfd/ * archures.c (bfd_mach_nios2r1, bfd_mach_nios2r2): New. * bfd-in2.h: Regenerated. * cpu-nios2.c (nios2_compatible): New. (N): Use nios2_compatible instead of bfd_default_compatible. (NIOS2R1_NEXT, NIOS2R2_NEXT): Define. (arch_info_struct): New. (bfd_nios2_arch): Chain to NIOS2R1_NEXT. * elf32-nios2.c (is_nios2_elf): New. (nios2_elf32_merge_private_bfd_data): New. (nios2_elf32_object_p): New. (bfd_elf32_bfd_merge_private_bfd_data): Define. (elf_backend_object_p): Define. gas/ * config/tc-nios2.c: Adjust includes. (OPTION_MARCH): Define. (md_longopts): Add -march option. (nios2_architecture): New. (nios2_use_arch): New. (md_parse_option): Handle OPTION_MARCH. (md_show_usage): Document -march. (md_begin): Set arch in BFD. (nios2_elf_final_processing): New. * config/tc-nios2.h (elf_tc_final_processing): Define. (nios2_elf_final_processing): New. * doc/c-nios2.texi (-march): Add documentation. include/elf/ * nios2.h (EF_NIOS2_ARCH_R1, EF_NIOS2_ARCH_R2): Define. ld/testsuite/ * ld-nios2/mixed1a.d: New. * ld-nios2/mixed1a.s: New. * ld-nios2/mixed1b.d: New. * ld-nios2/mixed1b.s: New. * ld-nios2/nios2.exp: Build the new compatibility tests.
Diffstat (limited to 'gas/config')
-rw-r--r--gas/config/tc-nios2.c66
-rw-r--r--gas/config/tc-nios2.h3
2 files changed, 67 insertions, 2 deletions
diff --git a/gas/config/tc-nios2.c b/gas/config/tc-nios2.c
index 2fb26b8..549ca98 100644
--- a/gas/config/tc-nios2.c
+++ b/gas/config/tc-nios2.c
@@ -25,6 +25,7 @@
#include "elf/nios2.h"
#include "tc-nios2.h"
#include "bfd.h"
+#include "libbfd.h"
#include "dwarf2dbg.h"
#include "subsegs.h"
#include "safe-ctype.h"
@@ -80,7 +81,9 @@ struct option md_longopts[] = {
#define OPTION_EB (OPTION_MD_BASE + 3)
{"EB", no_argument, NULL, OPTION_EB},
#define OPTION_EL (OPTION_MD_BASE + 4)
- {"EL", no_argument, NULL, OPTION_EL}
+ {"EL", no_argument, NULL, OPTION_EL},
+#define OPTION_MARCH (OPTION_MD_BASE + 5)
+ {"march", required_argument, NULL, OPTION_MARCH}
};
size_t md_longopts_size = sizeof (md_longopts);
@@ -212,6 +215,9 @@ static symbolS *nios2_last_label;
symbolS *GOT_symbol;
#endif
+/* The processor architecture value, EF_NIOS2_ARCH_R1 by default. */
+static int nios2_architecture = EF_NIOS2_ARCH_R1;
+
/** Utility routines. */
/* Function md_chars_to_number takes the sequence of
@@ -2209,6 +2215,34 @@ output_movia (nios2_insn_infoS *insn)
/** External interfaces. */
+/* Update the selected architecture based on ARCH, giving an error if
+ ARCH is an invalid value. */
+
+static void
+nios2_use_arch (const char *arch)
+{
+ if (strcmp (arch, "nios2") == 0 || strcmp (arch, "r1") == 0)
+ {
+ nios2_architecture |= EF_NIOS2_ARCH_R1;
+ nios2_opcodes = (struct nios2_opcode *) nios2_r1_opcodes;
+ nios2_num_opcodes = nios2_num_r1_opcodes;
+ nop32 = nop_r1;
+ nop16 = NULL;
+ return;
+ }
+ else if (strcmp (arch, "r2") == 0)
+ {
+ nios2_architecture |= EF_NIOS2_ARCH_R2;
+ nios2_opcodes = (struct nios2_opcode *) nios2_r2_opcodes;
+ nios2_num_opcodes = nios2_num_r2_opcodes;
+ nop32 = nop_r2;
+ nop16 = nop_r2_cdx;
+ return;
+ }
+
+ as_bad (_("unknown architecture '%s'"), arch);
+}
+
/* The following functions are called by machine-independent parts of
the assembler. */
int
@@ -2235,6 +2269,9 @@ md_parse_option (int c, char *arg ATTRIBUTE_UNUSED)
case OPTION_EL:
target_big_endian = 0;
break;
+ case OPTION_MARCH:
+ nios2_use_arch (arg);
+ break;
default:
return 0;
break;
@@ -2262,9 +2299,11 @@ md_show_usage (FILE *stream)
"branches with jmp sequences (default)\n"
" -no-relax do not replace any branches or calls\n"
" -EB force big-endian byte ordering\n"
- " -EL force little-endian byte ordering\n");
+ " -EL force little-endian byte ordering\n"
+ " -march=ARCH enable instructions from architecture ARCH\n");
}
+
/* This function is called once, at assembler startup time.
It should set up all the tables, etc. that the MD part of the
assembler will need. */
@@ -2274,6 +2313,19 @@ md_begin (void)
int i;
const char *inserted;
+ switch (nios2_architecture)
+ {
+ default:
+ case EF_NIOS2_ARCH_R1:
+ bfd_default_set_arch_mach (stdoutput, bfd_arch_nios2, bfd_mach_nios2r1);
+ break;
+ case EF_NIOS2_ARCH_R2:
+ if (target_big_endian)
+ as_fatal (_("Big-endian R2 is not supported."));
+ bfd_default_set_arch_mach (stdoutput, bfd_arch_nios2, bfd_mach_nios2r2);
+ break;
+ }
+
/* Create and fill a hashtable for the Nios II opcodes, registers and
arguments. */
nios2_opcode_hash = hash_new ();
@@ -2747,3 +2799,13 @@ nios2_frame_initial_instructions (void)
{
cfi_add_CFA_def_cfa (27, 0);
}
+
+#ifdef OBJ_ELF
+/* Some special processing for a Nios II ELF file. */
+
+void
+nios2_elf_final_processing (void)
+{
+ elf_elfheader (stdoutput)->e_flags = nios2_architecture;
+}
+#endif
diff --git a/gas/config/tc-nios2.h b/gas/config/tc-nios2.h
index 2e69caf..8b9a7d8 100644
--- a/gas/config/tc-nios2.h
+++ b/gas/config/tc-nios2.h
@@ -118,4 +118,7 @@ extern int nios2_regname_to_dw2regnum (char *regname);
#define tc_cfi_frame_initial_instructions nios2_frame_initial_instructions
extern void nios2_frame_initial_instructions (void);
+#define elf_tc_final_processing nios2_elf_final_processing
+extern void nios2_elf_final_processing (void);
+
#endif /* TC_NIOS2 */