HP-UX Reference (11i v2 07/12) - 3 Library Functions N-Z (vol 7)

n
nlist(3E)
Integrity Systems Only
nlist(3E)
NAME
nlist( ), nlist64( ) - get entries from name list
SYNOPSIS
nlist()
cc [flag]... cfile ...
-lelf [library]...
#include <nlist.h>
int nlist(const char *file_name, struct nlist *nl);
nlist64()
cc [flag]... cfile ...
-lelf [library]...
#include <nlist.h>
int nlist64(const char* file_name, struct nlist64 *nl);
Remarks
The use of symbol table type and value information is inherently non-portable. Use of
nlist() or
nlist64() should reduce the effort required to port a program that uses such information, but complete
portability across all HP-UX implementations cannot be expected.
This manpage describes nlist() for Integrity systems. For nlist() and nlist64() on PA-RISC
systems, see nlist(3C).
DESCRIPTION
nlist() and nlist64() have basically the same functionality and they can process SOM or ELF files.
The nlist structure is the same as nlist64 and is used for source code compatibility.
The
nlist/nlist64 function examines the name list in the executable file whose name is pointed to by
file_name, and selectively extracts a list of values and puts them in the array of
nlist/nlist64 struc-
tures pointed to by nl. The array of
nlist/nlist64
structures initially contains only the names of vari-
ables. Once the
nlist/nlist64 function has been called, the variable names are augmented with sym-
bol information. The list is terminated by a null name, which consists of a null string in the variable-name
position of the structure. The name list of the file is searched for each variable name. If the name is found,
the symbol’s type, scope, and value in the file is inserted into the name list structure. If the file searched is
an ELF file, the section index is also inserted. For SOM files, the subspace index is inserted. The symbol
value is 64-bit. If the file searched is a SOM le, then the value field is zero padded. If the name is not
found, the elds in the name list structure are set to 0. The structures
nlist and
nlist64 are defined
in the include file
<nlist.h>. See a.out(4) and nlist(4) for further description of the symbol table struc-
ture.
The file must have the organization and symbol table described for an a.out file in a.out(4). The informa-
tion is extracted from the symbol table used by the linker, ld(1).
On machines that have such a file, this subroutine is useful for examining the system name list kept in file
/stand/vmunix. In this way programs can obtain system addresses that are up to date.
RETURN VALUE
All
nlist structure fields are set to 0 if the file cannot be found or if it is not a valid object file containing
a linker symbol table.
nlist() returns -1 upon error; otherwise it returns 0.
WARNINGS
The <nlist.h> header file is automatically included by <a.out.h> for compatibility. However, includ-
ing
<a.out.h> is discouraged if the only information needed from <a.out.h> is for use by nlist().
If <a.out.h> is included, the line #undef n_name may need to follow it.
SEE ALSO
a.out(4), elf(3E), nlist(4).
STANDARDS CONFORMANCE
nlist(): SVID2, SVID3
112 Hewlett-Packard Company 1 HP-UX 11i Version 2: December 2007 Update