nlist, nlist64 - get entries from name list
int nlist(const char *filename, struct nlist *nl);
int nlist64(const char *filename, struct nlist64 *nl);
cc ... -lelf
NOTE: The nlist function has moved to the Elf library (-lelf). Programs
that need to use nlist must be linked with the -lelf option (in IRIX4,
nlist was in -lmld).
nlist examines a section with Elf section type SHT_SYMTAB or SHT_DYNSYM
(whichever comes first in the Elf file) in the given Elf file and
selectively extracts a list of values. The name list consists of an
array of structures containing names, types and values. The list is
terminated with a structure containing a NULL (a NULL pointer) n_name or
zero-length n_name (the first character of the memory pointed to is 0).
Each name is looked up in the name list of the file. If the name is
found, the n_value field is set to the value of the symbol-table entry's
st_value and the n_type field is set to the value of the symbol-table
entry's ELF32_ST_TYPE. If the name is not found, n_value and n_type are
set to 0. nlist works on 32-bit Elf files only (Elf header EI_CLASS
nlist64 works in the same manner as nlist but nlist64 works only on 64-
bit Elf files (Elf header EI_CLASS ELFCLASS64) and and uses
ELF64_ST_TYPE to set the n_type field.
The Elf symbol table is searched sequentially.
If the file cannot be found or if it does not contain a valid Elf symbol
table or if the object is not the right class (ELFCLASS32 for nlist(),
ELFCLASS64 for nlist64()), or if there is some other error, -1 is
On success, 0 is returned.
Standard UNIX System V Release 4 documentation is ambiguous as to whether
the n_name list terminator field value should be a NULL pointer or a
non-NULL pointer pointing to a string of length 0. Either will work as a
terminator with this library.
In general there is only one symtab section of type SHT_SYMTAB or one
symtab section of type SHT_DYNSYM in a file. Not both. In releases
before IRIX6.2 some files had both, but that is no longer true. Both
sections have the same format.
PPPPaaaaggggeeee 2222 [ Back ]