what's wrong with nlist
I'm trying to get the address of kernel symbols using nlist() function and this is not working on my machine (Solaris 10, 06/01, SPARC/64 bit):
I used the following program to test nlist:
[code]#include <stdio.h>
#include <stdlib.h>
#include <nlist.h>
#include <string.h>
int main()
{
struct nlist *knl = NULL;
int result;
knl = calloc(10, sizeof(struct nlist));
knl[0].n_name = strdup("spec_vnodeops");
result = nlist("/dev/ksyms", knl);
if ( result < 0 )
{
perror("Could not read namelist");
}
printf("Status %d\n", result);
}
[/code]
I compile and execute the code:
[code]
$ make
cc -c -o nlist.o -gnlist.c
cc -o knl -g-lelf nlist.o
$ ./knl
Could not read namelist: Error 0
Status -1
[/code]
But nlist() returns an error code. The problem is that it does not set errno or any other environment variable.
Is there a simple example on the net about how to use nlist to get kernel symbol address?

