Nicholas wrote: > Hi All, > > Gerrit and I were discussing this off-list, but I thought it appropriate > that I move it to the main list since he has confirmed the problem. > > Here's the problem, programs are segfaulting when the are linked to a > symbol which was aliased using __attribute__((alias)) in a dll. Here is > a small testcase: > > > foo.c: > #include <stdio.h> > > int __foo (void) { > printf("foo\r\n"); > return 0; > } > int __attribute__ ((alias("__foo"))) foo (void); >
One problem is that you (or gcc) need to tell ld that 'foo' is function, not data. Adding this to file foo.c (after the alias declaration): __asm__ (".def _foo; .scl 2; .type 32; .endef\n"); would do that. That fixes the testcase on mingw anyway. I'm testing a patch now that would make gcc do that too (for aliased functions). However, in general,when you do dllexport with code written in straight assembler, you will need to add a function directive like the one above so that the linker does the right thing. (BTW, you've just reminded me of a similar problem in libffi assembly code that needs to be fixed. Thanks ) Or... The usual windows way would be to put your aliasing for dllexports in a def file. Danny http://personals.yahoo.com.au - Yahoo! Personals New people, new possibilities. FREE for a limited time. -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/