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.

.



Relevant Pages

  • Re: (void**)&ppval
    ... a sort of "generic data pointer type". ... returned from mallochas type "void *", so that it can point to ... void *tmp; ... T *ptr; ...
    (comp.lang.c)
  • Re: warning C4238 : cast reference in void*
    ... void* foo ... why void* ptr = &foo2give this warning? ... Do you understand what rvalue and lvalue mean? ...
    (microsoft.public.vc.language)
  • Re: Why can I not alloc memory in called function?
    ... Note the "output parameter" in this call. ... void malloc ... In this version, size is still an input parameter, but *ptr is an output ...
    (comp.lang.c)
  • Re: incrementing void *
    ... void *ptr; ... Which of the following is the correct way to increment the variable ... Its a void * pointer. ... then they want you to treat ptr as if it were a myStruct * ...
    (comp.lang.c)
  • [RFC] mm: generic adaptive large memory allocation APIs
    ... kvmallocwill try to allocate physically contiguous memory first, ... void *kvmalloc ... if (ptr!= NULL) ... static int kvfree_work_struct_init ...
    (Linux-Kernel)