knlist Subroutine
Purpose
Translates names to addresses in the running system.
Syntax
#include <nlist.h>
Description
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
- If both the nlist.h and netdb.h files are to be included, the netdb.h file should be included before the nlist.h file in order to avoid a conflict with the n_name structure member. Likewise, if both the a.out.h and netdb.h files are to be included, the netdb.h file should be included before the a.out.h file to avoid a conflict with the n_name structure.
- If the netdb.h file
and either the nlist.h or syms.h file are included,
the n_name field will be defined as _n._n_name.
This definition allows you to access the n_name field in
the nlist or syment structure. If you need to access
the n_name field in the netent structure, undefine
the n_name field by entering:
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:#undef n_name
#define n_name _n._n_name
Parameters
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) . |
Return Values
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.
Error Codes
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 |