This is the mail archive of the newlib@sources.redhat.com mailing list for the newlib project.


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

illegal alias attribute vs ia64 asm_output_labelref


http://gcc.gnu.org/ml/gcc-patches/2001-07/msg00349.html

This patch broke handling @ and * at the same time in the ia64
ASM_OUTPUT_LABELREF, which meant that some c++ variables would
get mangled during output to contain a leading * character.

I wish I'd looked at the reason for this patch when it went in.
On the face of it it makes no sense -- we're being called to
emit a label, not an expression.  How could there possibly be
a plus sign embedded?

The answer is this little gem from newlib:

extern _CONST char _ctype_[1 + 256] __attribute__ ((alias ("_ctype_b+127")));

This is illegal code.  The argument to the alias attribute is
a symbol name, not an expression.  That it happens to work for
some targets is immaterial.  And before you ask, no, there is
no way to do what you want.  Your best bet is to either push
ALLOW_NEGATIVE_CTYPE_INDEX into ctype.h and adjust the expressions
therein or use __ctype_ptr and ignore _ctype_ entirely.


r~


	* config/ia64/ia64.h (STRIP_NAME_ENCODING): Handle @ and *
	in the same string.
	(ASM_NAME_TO_STRING): Remove.
	* config/ia64/sysv4.h (ASM_OUTPUT_LABELREF): Handle @ and *
	in the same string.  Remove support for expressions.

Index: config/ia64/ia64.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/ia64/ia64.h,v
retrieving revision 1.84
diff -c -p -d -r1.84 ia64.h
*** ia64.h	2001/08/19 03:04:19	1.84
--- ia64.h	2001/08/19 06:47:12
*************** do {									\
*** 1968,1978 ****
  /* Decode SYM_NAME and store the real name part in VAR, sans the characters
     that encode section info.  */
  
! #define STRIP_NAME_ENCODING(VAR, SYMBOL_NAME) \
!   (VAR) = ((SYMBOL_NAME)                        \
! 	   + (*(SYMBOL_NAME) == '*' || *(SYMBOL_NAME) == SDATA_NAME_FLAG_CHAR))
! 
! 
  
  /* Position Independent Code.  */
  
--- 1968,1981 ----
  /* Decode SYM_NAME and store the real name part in VAR, sans the characters
     that encode section info.  */
  
! #define STRIP_NAME_ENCODING(VAR, SYMBOL_NAME)	\
! do {						\
!   (VAR) = (SYMBOL_NAME);			\
!   if ((VAR)[0] == SDATA_NAME_FLAG_CHAR)		\
!     (VAR)++;					\
!   if ((VAR)[0] == '*')				\
!     (VAR)++;					\
! } while (0)
  
  /* Position Independent Code.  */
  
*************** do {									\
*** 2547,2569 ****
  #define UNALIGNED_SHORT_ASM_OP		"\tdata2.ua\t"
  #define UNALIGNED_INT_ASM_OP		"\tdata4.ua\t"
  #define UNALIGNED_DOUBLE_INT_ASM_OP	"\tdata8.ua\t"
- 
- /* We need to override the default definition for this in dwarf2out.c so that
-    we can emit the necessary # postfix.  */
- #define ASM_NAME_TO_STRING(STR, NAME)			\
-   do {							\
-       if ((NAME)[0] == '*')				\
- 	dyn_string_append (STR, NAME + 1);		\
-       else						\
- 	{						\
- 	  char *newstr;					\
- 	  STRIP_NAME_ENCODING (newstr, NAME);		\
- 	  dyn_string_append (STR, user_label_prefix);	\
- 	  dyn_string_append (STR, newstr);		\
- 	  dyn_string_append (STR, "#");			\
- 	}						\
-   }							\
-   while (0)
  
  #define DWARF2_ASM_LINE_DEBUG_INFO (TARGET_DWARF2_ASM)
  
--- 2550,2555 ----
Index: config/ia64/sysv4.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/ia64/sysv4.h,v
retrieving revision 1.14
diff -c -p -d -r1.14 sysv4.h
*** sysv4.h	2001/08/09 22:33:25	1.14
--- sysv4.h	2001/08/19 06:47:12
*************** do {									\
*** 54,81 ****
     we have to scan it for a non-label character and insert the # there.  */
  
  #undef ASM_OUTPUT_LABELREF
! #define ASM_OUTPUT_LABELREF(STREAM, NAME) 				\
!   do									\
!     {									\
!       const char *real_name;						\
!       const char *name_end;						\
! 									\
!       STRIP_NAME_ENCODING (real_name, NAME);				\
!       name_end = strchr (real_name, '+');				\
! 									\
!       fputs (user_label_prefix, STREAM);				\
!       if (name_end)							\
! 	fwrite (real_name, name_end - real_name, 1, STREAM);		\
!       else								\
! 	fputs (real_name, STREAM);					\
! 									\
!       if (ia64_asm_output_label)					\
! 	fputc ('#', STREAM);						\
! 									\
!       if (name_end)							\
! 	fputs (name_end, STREAM);					\
!     }									\
!   while (0)
  
  /* Intel assembler requires both flags and type if declaring a non-predefined
     section.  */
--- 54,71 ----
     we have to scan it for a non-label character and insert the # there.  */
  
  #undef ASM_OUTPUT_LABELREF
! #define ASM_OUTPUT_LABELREF(STREAM, NAME)	\
! do {						\
!   const char *name_ = NAME;			\
!   if (*name_ == SDATA_NAME_FLAG_CHAR)		\
!     name_++;					\
!   if (*name_ == '*')				\
!     name_++;					\
!   else						\
!     fputs (user_label_prefix, STREAM);		\
!   fputs (name_, STREAM);			\
!   fputc ('#', STREAM);				\
! } while (0)
  
  /* Intel assembler requires both flags and type if declaring a non-predefined
     section.  */


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