09-19-2008
7,
0
Join Date: Apr 2008
Last Activity: 19 September 2008, 11:41 PM EDT
Posts: 7
Thanks Given: 0
Thanked 0 Times in 0 Posts
-d_gnu_source
brothers
//open.c
#include<stdio.h>
#include<sys/types.h>
#include<dlfcn.h>
int open(char const *path,int mode,mode_t permission)
{
int (*point)(char const ,int ,mode_t)=NULL;
FILE *out;
int type;
char *actualpath,*lisaoutput;
lisaoutput=getenv("LISA_TRACE");
point= dlsym( RTLD_NEXT,"open" );
type=point(path,mode,permission);
if(type!=-1)
{
printf("%s\n",path);
}
}
i wrote this program .. when i tried to compile i got the following error
lohi@look:~/cl/lisa$ cc -c open.c -ld
open.c: In function ‘open':
open.c:12: warning: assignment makes pointer from integer without a cast
open.c:13: error: ‘RTLD_NEXT' undeclared (first use in this function)
open.c:13: error: (Each undeclared identifier is reported only once
open.c:13: error: for each function it appears in.)
open.c:14: warning: passing argument 1 of ‘point' makes integer from pointer without a cast
then i saw -D_GNU_SOURCE , -Fpic option used by some one .
i dont know why we use it ?
lohi@look:~/cl/lisa$ cc -c open.c -D_GNU_SOURCE -fPIC -ld
open.c: In function ‘open':
open.c:12: warning: assignment makes pointer from integer without a cast
open.c:14: warning: passing argument 1 of ‘point' makes integer from pointer without a cast
gcc.real: -ld: linker input file unused because linking not done
please help me telling why we use it..
searching in google . im not getting an appropriate explanation .
please explain D_GNU_SOURCE option and -fpic option
lohi@look:~/cl/lisa$ gcc -D_GNU_SOURCE -fPIC -c open.c
open.c: In function ‘open':
open.c:12: warning: assignment makes pointer from integer without a cast
open.c:14: warning: passing argument 1 of ‘point' makes integer from pointer without a cast
lohi@look:~/cl/lisa$