This is the mail archive of the binutils@sources.redhat.com 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]

Re: GAS patch for sh*-unknown-linux-gnu


On Wed, 3 Oct 2001, NIIBE Yutaka wrote:
> Here's a patch for gas for the target sh*-unknown-linux-gnu.
>
> It does some clean-up for endian handling.  Removing the variable
> shl and use target_big_endian directly, let configure define
> TARGET_BYTES_BIG_ENDIAN.
>
> Besides, we'd like to set default as little endian for
> sh-unknown-linux-gnu, because it's more populer for SH-3 and SH-4.
>
> While only little endian is supported for sh-*-pe, we need
> support of big endian, thus, the option -big.

Thanks!

I've committed the non-controversial changes, like the cleanup
of s/shl/!target_big_endian/ and to use endian=... in
configure.in, though I changed .big to be an assertion rather
than an attempt to change the endianness, which isn't possible
as previously pointed out.  The emitted data may be right, but
the file is marked as having the "original" endianness, causing
at least confusion.  I see .little was also wrong in this
regard.  I committed what's below.  It is possible that this
change may cause problems for some people, but then again I
think this would be the least of their problems.  Tell me if I'm
wrong.

Some nits: I added a ChangeLog entry saying "configure:
Regenerate" and a prototype for the function big.  Also,
my preference is for test-cases for all changes.

You mentioned that you were working on documentation patches.
That'd be most welcome.

2001-10-16  NIIBE Yutaka  <gniibe@m17n.org>,
	    Hans-Peter Nilsson  <hp@bitrange.com>

	* config/tc-sh.c (shl): Remove.
 	(big): New function.
	(little): Remove shl handling.  Emit error for endian mismatch.
	(md_show_usage): Add description of -big.
	(md_parse_option): Handle OPTION_BIG.  Remove shl handling.
	(OPTION_BIG): Add.
	(md_pseudo_table): Add .big.
	(md_longopts): Add -big.
	(md_begin): Don't set target_big_endian here.
	* config/tc-sh.h (TARGET_BYTES_BIG_ENDIAN): Remove.
	(LISTING_HEADER, COFF_MAGIC, TARGET_FORMAT): Use target_big_endian.
	(shl): Remove.
	* configure.in (endian): Default is big.
	(sh-*-pe*): Little endian.
	(cpu_type): Set sh for target sh*.
	* configure: Regenerate.

gas/testsuite:
	* gas/sh/err-le.s, gas/sh/err-be.s: New tests.

*** /dev/null	Tue Jan  1 05:00:00 1980
--- err-be.s	Tue Oct 16 03:54:09 2001
***************
*** 0 ****
--- 1,10 ----
+ ! { dg-do assemble { target sh*-*-elf} }
+ ! { dg-options "-little" }
+ ! { dg-error "-big required" "" { target sh*-*-elf } 0 }
+
+ ! Check that a mismatch between command-line options and the .big
+ ! directive is identified.
+
+ 	.big
+ start:
+ 	nop

*** /dev/null	Tue Jan  1 05:00:00 1980
--- err-le.s	Tue Oct 16 03:54:03 2001
***************
*** 0 ****
--- 1,10 ----
+ ! { dg-do assemble { target sh*-*-elf} }
+ ! { dg-options "-big" }
+ ! { dg-error "-little required" "" { target sh*-*-elf } 0 }
+
+ ! Check that a mismatch between command-line options and the .big
+ ! directive is identified.
+
+ 	.little
+ start:
+ 	nop

Index: configure.in
===================================================================
RCS file: /cvs/src/src/gas/configure.in,v
retrieving revision 1.78
diff -p -c -r1.78 configure.in
*** configure.in	2001/09/14 11:46:40	1.78
--- configure.in	2001/10/16 02:32:07
*************** changequote([,])dnl
*** 144,149 ****
--- 144,150 ----
        rs6000*)		cpu_type=ppc ;;
        s390x*)		cpu_type=s390 arch=s390x ;;
        s390*)		cpu_type=s390 arch=s390 ;;
+       sh*)		cpu_type=sh endian=big ;;
        sparclite*)	cpu_type=sparc arch=sparclite ;;
        sparclet*)	cpu_type=sparc arch=sparclet ;;
        sparc64*)		cpu_type=sparc arch=v9-64 ;;
*************** changequote([,])dnl
*** 401,407 ****
        sh-*-linux*)	    fmt=elf em=linux ;;
        sh-*-elf*)	    fmt=elf ;;
        sh-*-coff*)           fmt=coff bfd_gas=yes;;
!       sh-*-pe*)             fmt=coff em=pe bfd_gas=yes;;
        sh-*-rtemself*)       fmt=elf ;;
        sh-*-rtems*)	    fmt=coff bfd_gas=yes;;

--- 402,408 ----
        sh-*-linux*)	    fmt=elf em=linux ;;
        sh-*-elf*)	    fmt=elf ;;
        sh-*-coff*)           fmt=coff bfd_gas=yes;;
!       sh-*-pe*)             fmt=coff em=pe bfd_gas=yes endian=little ;;
        sh-*-rtemself*)       fmt=elf ;;
        sh-*-rtems*)	    fmt=coff bfd_gas=yes;;

Index: config/tc-sh.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-sh.c,v
retrieving revision 1.44
diff -p -c -r1.44 tc-sh.c
*** tc-sh.c	2001/10/11 23:56:33	1.44
--- tc-sh.c	2001/10/16 02:01:45
*************** static void s_uacons PARAMS ((int));
*** 57,62 ****
--- 57,63 ----
  static sh_opcode_info *find_cooked_opcode PARAMS ((char **));
  static unsigned int assemble_ppi PARAMS ((char *, sh_opcode_info *));
  static void little PARAMS ((int));
+ static void big PARAMS ((int));
  static bfd_reloc_code_real_type sh_elf_suffix
    PARAMS ((char **str_p, expressionS *, expressionS *new_exp_p));
  static int parse_reg PARAMS ((char *, int *, int *));
*************** static void sh_elf_cons PARAMS ((int));
*** 80,92 ****
  symbolS *GOT_symbol;		/* Pre-defined "_GLOBAL_OFFSET_TABLE_" */
  #endif

! int shl = 0;

  static void
  little (ignore)
       int ignore ATTRIBUTE_UNUSED;
  {
!   shl = 1;
    target_big_endian = 0;
  }

--- 81,105 ----
  symbolS *GOT_symbol;		/* Pre-defined "_GLOBAL_OFFSET_TABLE_" */
  #endif

! static void
! big (ignore)
!      int ignore ATTRIBUTE_UNUSED;
! {
!   if (! target_big_endian)
!     as_bad (_("directive .big encountered when option -big required"));

+   /* Stop further messages.  */
+   target_big_endian = 1;
+ }
+
  static void
  little (ignore)
       int ignore ATTRIBUTE_UNUSED;
  {
!   if (target_big_endian)
!     as_bad (_("directive .little encountered when option -little required"));
!
!   /* Stop further messages.  */
    target_big_endian = 0;
  }

*************** const pseudo_typeS md_pseudo_table[] =
*** 107,112 ****
--- 120,126 ----
    {"int", cons, 4},
    {"word", cons, 2},
  #endif /* OBJ_ELF */
+   {"big", big, 0},
    {"form", listing_psize, 0},
    {"little", little, 0},
    {"heading", listing_title, 0},
*************** md_begin ()
*** 439,452 ****
    char *prev_name = "";
    int target_arch;

- #ifdef TE_PE
-   /* The WinCE OS only supports little endian executables.  */
-   target_big_endian = 0;
- #else
-   if (! shl)
-     target_big_endian = 1;
- #endif
-
    target_arch = arch_sh1_up & ~(sh_dsp ? arch_sh3e_up : arch_sh_dsp_up);
    valid_arch = target_arch;

--- 453,458 ----
*************** CONST char *md_shortopts = "";
*** 2127,2137 ****
  struct option md_longopts[] =
  {
  #define OPTION_RELAX  (OPTION_MD_BASE)
! #define OPTION_LITTLE (OPTION_MD_BASE + 1)
  #define OPTION_SMALL (OPTION_LITTLE + 1)
  #define OPTION_DSP (OPTION_SMALL + 1)

    {"relax", no_argument, NULL, OPTION_RELAX},
    {"little", no_argument, NULL, OPTION_LITTLE},
    {"small", no_argument, NULL, OPTION_SMALL},
    {"dsp", no_argument, NULL, OPTION_DSP},
--- 2133,2145 ----
  struct option md_longopts[] =
  {
  #define OPTION_RELAX  (OPTION_MD_BASE)
! #define OPTION_BIG (OPTION_MD_BASE + 1)
! #define OPTION_LITTLE (OPTION_BIG + 1)
  #define OPTION_SMALL (OPTION_LITTLE + 1)
  #define OPTION_DSP (OPTION_SMALL + 1)

    {"relax", no_argument, NULL, OPTION_RELAX},
+   {"big", no_argument, NULL, OPTION_BIG},
    {"little", no_argument, NULL, OPTION_LITTLE},
    {"small", no_argument, NULL, OPTION_SMALL},
    {"dsp", no_argument, NULL, OPTION_DSP},
*************** md_parse_option (c, arg)
*** 2150,2157 ****
        sh_relax = 1;
        break;

      case OPTION_LITTLE:
-       shl = 1;
        target_big_endian = 0;
        break;

--- 2158,2168 ----
        sh_relax = 1;
        break;

+     case OPTION_BIG:
+       target_big_endian = 1;
+       break;
+
      case OPTION_LITTLE:
        target_big_endian = 0;
        break;

*************** md_show_usage (stream)
*** 2177,2182 ****
--- 2188,2194 ----
    fprintf (stream, _("\
  SH options:\n\
  -little			generate little endian code\n\
+ -big			generate big endian code\n\
  -relax			alter jump instructions for long displacements\n\
  -small			align sections to 4 byte boundaries, not 16\n\
  -dsp			enable sh-dsp insns, and disable sh3e / sh4 insns.\n"));
Index: config/tc-sh.h
===================================================================
RCS file: /cvs/src/src/gas/config/tc-sh.h,v
retrieving revision 1.14
diff -p -c -r1.14 tc-sh.h
*** tc-sh.h	2001/10/01 00:08:36	1.14
--- tc-sh.h	2001/10/16 02:01:45
***************
*** 21,28 ****

  #define TC_SH

- #define TARGET_BYTES_BIG_ENDIAN 0
-
  #define TARGET_ARCH bfd_arch_sh

  #if ANSI_PROTOTYPES
--- 21,26 ----
*************** struct segment_info_struct;
*** 30,38 ****
  struct internal_reloc;
  #endif

- /* Whether in little endian mode.  */
- extern int shl;
-
  /* Whether -relax was used.  */
  extern int sh_relax;

--- 28,33 ----
*************** extern long md_pcrel_from_section PARAMS
*** 81,87 ****

  #define IGNORE_NONSTANDARD_ESCAPES

! #define LISTING_HEADER (shl ? "Hitachi Super-H GAS Little Endian" : "Hitachi Super-H GAS Big Endian")

  #define md_operand(x)

--- 76,84 ----

  #define IGNORE_NONSTANDARD_ESCAPES

! #define LISTING_HEADER \
!   (!target_big_endian \
!    ? "Hitachi Super-H GAS Little Endian" : "Hitachi Super-H GAS Big Endian")

  #define md_operand(x)

*************** extern void sh_frob_file PARAMS ((void))
*** 123,129 ****

  #define BFD_ARCH TARGET_ARCH

! #define COFF_MAGIC (shl ? SH_ARCH_MAGIC_LITTLE : SH_ARCH_MAGIC_BIG)

  /* We need to write out relocs which have not been completed.  */
  #define TC_COUNT_RELOC(fix) ((fix)->fx_addsy != NULL)
--- 120,126 ----

  #define BFD_ARCH TARGET_ARCH

! #define COFF_MAGIC (!target_big_endian ? SH_ARCH_MAGIC_LITTLE : SH_ARCH_MAGIC_BIG)

  /* We need to write out relocs which have not been completed.  */
  #define TC_COUNT_RELOC(fix) ((fix)->fx_addsy != NULL)
*************** extern int tc_coff_sizemachdep PARAMS ((
*** 168,176 ****
  extern int target_big_endian;

  #ifdef TE_LINUX
! #define TARGET_FORMAT (shl ? "elf32-sh-linux" : "elf32-shbig-linux")
  #else
! #define TARGET_FORMAT (shl ? "elf32-shl" : "elf32-sh")
  #endif

  #define elf_tc_final_processing sh_elf_final_processing
--- 165,173 ----
  extern int target_big_endian;

  #ifdef TE_LINUX
! #define TARGET_FORMAT (!target_big_endian ? "elf32-sh-linux" : "elf32-shbig-linux")
  #else
! #define TARGET_FORMAT (!target_big_endian ? "elf32-shl" : "elf32-sh")
  #endif

  #define elf_tc_final_processing sh_elf_final_processing

brgds, H-P


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