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]

GAS: Preserve copy of case clobber opcodes


Hi Guys,

  A customer recently reported a problem with the ARM assembler that
  turns out to have roots in the generic opcode parsing code in
  read.c.

  It turns out that if IGNORE_OPCODE_CASE is defined (and it always is
  defined), then the opcode is case clobbered before it is passed to
  md_assemble.  This causes problems if the string was not really an
  opcode at all, but something else.

  In the ARM's case the situation was a .req directive, where the
  syntax is <alias> .req <register_name>.  The alias has to be case
  sensitive, and the syntax cannot be changed, since it is defined by
  ARMs own assembler.  ARM's opcodes however, are supposed to be case
  insensitive, so just disabling IGNORE_OPCODE_CASE was not the
  answer.

  The patch resolves this problem by taking a copy of the about-to-be
  case-clobbered opcode and saving it in a global array.  If the
  backend needs the original opcode string, it can access it from this
  array.

Comments or criticisms anyone ?

If not then I will check the patch in in a few days time.

Cheers
	Nick


2000-11-01  Nick Clifton  <nickc@redhat.com>

	* read.c (original_case_string): New global variable.
	(read_a_source_file): Copy opcode string into
	original_case_string if clobbering the case of the opcode.

	* read.h: Export the definition of original_case_string.

	* config/tc-arm.c (md_assembler): When parsing a .req
	directive use the original opcode string, not the case
	clobbered version.

Index: gas/read.c
===================================================================
RCS file: /cvs/src//src/gas/read.c,v
retrieving revision 1.28
diff -p -r1.28 read.c
*** read.c	2000/10/25 19:15:33	1.28
--- read.c	2000/11/02 02:07:31
*************** char is_end_of_line[256] =
*** 165,170 ****
--- 165,174 ----
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0	/* */
  };
  
+ #ifdef  IGNORE_OPCODE_CASE
+ char original_case_string[128];
+ #endif
+ 
  /* Functions private to this file.  */
  
  static char *buffer;	/* 1st char of each buffer of lines is here.  */
*************** read_a_source_file (name)
*** 735,744 ****
  		  /* Expect pseudo-op or machine instruction.  */
  		  pop = NULL;
  
- #define IGNORE_OPCODE_CASE
  #ifdef IGNORE_OPCODE_CASE
  		  {
  		    char *s2 = s;
  		    while (*s2)
  		      {
  			if (isupper ((unsigned char) *s2))
--- 739,751 ----
  		  /* Expect pseudo-op or machine instruction.  */
  		  pop = NULL;
  
  #ifdef IGNORE_OPCODE_CASE
  		  {
  		    char *s2 = s;
+ 
+ 		    strncpy (original_case_string, s2, sizeof (original_case_string));
+ 		    original_case_string[sizeof (original_case_string) - 1] = 0;
+ 		    
  		    while (*s2)
  		      {
  			if (isupper ((unsigned char) *s2))
Index: gas/read.h
===================================================================
RCS file: /cvs/src//src/gas/read.h,v
retrieving revision 1.7
diff -p -r1.7 read.h
*** read.h	2000/09/12 20:57:14	1.7
--- read.h	2000/11/02 02:07:31
*************** enum linkonce_type
*** 85,90 ****
--- 85,95 ----
    LINKONCE_SAME_CONTENTS
  };
  
+ #define IGNORE_OPCODE_CASE
+ #ifdef  IGNORE_OPCODE_CASE
+ extern char original_case_string[];
+ #endif
+ 
  extern void pop_insert PARAMS ((const pseudo_typeS *));
  extern unsigned int get_stab_string_offset
    PARAMS ((const char *string, const char *stabstr_secname));

Index: gas/config/tc-arm.c
===================================================================
RCS file: /cvs/src//src/gas/config/tc-arm.c,v
retrieving revision 1.62
diff -p -r1.62 tc-arm.c
*** tc-arm.c	2000/10/27 13:55:49	1.62
--- tc-arm.c	2000/11/02 02:07:31
*************** _("Warning: Use of the 'nv' conditional 
*** 6613,6621 ****
    if (*q && !strncmp (q, ".req ", 4))
      {
        int    reg;
!       char * copy_of_str = str;
        char * r;
  
        q += 4;
        skip_whitespace (q);
  
--- 6613,6626 ----
    if (*q && !strncmp (q, ".req ", 4))
      {
        int    reg;
!       char * copy_of_str;
        char * r;
  
+ #ifdef IGNORE_OPCODE_CASE
+       str = original_case_string;
+ #endif
+       copy_of_str = str;
+       
        q += 4;
        skip_whitespace (q);
  

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