This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
[patch] Re: egcs-1.0 on mingw32/possibly cygwin32 regression
- To: "Andrew Zabolotny" <bit at freya dot etu dot ru>
- Subject: [patch] Re: egcs-1.0 on mingw32/possibly cygwin32 regression
- From: Mumit Khan <khan at xraylith dot wisc dot edu>
- Date: Fri, 09 Jan 1998 21:05:07 -0600
- Cc: "egcs at cygnus dot com" <egcs at cygnus dot com>
Hi Andrew,
Here's a patch to undo the effects of ENCODE_SECTION_INFO on win32.
Currently the i386/cygwin32.h defines ENCODE_SECTION_INFO which adds
@[NUM] to names that have the "stdcall" attribute, but forgets
to define STRIP_NAME_ENCODING. (Thanks for debugging the problem!)
Here's your test case (filed Jan 8, 1998):
#include <stdio.h>
static __attribute__ ((stdcall)) BlackHole(int a);
void doit()
{
BlackHole(1);
}
static __attribute__ ((stdcall)) BlackHole(int a)
{
printf("disappearing function! %d\n", a);
}
int main()
{
doit();
return (0);
}
Currently with -O3, BlackHole gets inlined, but there is an (incorrect)
undefined call to BlackHole.
% i386-cygwin32-gcc -O3 -c blackhole.c
% i386-cygwin32-nm blackhole.o
00000000 b .bss
00000000 d .data
00000000 t .text
U _BlackHole@4 <<<<<< Here.
00000000 t ___gnu_compiled_c
U ___main
0000001c T _doit
00000028 T _main
00000000 t gcc2_compiled.
With this patch:
% i386-cygwin32-nm blackhole.o
00000000 b .bss
00000000 d .data
00000000 t .text
0000003c t _BlackHole@4 <<<<<< Voila!
00000000 t ___gnu_compiled_c
U ___main
0000001c T _doit
00000028 T _main
U _printf
00000000 t gcc2_compiled.
Fri Jan 9 20:36:23 1998 Mumit Khan <khan@xraylith.wisc.edu>
* i386/cygwin32.h (STRIP_NAME_ENCODING): Define for Win32 to strip
off the trailing @[NUM] added by ENCODE_SECTION_INFO.
Index: egcs/gcc/config/i386/cygwin32.h
diff -c egcs/gcc/config/i386/cygwin32.h:1.2 egcs/gcc/config/i386/cygwin32.h:1.3
*** egcs/gcc/config/i386/cygwin32.h:1.2 Sat Dec 20 16:34:20 1997
--- egcs/gcc/config/i386/cygwin32.h Fri Jan 9 20:46:09 1998
***************
*** 150,155 ****
--- 150,178 ----
while (0)
#endif
+ /* This macro gets just the user-specified name
+ out of the string in a SYMBOL_REF. Discard
+ trailing @[NUM] encoded by ENCODE_SECTION_INFO.
+ Do we need the stripping of leading '*'? */
+ #undef STRIP_NAME_ENCODING
+ #define STRIP_NAME_ENCODING(VAR,SYMBOL_NAME) \
+ do { \
+ char *_p; \
+ char *_name = ((SYMBOL_NAME) + ((SYMBOL_NAME)[0] == '*')); \
+ for (_p = _name; *_p && *_p != '@'; ++_p) \
+ ; \
+ if (*_p == '@') \
+ { \
+ int _len = _p - _name; \
+ (VAR) = (char *) alloca (_len + 1); \
+ strncpy ((VAR), _name, _len); \
+ (VAR)[_len] = '\0'; \
+ } \
+ else \
+ (VAR) = _name; \
+ } while (0)
+
+
/* Emit code to check the stack when allocating more that 4000
bytes in one go. */
Regards,
Mumit -- khan@xraylith.wisc.edu
http://www.xraylith.wisc.edu/~khan/