From 856ea05ccf051d4d86f422552f5cdfa83659dd6b Mon Sep 17 00:00:00 2001 From: Kaushik Phata Date: Fri, 16 May 2014 14:57:10 +0100 Subject: [PATCH] This adds support for marking RL78 binaries as either supporting 32-bit or 64-bit doubles. It also makes the linker complain if the user attempts to link together binaries with different sized doubles. * elf32-rl78.c (rl78_elf_merge_private_bfd_data): Complain if 64-bit doubles objects mix with 32-bit doubles objects. (rl78_elf_print_private_bfd_data): Describe 64-bit doubles flag. * readelf.c (get_machine_flags): Handle RL78 64-bit doubles flag. * config/tc-rl78.c (enum options): Add OPTION_32BIT_DOUBLES and OPTION_64BIT_DOUBLES. (md_longopts): Add -m32bit-doubles and -m64bit-doubles. (md_parse_option): Parse -m32bit-doubles and -m64bit-doubles. (md_show_usage): Show all of the RL78 options. (rl78_float_cons): New static functions. (md_pseudo_table): Update handler for "double". --- bfd/ChangeLog | 6 ++++++ bfd/elf32-rl78.c | 16 ++++++++++++++++ binutils/ChangeLog | 4 ++++ binutils/readelf.c | 2 ++ gas/ChangeLog | 12 ++++++++++++ gas/config/tc-rl78.c | 37 ++++++++++++++++++++++++++++++------- gas/doc/as.texinfo | 6 ++++++ gas/doc/c-rl78.texi | 14 ++++++++++++-- 8 files changed, 88 insertions(+), 9 deletions(-) diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 3c0aa713ec..de40fb774c 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,9 @@ +2014-05-16 Kaushik Phata + + * elf32-rl78.c (rl78_elf_merge_private_bfd_data): Complain if + 64-bit doubles objects mix with 32-bit doubles objects. + (rl78_elf_print_private_bfd_data): Describe 64-bit doubles flag. + 2014-05-08 Hans-Peter Nilsson * mmo.c: Update URLs in documentation comments. diff --git a/bfd/elf32-rl78.c b/bfd/elf32-rl78.c index 7b66971e96..5e62edd302 100644 --- a/bfd/elf32-rl78.c +++ b/bfd/elf32-rl78.c @@ -1049,6 +1049,19 @@ rl78_elf_merge_private_bfd_data (bfd * ibfd, bfd * obfd) (*_bfd_error_handler) (_("- %s is G10, %s is not"), bfd_get_filename (ibfd), bfd_get_filename (obfd)); } + + if (changed_flags & E_FLAG_RL78_64BIT_DOUBLES) + { + (*_bfd_error_handler) + (_("RL78 merge conflict: cannot link 32-bit and 64-bit objects together")); + + if (old_flags & E_FLAG_RL78_64BIT_DOUBLES) + (*_bfd_error_handler) (_("- %s is 64-bit, %s is not"), + bfd_get_filename (obfd), bfd_get_filename (ibfd)); + else + (*_bfd_error_handler) (_("- %s is 64-bit, %s is not"), + bfd_get_filename (ibfd), bfd_get_filename (obfd)); + } } return !error; @@ -1071,6 +1084,9 @@ rl78_elf_print_private_bfd_data (bfd * abfd, void * ptr) if (flags & E_FLAG_RL78_G10) fprintf (file, _(" [G10]")); + if (flags & E_FLAG_RL78_64BIT_DOUBLES) + fprintf (file, _(" [64-bit doubles]")); + fputc ('\n', file); return TRUE; } diff --git a/binutils/ChangeLog b/binutils/ChangeLog index 922317f68a..66f2ec15c5 100644 --- a/binutils/ChangeLog +++ b/binutils/ChangeLog @@ -1,3 +1,7 @@ +2014-05-16 Kaushik Phata + + * readelf.c (get_machine_flags): Handle RL78 64-bit doubles flag. + 2014-05-02 Alan Modra * emul_aix.c: Update bfd target vector naming. diff --git a/binutils/readelf.c b/binutils/readelf.c index 9cafd7c4fe..af6463e6ad 100644 --- a/binutils/readelf.c +++ b/binutils/readelf.c @@ -3009,6 +3009,8 @@ get_machine_flags (unsigned e_flags, unsigned e_machine) case EM_RL78: if (e_flags & E_FLAG_RL78_G10) strcat (buf, ", G10"); + if (e_flags & E_FLAG_RL78_64BIT_DOUBLES) + strcat (buf, ", 64-bit doubles"); break; case EM_RX: diff --git a/gas/ChangeLog b/gas/ChangeLog index e5e6785b12..fa1d46b50e 100644 --- a/gas/ChangeLog +++ b/gas/ChangeLog @@ -1,3 +1,15 @@ +2014-05-16 Kaushik Phata + + * config/tc-rl78.c (enum options): Add OPTION_32BIT_DOUBLES + and OPTION_64BIT_DOUBLES. + (md_longopts): Add -m32bit-doubles and -m64bit-doubles. + (md_parse_option): Parse -m32bit-doubles and -m64bit-doubles. + (md_show_usage): Show all of the RL78 options. + (rl78_float_cons): New static functions. + (md_pseudo_table): Update handler for "double". + * doc/c-rl78.texi: Document new options. + * doc/as.texinfo: Likewise. + 2014-05-13 Matthew Fortune * config/tc-mips.c (mips_set_options): Rename gp32 to gp throughout. diff --git a/gas/config/tc-rl78.c b/gas/config/tc-rl78.c index bbbf47bb40..0cd7e5b5a9 100644 --- a/gas/config/tc-rl78.c +++ b/gas/config/tc-rl78.c @@ -282,6 +282,8 @@ enum options { OPTION_RELAX = OPTION_MD_BASE, OPTION_G10, + OPTION_32BIT_DOUBLES, + OPTION_64BIT_DOUBLES, }; #define RL78_SHORTOPTS "" @@ -292,6 +294,8 @@ struct option md_longopts[] = { {"relax", no_argument, NULL, OPTION_RELAX}, {"mg10", no_argument, NULL, OPTION_G10}, + {"m32bit-doubles", no_argument, NULL, OPTION_32BIT_DOUBLES}, + {"m64bit-doubles", no_argument, NULL, OPTION_64BIT_DOUBLES}, {NULL, no_argument, NULL, 0} }; size_t md_longopts_size = sizeof (md_longopts); @@ -308,6 +312,14 @@ md_parse_option (int c, char * arg ATTRIBUTE_UNUSED) case OPTION_G10: elf_flags |= E_FLAG_RL78_G10; return 1; + + case OPTION_32BIT_DOUBLES: + elf_flags &= ~ E_FLAG_RL78_64BIT_DOUBLES; + return 1; + + case OPTION_64BIT_DOUBLES: + elf_flags |= E_FLAG_RL78_64BIT_DOUBLES; + return 1; } return 0; } @@ -315,9 +327,12 @@ md_parse_option (int c, char * arg ATTRIBUTE_UNUSED) void md_show_usage (FILE * stream ATTRIBUTE_UNUSED) { + fprintf (stream, _(" RL78 specific command line options:\n")); + fprintf (stream, _(" --mg10 Enable support for G10 variant\n")); + fprintf (stream, _(" --m32bit-doubles [default]\n")); + fprintf (stream, _(" --m64bit-doubles\n")); } - static void s_bss (int ignore ATTRIBUTE_UNUSED) { @@ -328,15 +343,23 @@ s_bss (int ignore ATTRIBUTE_UNUSED) demand_empty_rest_of_line (); } +static void +rl78_float_cons (int ignore ATTRIBUTE_UNUSED) +{ + if (elf_flags & E_FLAG_RL78_64BIT_DOUBLES) + return float_cons ('d'); + return float_cons ('f'); +} + /* The target specific pseudo-ops which we support. */ const pseudo_typeS md_pseudo_table[] = { - /* Our "standard" pseudos. */ - { "double", float_cons, 'd' }, - { "bss", s_bss, 0 }, - { "3byte", cons, 3 }, - { "int", cons, 4 }, - { "word", cons, 4 }, + /* Our "standard" pseudos. */ + { "double", rl78_float_cons, 'd' }, + { "bss", s_bss, 0 }, + { "3byte", cons, 3 }, + { "int", cons, 4 }, + { "word", cons, 4 }, /* End of list marker. */ { NULL, NULL, 0 } diff --git a/gas/doc/as.texinfo b/gas/doc/as.texinfo index 5759e9bfba..0f0956ce2b 100644 --- a/gas/doc/as.texinfo +++ b/gas/doc/as.texinfo @@ -479,6 +479,12 @@ gcc(1), ld(1), and the Info entries for @file{binutils} and @file{ld}. [@b{-msolaris}|@b{-mno-solaris}] [@b{-nops=@var{count}}] @end ifset +@ifset RL78 + +@emph{Target RL78 options:} + [@b{-mg10}] + [@b{-m32bit-doubles}|@b{-m64bit-doubles}] +@end ifset @ifset RX @emph{Target RX options:} diff --git a/gas/doc/c-rl78.texi b/gas/doc/c-rl78.texi index dce833bc75..a7145482d9 100644 --- a/gas/doc/c-rl78.texi +++ b/gas/doc/c-rl78.texi @@ -32,6 +32,14 @@ Enable support for link-time relaxation. Mark the generated binary as targeting the G10 variant of the RL78 architecture. +@item m32bit-doubles +Mark the generated binary as one that uses 32-bits to hold the +@code{double} floating point type. This is the default. + +@item m64bit-doubles +Mark the generated binary as one that uses 64-bits to hold the +@code{double} floating point type. + @end table @node RL78-Modifiers @@ -85,8 +93,10 @@ In addition to the common directives, the RL78 adds these: @table @code @item .double -Output a constant in ``double'' format, which is a 32-bit floating -point value on RL78. +Output a constant in ``double'' format, which is either a 32-bit +or a 64-bit floating point value, depending upon the setting of the +@option{-m32bit-doubles}|@option{-m64bit-doubles} command line +option. @item .bss Select the BSS section.