View Single Post

   
  #1 (permalink)  
Old 01-05-2008, 11:57 AM
shankha
 
Posts: n/a
Default Uncharacteristic behavior of system call cs

#include <stdio.h>
#include <stdlib.h>
#include <dlfcn.h>
#include <errno.h>

void foo(void * handle,const char *ptr)
{
void * symptr;
if (NULL == (symptr = dlsym(handle, ptr)))
{
if ( 0 == errno)
fprintf(stderr, "symbol %s not found\n", ptr);
else
perror(dlerror());
}
else
{
printf("SYSTEM CALL : %s 0x%x\n", ptr, symptr);
printf(" THE ADDRESS TO WHICH WE JUMP TO
0x%x\n",*(int *)symptr);
printf(" TOC VALUE(r2)
0x%x\n\n",*(int *)((int)symptr + 4));
}
}

int main()
{
void * handle;
if ( NULL == (handle = dlopen("/unix",RTLD_NOW )))
{
perror(dlerror());
exit(1);
}
foo(handle,"cs");
foo(handle,"_getpid");
foo(handle,"mkdir");
foo(handle,"__unload");
foo(handle,"thread_waitlock_");
foo(handle,"skeytune");
foo(handle,"kfork");
if ( 0 != (dlclose(handle))) {
perror(dlerror());
exit(1);
}

return 0;
}


if you see the output on AIX 5.1 5.2 5.3 the value which we get for thr
field THE ADDRESS TO WHICH WE JUMP TO is same for all other system
calls except cs. If we do a dump -Tv -X64 /unix and grep for all the
system calls the Scn field shows .data but for cs it shows .text. Can
any one please explain this uncharacteristic behaviour of cs. I am not
sure wether cs is a system call or not.

Reply With Quote