NLIST(3) BSD Programmer's Manual NLIST(3)NAMEnlist - retrieve symbol table name list from an executable file
SYNOPSIS
#include <nlist.h>
int
nlist(const char *filename, struct nlist *nl);
DESCRIPTION
The nlist() function looks up names in the symbol table of an executable
binary file, and returns the corresponding values. A value is normally
the address of a global variable in the running image of the executable
binary.
The argument nl should point to an array of nlist structures:
struct nlist {
char *n_name;
unsigned char n_type;
char n_other;
short n_desc;
unsigned long n_value;
};
On input, the n_name fields should be initialized to the names of symbols
that nlist() should look for in the symbol table. All other fields
should be set to 0. The last array element should have its n_name field
set to NULL.
If nlist() returns successfully, then for each array element whose value
was found in the symbol table, the n_type field will be nonzero and the
n_value field will be set to the value of the symbol. For array elements
whose value was not found, the n_type field will be 0. The n_name fields
will not change. The values of the other fields are not defined.
Only global symbols can be matched.
RETURN VALUES
The number of invalid entries is returned if successful; otherwise, the
value returned is -1 and the global variable errno is set to indicate the
error.
SEE ALSOa.out(5), elf(5)HISTORY
An nlist() function appeared in Version 6 AT&T UNIX.
BUGS
The nlist structure is a variant of the symbol table structure used in
a.out(5) executable binary files. When nlist() is used with a file that
isn't a.out(5) format, the n_type field is at best an approximation of
the value that would be expected in an a.out(5) binary, and the n_other
and n_desc fields contain no useful information.
Because some symbol table formats prepend an underscore to names of sym-
bols that derive from names of variables in high-level languages, nlist()
will declare a match if it finds a symbol name that compares equal to the
given name with or without its initial underscore. This `feature' can
sometimes lead to incorrect matches.
4th Berkeley Distribution October 18, 1997 1