man pages section 3: Extended Library Functions, Volume 1

Exit Print View

Updated: July 2014
 
 

nlist(3ELF)

Name

nlist - get entries from name list

Synopsis

cc [ flag... ] file ... –lelf [ library ... ]
#include <nlist.h>

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

Description

nlist() examines the name list in the executable file whose name is pointed to by filename, and selectively extracts a list of values and puts them in the array of nlist() structures pointed to by nl. The name list nl consists of an array of structures containing names of variables, types, and values. The list is terminated with a null name, that is, a null string is in the name position of the structure. Each variable name is looked up in the name list of the file. If the name is found, the type, value, storage class, and section number of the name are inserted in the other fields. The type field may be set to 0 if the file was not compiled with the –g option to cc.

nlist() will always return the information for an external symbol of a given name if the name exists in the file. If an external symbol does not exist, and there is more than one symbol with the specified name in the file (such as static symbols defined in separate files), the values returned will be for the last occurrence of that name in the file. If the name is not found, all fields in the structure except n_name are set to 0.

This function is useful for examining the system name list kept in the file /dev/ksyms. In this way programs can obtain system addresses that are up to date.

Return Values

All value entries are set to 0 if the file cannot be read or if it does not contain a valid name list.

nlist() returns 0 on success, −1 on error.

Attributes

See attributes(5) for descriptions of the following attributes:

ATTRIBUTE TYPE
ATTRIBUTE VALUE
Interface Stability
Committed
MT-Level
Safe

See Also

elf(3ELF), kvm_nlist(3KVM) , kvm_open(3KVM), libelf(3LIB) , a.out(4), attributes(5) , ksyms(7D), mem(7D)