This is the mail archive of the
cygwin
mailing list for the Cygwin project.
Re: Possibly wrong address passed to callq asm instruction within MPIR test binaries
- From: Jean-Pierre Flori <jpflori at gmail dot com>
- To: cygwin at cygwin dot com
- Date: Mon, 7 Apr 2014 14:02:43 +0000 (UTC)
- Subject: Re: Possibly wrong address passed to callq asm instruction within MPIR test binaries
- Authentication-results: sourceware.org; auth=none
- References: <20140402090750 dot GP2508 at calimero dot vinschen dot de> <lhsctu$56e$1 at ger dot gmane dot org> <20140407084312 dot GA2061 at calimero dot vinschen dot de> <lhtqa1$ie3$1 at ger dot gmane dot org> <lhtsb6$ie3$2 at ger dot gmane dot org> <lhtve5$ie3$4 at ger dot gmane dot org> <lhtvgh$ie3$5 at ger dot gmane dot org> <lhu212$ie3$6 at ger dot gmane dot org> <20140407113027 dot GA30595 at calimero dot vinschen dot de> <lhu3dq$ie3$7 at ger dot gmane dot org> <20140407115730 dot GA721 at calimero dot vinschen dot de> <lhu95j$ie3$8 at ger dot gmane dot org>
Le Mon, 07 Apr 2014 13:28:19 +0000, Jean-Pierre Flori a ÃcritÂ:
> Le Mon, 07 Apr 2014 13:57:30 +0200, Corinna Vinschen a ÃcritÂ:
>
>> On Apr 7 11:50, Jean-Pierre Flori wrote:
>>> Le Mon, 07 Apr 2014 13:30:27 +0200, Corinna Vinschen a ÃcritÂ:
>>> >
>>> > I'm sorry, but I don't know how this works exactly. The nm prefix
>>> > is only added for external references, not for inlined functions,
>>> > but I don't know the gory details. You may be better off to ask on
>>> > the gcc mailing list.
>>> >
>>> No problem, I've already learned tons of stuff thanks to your help.
>>> I've just posted on gcc-help.
>>> http://gcc.gnu.org/ml/gcc-help/2014-04/msg00024.html
>>
>> Thanks. A simple testcase would still be nice, of course.
>>
>>
> Sure, but it seems the issue is that I cannot get the __nm_ prefix when
> I elaborate on a minimal problem like you did.
>
> I'll still try to get something this afternoon.
I think I got something:
$ cat > lib.c <<EOF
#include <stdio.h>
int
foo (int a)
{
printf ("a = %d\n", a);
return a;
}
EOF
$cat > asm.as <<EOF
global nothing
;export nothing
nothing:
ret
end
EOF
$ cat > app.c <<EOF
#include <stdio.h>
extern int foo (int);
int
main ()
{
int x = foo (42);
printf ("x = %d\n", x);
nothing();
return 0;
}
EOF
$ gcc -g -c lib.c -o lib.o
$ yasm -fx64 asm.as -o asm.o
$ gcc -shared lib.o ams.o -Wl,--out-implib=lib.dll.a -Wl,--export-all-
symbols -o lib.dll
$ gcc -g -o app app.c -L. -llib
$ ./app
...
<segfault>
Without the export directive (commented above) I get __nm_ prefix and
wrong callq instruction.
With it, the __nm_prefix disappears and the trampoline correctly used.
--
Problem reports: http://cygwin.com/problems.html
FAQ: http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple