This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Commit: RL78: Add support for G10 binaries


Hi Guys,

  I am applying the patch below to add support to GAS for generating
  RL78 binaries that target the G10 architecture variant.  This variant
  only has one register bank, so it has to use a different ABI from
  other RL78 parts.  The patch also enhances the linker to issue an
  error message if the user attempts to link together G10 and non-G10
  RL78 binaries.

Cheers
  Nick

bfd/ChangeLog
2013-08-09  Nick Clifton  <nickc@redhat.com>

	* elf32-rl78.c (rl78_elf_merge_private_bfd_data): Complain if G10
	flag bits do not match.
	(rl78_elf_print_private_bfd_data): Describe G10 flag.

binutils/ChangeLog
2013-08-09  Nick Clifton  <nickc@redhat.com>

	* readelf.c (get_machine_flags): Handle RL78 G10 flag.

gas/ChangeLog
2013-08-09  Nick Clifton  <nickc@redhat.com>

	* config/tc-rl78.c (elf_flags): New variable.
	(enum options): Add OPTION_G10.
	(md_longopts): Add mg10.
	(md_parse_option): Parse -mg10.
	(rl78_elf_final_processing): New function.
	* config/tc-rl78.c (tc_final_processing): Define.
	* doc/c-rl78.texi: Document -mg10 option.

include/elf/ChangeLog
2013-08-09  Nick Clifton  <nickc@redhat.com>

	* rl78.c (E_FLAG_RL78_G10): Define.

ld/testsuite/ChangeLog
2013-08-09  Nick Clifton  <nickc@redhat.com>

	* lib/ld-lib.exp (check_shared_lib_support): Note that the RL78
	does not support shared library generation.

Index: bfd/elf32-rl78.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-rl78.c,v
retrieving revision 1.16
diff -u -3 -p -r1.16 elf32-rl78.c
--- bfd/elf32-rl78.c	11 Jun 2013 19:16:07 -0000	1.16
+++ bfd/elf32-rl78.c	9 Aug 2013 10:05:54 -0000
@@ -1021,9 +1020,11 @@ static bfd_boolean
 rl78_elf_merge_private_bfd_data (bfd * ibfd, bfd * obfd)
 {
   flagword new_flags;
+  flagword old_flags;
   bfd_boolean error = FALSE;
 
   new_flags = elf_elfheader (ibfd)->e_flags;
+  old_flags = elf_elfheader (obfd)->e_flags;
 
   if (!elf_flags_init (obfd))
     {
@@ -1031,6 +1032,23 @@ rl78_elf_merge_private_bfd_data (bfd * i
       elf_flags_init (obfd) = TRUE;
       elf_elfheader (obfd)->e_flags = new_flags;
     }
+  else if (old_flags != new_flags)
+    {
+      flagword changed_flags = old_flags ^ new_flags;
+
+      if (changed_flags & E_FLAG_RL78_G10)
+	{
+	  (*_bfd_error_handler)
+	    (_("RL78/G10 ABI conflict: cannot link G10 and non-G10 objects together"));
+
+	  if (old_flags & E_FLAG_RL78_G10)
+	    (*_bfd_error_handler) (_("- %s is G10, %s is not"),
+				   bfd_get_filename (obfd), bfd_get_filename (ibfd));
+	  else
+	    (*_bfd_error_handler) (_("- %s is G10, %s is not"),
+				   bfd_get_filename (ibfd), bfd_get_filename (obfd));
+	}
+    }
 
   return !error;
 }
@@ -1049,6 +1067,9 @@ rl78_elf_print_private_bfd_data (bfd * a
   flags = elf_elfheader (abfd)->e_flags;
   fprintf (file, _("private flags = 0x%lx:"), (long) flags);
 
+  if (flags & E_FLAG_RL78_G10)
+    fprintf (file, _(" [G10]"));
+
   fputc ('\n', file);
   return TRUE;
 }
Index: binutils/readelf.c
===================================================================
RCS file: /cvs/src/src/binutils/readelf.c,v
retrieving revision 1.606
diff -u -3 -p -r1.606 readelf.c
--- binutils/readelf.c	19 Jul 2013 10:44:01 -0000	1.606
+++ binutils/readelf.c	9 Aug 2013 10:05:54 -0000
@@ -2779,6 +2779,11 @@ get_machine_flags (unsigned e_flags, uns
 	    strcat (buf, ", G-Float");
 	  break;
 
+	case EM_RL78:
+	  if (e_flags & E_FLAG_RL78_G10)
+	    strcat (buf, ", G10");
+	  break;
+	  
 	case EM_RX:
 	  if (e_flags & E_FLAG_RX_64BIT_DOUBLES)
 	    strcat (buf, ", 64-bit doubles");
Index: gas/config/tc-rl78.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-rl78.c,v
retrieving revision 1.6
diff -u -3 -p -r1.6 tc-rl78.c
--- gas/config/tc-rl78.c	27 Feb 2013 21:39:20 -0000	1.6
+++ gas/config/tc-rl78.c	9 Aug 2013 10:05:55 -0000
@@ -45,6 +44,9 @@ const char line_separator_chars[] = "@";
 const char EXP_CHARS[]            = "eE";
 const char FLT_CHARS[]            = "dD";
 
+/* ELF flags to set in the output file header.  */
+static int elf_flags = 0;
+
 /*------------------------------------------------------------------*/
 
 char * rl78_lex_start;
@@ -260,6 +262,7 @@ rl78_field (int val, int pos, int sz)
 enum options
 {
   OPTION_RELAX = OPTION_MD_BASE,
+  OPTION_G10,
 };
 
 #define RL78_SHORTOPTS ""
@@ -269,6 +272,7 @@ const char * md_shortopts = RL78_SHORTOP
 struct option md_longopts[] =
 {
   {"relax", no_argument, NULL, OPTION_RELAX},
+  {"mg10", no_argument, NULL, OPTION_G10},
   {NULL, no_argument, NULL, 0}
 };
 size_t md_longopts_size = sizeof (md_longopts);
@@ -282,6 +286,9 @@ md_parse_option (int c, char * arg ATTRI
       linkrelax = 1;
       return 1;
 
+    case OPTION_G10:
+      elf_flags |= E_FLAG_RL78_G10;
+      return 1;
     }
   return 0;
 }
@@ -326,6 +333,13 @@ rl78_md_end (void)
 {
 }
 
+/* Set the ELF specific flags.  */
+void
+rl78_elf_final_processing (void)
+{
+  elf_elfheader (stdoutput)->e_flags |= elf_flags;
+}
+
 /* Write a value out to the object file, using the appropriate endianness.  */
 void
 md_number_to_chars (char * buf, valueT val, int n)
Index: gas/config/tc-rl78.h
===================================================================
RCS file: /cvs/src/src/gas/config/tc-rl78.h,v
retrieving revision 1.2
diff -u -3 -p -r1.2 tc-rl78.h
--- gas/config/tc-rl78.h	23 Dec 2011 01:49:37 -0000	1.2
+++ gas/config/tc-rl78.h	9 Aug 2013 10:05:55 -0000
@@ -77,3 +77,6 @@ extern void rl78_cons_fix_new (fragS *, 
 #define MAX_MEM_FOR_RS_ALIGN_CODE 8
 #define HANDLE_ALIGN(FRAG) rl78_handle_align (FRAG)
 extern void rl78_handle_align (fragS *);
+
+#define elf_tc_final_processing	rl78_elf_final_processing
+extern void rl78_elf_final_processing (void);
Index: gas/doc/c-rl78.texi
===================================================================
RCS file: /cvs/src/src/gas/doc/c-rl78.texi,v
retrieving revision 1.2
diff -u -3 -p -r1.2 c-rl78.texi
--- gas/doc/c-rl78.texi	4 Nov 2011 16:04:13 -0000	1.2
+++ gas/doc/c-rl78.texi	9 Aug 2013 10:05:55 -0000
@@ -25,8 +24,15 @@
 @cindex options, RL78
 @cindex RL78 options
 
-The Renesas RL78 port of @code{@value{AS}} has no target-specific
-options.
+@table @code
+@item relax
+Enable support for link-time relaxation.
+
+@item mg10
+Mark the generated binary as targeting the G10 variant of the RL78
+architecture.
+
+@end table
 
 @node RL78-Modifiers
 @section Symbolic Operand Modifiers
Index: include/elf/rl78.h
===================================================================
RCS file: /cvs/src/src/include/elf/rl78.h,v
retrieving revision 1.2
diff -u -3 -p -r1.2 rl78.h
--- include/elf/rl78.h	23 Dec 2011 01:49:37 -0000	1.2
+++ include/elf/rl78.h	9 Aug 2013 10:05:55 -0000
@@ -104,8 +104,9 @@ END_RELOC_NUMBERS (R_RL78_max)
 #define EF_RL78_ALL_FLAGS	(EF_RL78_CPU_MASK)
 
 /* Values for the e_flags field in the ELF header.  */
-#define E_FLAG_RL78_64BIT_DOUBLES		(1 << 0)
+#define E_FLAG_RL78_64BIT_DOUBLES	(1 << 0)
 #define E_FLAG_RL78_DSP			(1 << 1) /* Defined in the RL78 CPU Object file specification, but not explained.  */
+#define E_FLAG_RL78_G10			(1 << 2) /* CPU is missing register banks 1-3, so uses different ABI.  */
 
 /* These define the addend field of R_RL78_RH_RELAX relocations.  */
 #define	RL78_RELAXA_BRA		0x00000010	/* Any type of branch (must be decoded).  */
Index: ld/testsuite/lib/ld-lib.exp
===================================================================
RCS file: /cvs/src/src/ld/testsuite/lib/ld-lib.exp,v
retrieving revision 1.107
diff -u -3 -p -r1.107 ld-lib.exp
--- ld/testsuite/lib/ld-lib.exp	24 Jul 2013 17:24:20 -0000	1.107
+++ ld/testsuite/lib/ld-lib.exp	9 Aug 2013 10:05:56 -0000
@@ -1595,6 +1595,7 @@ proc check_shared_lib_support { } {
 	 && ![istarget openrisc-*-*]
 	 && ![istarget or32-*-*]
 	 && ![istarget pj-*-*]
+	 && ![istarget rl78-*-*]
 	 && ![istarget rx-*-*]
 	 && ![istarget spu-*-*]
 	 && ![istarget v850*-*-*]


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]