[linux-unicore] [PATCH binutils 4/5] Building support for gas.

  • From: LIU Zhiyou <liuzhiyou.cs@xxxxxxxxx>
  • To: gxt@xxxxxxxxxxxxxxx
  • Date: Tue, 12 Feb 2013 14:18:34 +0800

Signed-off-by: LIU Zhiyou <liuzhiyou.cs@xxxxxxxxx>
---
 gas/Makefile.am           |   2 +
 gas/Makefile.in           |  17 ++++++
 gas/config/tc-unicore32.c | 135 ++++++++++++++++++++++++++++++++++++++++++++++
 gas/config/tc-unicore32.h |  39 ++++++++++++++
 gas/configure.tgt         |   3 ++
 5 files changed, 196 insertions(+)
 create mode 100644 gas/config/tc-unicore32.c
 create mode 100644 gas/config/tc-unicore32.h

diff --git a/gas/Makefile.am b/gas/Makefile.am
index fdfa452..62cd523 100644
--- a/gas/Makefile.am
+++ b/gas/Makefile.am
@@ -166,6 +166,7 @@ TARGET_CPU_CFILES = \
        config/tc-tic6x.c \
        config/tc-tilegx.c \
        config/tc-tilepro.c \
+       config/tc-unicore32.c \
        config/tc-vax.c \
        config/tc-v850.c \
        config/tc-xstormy16.c \
@@ -235,6 +236,7 @@ TARGET_CPU_HFILES = \
        config/tc-tic6x.h \
        config/tc-tilegx.h \
        config/tc-tilepro.h \
+       config/tc-unicore32.h \
        config/tc-vax.h \
        config/tc-v850.h \
        config/tc-xstormy16.h \
diff --git a/gas/Makefile.in b/gas/Makefile.in
index a2d8902..656b6be 100644
--- a/gas/Makefile.in
+++ b/gas/Makefile.in
@@ -434,6 +434,7 @@ TARGET_CPU_CFILES = \
        config/tc-tic6x.c \
        config/tc-tilegx.c \
        config/tc-tilepro.c \
+       config/tc-unicore32.c \
        config/tc-vax.c \
        config/tc-v850.c \
        config/tc-xstormy16.c \
@@ -503,6 +504,7 @@ TARGET_CPU_HFILES = \
        config/tc-tic6x.h \
        config/tc-tilegx.h \
        config/tc-tilepro.h \
+       config/tc-unicore32.h \
        config/tc-vax.h \
        config/tc-v850.h \
        config/tc-xstormy16.h \
@@ -854,6 +856,7 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tc-tic6x.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tc-tilegx.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tc-tilepro.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tc-unicore32.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tc-v850.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tc-vax.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tc-xc16x.Po@am__quote@
@@ -1713,6 +1716,20 @@ tc-tilepro.obj: config/tc-tilepro.c
 @AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) 
$(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCC_FALSE@  $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) 
$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o tc-tilepro.obj `if test 
-f 'config/tc-tilepro.c'; then $(CYGPATH_W) 'config/tc-tilepro.c'; else 
$(CYGPATH_W) '$(srcdir)/config/tc-tilepro.c'; fi`
 
+tc-unicore32.o: config/tc-unicore32.c
+@am__fastdepCC_TRUE@   $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) 
$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT tc-unicore32.o -MD -MP 
-MF $(DEPDIR)/tc-unicore32.Tpo -c -o tc-unicore32.o `test -f 
'config/tc-unicore32.c' || echo '$(srcdir)/'`config/tc-unicore32.c
+@am__fastdepCC_TRUE@   $(am__mv) $(DEPDIR)/tc-unicore32.Tpo 
$(DEPDIR)/tc-unicore32.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      source='config/tc-unicore32.c' 
object='tc-unicore32.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) 
$(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) 
$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o tc-unicore32.o `test -f 
'config/tc-unicore32.c' || echo '$(srcdir)/'`config/tc-unicore32.c
+
+tc-unicore32.obj: config/tc-unicore32.c
+@am__fastdepCC_TRUE@   $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) 
$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT tc-unicore32.obj -MD -MP 
-MF $(DEPDIR)/tc-unicore32.Tpo -c -o tc-unicore32.obj `if test -f 
'config/tc-unicore32.c'; then $(CYGPATH_W) 'config/tc-unicore32.c'; else 
$(CYGPATH_W) '$(srcdir)/config/tc-unicore32.c'; fi`
+@am__fastdepCC_TRUE@   $(am__mv) $(DEPDIR)/tc-unicore32.Tpo 
$(DEPDIR)/tc-unicore32.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      source='config/tc-unicore32.c' 
object='tc-unicore32.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) 
$(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) 
$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o tc-unicore32.obj `if 
test -f 'config/tc-unicore32.c'; then $(CYGPATH_W) 'config/tc-unicore32.c'; 
else $(CYGPATH_W) '$(srcdir)/config/tc-unicore32.c'; fi`
+
 tc-vax.o: config/tc-vax.c
 @am__fastdepCC_TRUE@   $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) 
$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT tc-vax.o -MD -MP -MF 
$(DEPDIR)/tc-vax.Tpo -c -o tc-vax.o `test -f 'config/tc-vax.c' || echo 
'$(srcdir)/'`config/tc-vax.c
 @am__fastdepCC_TRUE@   $(am__mv) $(DEPDIR)/tc-vax.Tpo $(DEPDIR)/tc-vax.Po
diff --git a/gas/config/tc-unicore32.c b/gas/config/tc-unicore32.c
new file mode 100644
index 0000000..fcb1292
--- /dev/null
+++ b/gas/config/tc-unicore32.c
@@ -0,0 +1,135 @@
+/* tc-unicore32.c -- Assembler code for the UniCore32 CPU core.
+   Copyright 2013 Free Software Foundation, Inc.
+
+   Contributed by LIU Zhiyou <liuzhiyou.cs@xxxxxxxxx>
+
+   This file is part of GAS, the GNU Assembler.
+
+   GAS 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, or (at your option)
+   any later version.
+
+   GAS 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 GAS; see the file COPYING.  If not, write to the
+   Free Software Foundation, 51 Franklin Street - Fifth Floor, Boston,
+   MA 02110-1301, USA.  */
+
+#include "as.h"
+#include "safe-ctype.h"
+#include "dwarf2dbg.h"
+#include "opcode/unicore32.h"
+
+/* Word is considered here as a 16-bit unsigned short int.  */
+#define WORD_SHIFT  32
+
+/* Register is 2-byte size.  */
+#define REG_SIZE   4
+
+/* Maximum size of a single instruction (in words).  */
+#define INSN_MAX_SIZE   1
+
+/* Maximum bits which may be set in a `mask16' operand.  */
+#define MAX_REGS_IN_MASK16  16
+
+const char comment_chars[]        = "#";
+const char line_comment_chars[]   = "#";
+const char line_separator_chars[] = ";";
+/* Don't know what they are yet */
+const char EXP_CHARS[]            = "eE";
+const char FLT_CHARS[]            = "dD";
+#define OPENRISC_SHORTOPTS "m:"
+const char * md_shortopts = OPENRISC_SHORTOPTS;
+struct option md_longopts[] =
+{
+};
+size_t md_longopts_size = sizeof (md_longopts);
+const pseudo_typeS md_pseudo_table[] =
+{
+};
+int
+md_parse_option (int c ATTRIBUTE_UNUSED, char * arg ATTRIBUTE_UNUSED)
+{
+  return 0;
+}
+
+void
+md_show_usage (FILE * stream ATTRIBUTE_UNUSED)
+{
+}
+
+void
+md_begin (void)
+{
+}
+
+void
+md_assemble (char * str)
+{
+    as_bad("%s", str);
+}
+
+void
+md_operand (expressionS * expressionP)
+{
+    expression (expressionP);
+}
+
+valueT
+md_section_align (segT segment, valueT size)
+{
+  int align = bfd_get_section_alignment (stdoutput, segment);
+  return ((size + (1 << align) - 1) & (-1 << align));
+}
+
+symbolS *
+md_undefined_symbol (char * name ATTRIBUTE_UNUSED)
+{
+  return 0;
+}
+
+int
+md_estimate_size_before_relax (fragS * fragP ATTRIBUTE_UNUSED,
+                               segT segment ATTRIBUTE_UNUSED)
+{
+    return 0;
+}
+
+void
+md_convert_frag (bfd *   abfd ATTRIBUTE_UNUSED,
+                segT    sec  ATTRIBUTE_UNUSED,
+                fragS * fragP ATTRIBUTE_UNUSED)
+{
+    return ;
+}
+
+char *
+md_atof (int type, char * litP, int *  sizeP)
+{
+  return ieee_md_atof (type, litP, sizeP, TRUE);
+}
+
+arelent *
+tc_gen_reloc (asection *section ATTRIBUTE_UNUSED,
+              fixS * fixP ATTRIBUTE_UNUSED)
+{
+    return NULL;
+}
+
+long
+md_pcrel_from (fixS *fixp)
+{
+  return fixp->fx_frag->fr_address + fixp->fx_where;
+}
+
+void
+md_apply_fix (fixS *fixP ATTRIBUTE_UNUSED,
+              valueT *valP ATTRIBUTE_UNUSED,
+              segT seg ATTRIBUTE_UNUSED)
+{
+}
diff --git a/gas/config/tc-unicore32.h b/gas/config/tc-unicore32.h
new file mode 100644
index 0000000..01d2b16
--- /dev/null
+++ b/gas/config/tc-unicore32.h
@@ -0,0 +1,39 @@
+/* tc-unicore32.h -- Header file for tc-unicore32.c,
+   the UniCore32 GAS port.
+   Copyright 2013 Free Software Foundation, Inc.
+
+   Contributed by LIU Zhiyou <liuzhiyou.cs@xxxxxxxxx>
+
+   This file is part of GAS, the GNU Assembler.
+
+   GAS 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, or (at your option)
+   any later version.
+
+   GAS 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 GAS; see the file COPYING.  If not, write to the
+   Free Software Foundation, 51 Franklin Street - Fifth Floor, Boston,
+   MA 02110-1301, USA.  */
+
+#ifndef TC_UNICORE32_H
+#define TC_UNICORE32_H
+
+#define TARGET_BYTES_BIG_ENDIAN 0
+
+// #define GLOBAL_OFFSET_TABLE_NAME "_GLOBAL_OFFSET_TABLE_"
+
+#define TARGET_FORMAT "elf32-unicore32"
+#define TARGET_ARCH   bfd_arch_unicore32
+
+#define WORKING_DOT_WORD
+#define LOCAL_LABEL_PREFIX '.'
+
+#define md_number_to_chars      number_to_chars_littleendian
+
+#endif /* TC_UNICORE32_H */
diff --git a/gas/configure.tgt b/gas/configure.tgt
index 774031e..4278209 100644
--- a/gas/configure.tgt
+++ b/gas/configure.tgt
@@ -87,6 +87,7 @@ case ${cpu} in
   sparc*)              cpu_type=sparc arch=sparclite ;; # ??? See tc-sparc.c.
   tilegx*be)           cpu_type=tilegx endian=big ;;
   tilegx*)             cpu_type=tilegx endian=little ;;
+  unicore32*)   cpu_type=unicore32 endian=little ;;
   v850*)               cpu_type=v850 ;;
   x86_64*)             cpu_type=i386 arch=x86_64;;
   xgate)               cpu_type=xgate ;;
@@ -422,6 +423,8 @@ case ${generic_target} in
 
   tilepro-*-* | tilegx*-*-*)           fmt=elf ;;
 
+  unicore32-*-linux-gnu)    fmt=elf em=linux ;;
+
   v850*-*-*)                           fmt=elf ;;
 
   vax-*-netbsdelf*)                    fmt=elf em=nbsd ;;
-- 
1.8.1.1


Other related posts:

  • » [linux-unicore] [PATCH binutils 4/5] Building support for gas. - LIU Zhiyou