NLIST(3X)NLIST(3X)


NAME
     nlist, nlist64 - Gets entries from name list

SYNOPSIS
     #include <nlist.h>

     "int nlist(const char *filename, struct nlist *nl);"
     "int nlist64(const char *filename, struct nlist64 *nl);"

     "cc ... -lelf"

DESCRIPTION
     This routine is available for o32 ABI programs only.

     NOTE: The nlist function has moved to the ELF library (-lelf).
     Programs that must 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 ELFCLASS32).

     nlist64 works in the same manner as nlist but nlist64 works only on
     64-bit ELF files (ELF header EI_CLASS ELFCLASS64) and uses
     ELF64_ST_TYPE to set the n_type field.

     The ELF symbol table is searched sequentially.

DIAGNOSTICS
     If the file cannot be found, 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 returned;

     On success, 0 is returned.

NOTES
     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.  In releases before
     IRIX6.2, some files had both, but that is no longer true.  Both
     sections have the same format.

SEE ALSO
     elf(4)