* egcs-1.0 on mingw32/possibly cygwin32 regression
@ 1998-01-08 1:44 Andrew Zabolotny
1998-01-09 20:45 ` [patch] " Mumit Khan
0 siblings, 1 reply; 3+ messages in thread
From: Andrew Zabolotny @ 1998-01-08 1:44 UTC (permalink / raw)
To: egcs
Hello everybody!
The mingw32 egcs-1.0 port and possibly cygnus-win32 egcs-1.0 (since first
is
heavily based on second) has the following problem:
The program:
---------------
#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);
}
---------------
does not compile correctly with -O3. However, it compiles okay if the
-fkeep-inline-functions or with -fno-inline-functions switch was
specified.
The problem is that the BlackHole function is for some reason marked
as 'inline' but instead of inlining its code the compiler puts a
'call BlackHole@4' anyway, but the actual function code is totally
missing.
This problem is not present with gcc-2.7.2 from cygwin32.
I've did not tracked the problem, but I think it's related to the
ENCODE_SECTION_INFO macro in cygwin32.h (the name of function changes
and compiler detects by name whenever the function is inline??? nonsense)
Greetings,
_\ndy@teamOS/2
^ permalink raw reply [flat|nested] 3+ messages in thread
* [patch] Re: egcs-1.0 on mingw32/possibly cygwin32 regression
1998-01-08 1:44 egcs-1.0 on mingw32/possibly cygwin32 regression Andrew Zabolotny
@ 1998-01-09 20:45 ` Mumit Khan
1998-01-14 4:17 ` Jeffrey A Law
0 siblings, 1 reply; 3+ messages in thread
From: Mumit Khan @ 1998-01-09 20:45 UTC (permalink / raw)
To: Andrew Zabolotny; +Cc: egcs
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/
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [patch] Re: egcs-1.0 on mingw32/possibly cygwin32 regression
1998-01-09 20:45 ` [patch] " Mumit Khan
@ 1998-01-14 4:17 ` Jeffrey A Law
0 siblings, 0 replies; 3+ messages in thread
From: Jeffrey A Law @ 1998-01-14 4:17 UTC (permalink / raw)
To: Mumit Khan; +Cc: Andrew Zabolotny, egcs
In message < 9801100305.AA09263@modi.xraylith.wisc.edu >you write:
> 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!)
[ ... ]
> 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.
Thanks. I've installed this change.
jeff
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~1998-01-14 4:17 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1998-01-08 1:44 egcs-1.0 on mingw32/possibly cygwin32 regression Andrew Zabolotny
1998-01-09 20:45 ` [patch] " Mumit Khan
1998-01-14 4:17 ` Jeffrey A Law
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).