This is the mail archive of the cygwin mailing list for the Cygwin 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: problem with dlsym to fetch address of some functions


2014-09-23 16:40 GMT-03:00 Marco Atzeri <marco.atzeri@gmail.com>:
> On 23/09/2014 20:43, Paulo CÃsar Pereira de Andrade wrote:
>>
>>    Hi,
>>
>>    Forgive me if this is expected. I am probably abusing dlsym
>> behavior on other systems.
>
>
> It will be much more clear if you

  Sorry for not clear initial problem description.

> 1) produce a simple small complete test case,

$ cat x.c
extern int sprintf(char*,char*, ...);
extern int puts(char*);
extern void *dlsym(void*, char*);
char buff[128];
int main(void) {
int (*fn)(char*,char*,...);
sprintf(buff, "%.1f", 1.0);
puts(buff);
fn = dlsym((void*)0, "sprintf");
(*fn)(buff, "%.1f", 1.0);
puts(buff);
return 0;
}

$ gcc -O0 -g3 x.c

> 2) explain the outcome you obtain (or not)

$ ./a.exe
1.0
f

> 3) explain the result you are expecting.

The expected result would be:

$ ./a.exe
1.0
1.0

> I had difficulties to understand what you are asking us.
>
> Marco

Thanks,
Paulo

> --
> 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

--
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


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