Translates names to addresses in the running system.
#include <nlist.h>
int knlist( NList, NumberOfElements, Size)
struct nlist *NList;
int NumberOfElements;
int Size;
The knlist subroutine allows a program to look up the addresses of symbols exported by the kernel and kernel extensions.
The n_name field in the nlist structure specifies the name of a symbol for which the address is requested. If the symbol is found, its address is saved in the n_value field, and the remaining fields are not modified. If the symbol is not found, all fields, other than n_name, are set to 0.
rc = knlist((struct nlist *)Nlist64,
NumberOfElements,
sizeof(structure nlist64));
The nlist and nlist64 structures include the following fields:
Item | Description |
---|---|
char *n_name | Specifies the name of the symbol for which the address is to be retrieved. |
long n_value | The address of the symbol, filled in by the knlist subroutine. This field is included in the nlist structure. |
long long n_value | The address of the symbol, filled in by the knlist subroutine. This field is included in the nlist64 structure. |
#undef n_name
#undef n_name
before accessing the n_name field
in the netent structure. If you need to access the n_name field
in a syment or nlist structure after undefining it,
redefine the n_name field with: #define n_name _n._n_name
Item | Description |
---|---|
NList | Points to an array of nlist or nlist64 structures. |
NumberOfElements | Specifies the number of structures in the array of nlist or nlist64 structures. |
Size | Specifies the size of each structure. The only allowed values are sizeof(struct nlist) or sizeof(struct nlist64). |
Upon successful completion, the knlist subroutine returns a value of 0. Otherwise, a value of -1 is returned, and the errno variable is set to indicate the error.
The knlist subroutine fails when one of the following is true:
Item | Description |
---|---|
EINVAL | The NumberOfElements parameters is less than 1 or the Size parameter is neither sizeof(struct nlist) nor sizeof(struct nlist64). |
EFAULT | The NList parameter is not a valid address. One or more symbols in the array specified by the Nlist parameter were not found. The address of one of the symbols does not fit in the n_value field. This is only possible if the caller is a 32-bit program and the Size parameter is sizeof(struct nlist)). |