This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC 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]

Re: [patch] i386/cygwin.h I386_PE_STRIP_ENCODING


 --- DJ Delorie <dj@redhat.com> wrote: > 
> Hmmm, I didn't see that patch (I'm looking at a branch), but that
> patch doesn't affect ASM_OUTPUT_LABELREF.  I wonder if that matters? 


I think it does.

With current CVS the following test-case, modified from
gcc.dg/asm-fs-1.c by the addition of __attribute__((dllexport)) 
fails with options "-ffunction-sections -fdata-sections" on mingw32.

===start===

/* Origin: <hp@bitrange.com>
   Make sure we do not get spurious '*' characters in section names or
   elsewhere, with asm-specified names.  */
/* { dg-do compile } */
/* { dg-options "-ffunction-sections -fdata-sections" } */

void __attribute__((dllexport)) foo (void) asm ("_bar");
void  foo (void) {}

extern int __attribute__((dllexport)) foobar asm ("_baz");
int foobar = 3;

/* { dg-final { scan-assembler-not "\\*_bar" } } */
/* { dg-final { scan-assembler-not "\\*_baz" } } */

===end===

The attribute prepends "@e." to function name so that we get
"@e.*_bar" and "@e.*_baz".  Only the "@ei" is removed by
I386_PE_STRIP_ENCODING and then STRIP_NAME_ENCODING strips the '*'.

However, ASM_OUTPUT_LABELREF, uses the name as stripped by
I386_PE_STRIP_ENCODING, so that we get label refs "*_bar" and "*_baz".

Here is assembler output by gcc.  The section names are okay, the label
refs are not.

===start===

	.file	"asm-fs-export.c"
	.section	.text$_bar,"x"
	.align 2
.globl _*_bar
	.def	_*_bar;	.scl	2;	.type	32;	.endef
_*_bar:
	pushl	%ebp
	movl	%esp, %ebp
	popl	%ebp
	ret
.globl _*_baz
	.section	.data$_baz,"w"
	.align 4
_*_baz:
	.long	3
	.section .drectve

===end===

DJ Delories patch does not fix the dllexport case, but does after adding
a test for '*' at (SYM_NAME)[3].

The test for leading '*' in I386_PE_STRIP_ENCODING  is now redundant and
can be removed so that the latter macro does only what it was intended
to do (discard trailing @n from stdcall names)



--- cygwin.h.orig	Fri Dec 14 21:48:48 2001
+++ cygwin.h	Fri Dec 14 21:55:44 2001
@@ -286,7 +286,9 @@ extern void i386_pe_encode_section_info 
 
 /* Utility used only in this file.  */
 #define I386_PE_STRIP_ENCODING(SYM_NAME) \
-  ((SYM_NAME) + ((SYM_NAME)[0] == '@' ? 3 : 0))
+  ((SYM_NAME) + ((SYM_NAME)[0] == '@' ? 3 : 0) \
+	      + ((SYM_NAME)[0] == '*' ? 1 : 0) \
+	      + ((SYM_NAME)[3] == '*' ? 1 : 0)
 
 /* This macro gets just the user-specified name
    out of the string in a SYMBOL_REF.  Discard
@@ -296,7 +298,6 @@ extern void i386_pe_encode_section_info 
 do {									\
   const char *_p;							\
   const char *_name = I386_PE_STRIP_ENCODING (SYMBOL_NAME);		\
-  if (*_name == '*') _name++;						\
   for (_p = _name; *_p && *_p != '@'; ++_p)				\
     ;									\
   if (*_p == '@')							\


Tested on i586-pc-mingw32

Comments

Danny

http://shopping.yahoo.com.au - Yahoo! Shopping
- Free CDs for thousands of Priority Shoppers!


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