getksym.2 (2010 09)

g
getksym(2) getksym(2)
NAME
getksym() - get information for local and global kernel symbols
SYNOPSIS
#include <sys/types.h>
#include <sys/ksym.h>
#include <elf.h>
#include <elf_parisc.h> /* For STT_PARISC_MILLI on PA-RISC */
int getksym(char * symname, char * modname, uint64_t *value,
uint64_t *info);
DESCRIPTION
There are two ways that getksym() can be used to retrieve kernel symbol information. As detailed
below, if symname is provided and value is set to zero,
getksym() attempts to retrieve the value of the
symbol; if a non-zero value is provided, the associated symbol name is retrieved.
getksym(), given a symname, looks for global (
STB_GLOBAL or STB_WEAK) and local (STB_LOCAL)
symbols of that name in the symbol table of the static kernel and all currently loaded kernel modules. If
it finds a match,
getksym() returns the value associated with that symbol (typically its address) in the
space pointed to by value, and the type of that symbol in the space pointed to by info .
NOTE: If there are two symbols (a local and a global symbol) with the same name,
getksym()
returns
the first symbol that it finds with that name, which will be the local symbol.
The types returned are:
STT_NOTYPE unknown type
STT_FUNC text symbol (typically function)
STT_PARISC_MILLI PA-RISC millicode function (PA-RISC only)
STT_OBJECT data symbol
STT_SECTION section symbol
The symbol name can be no more than MAXSYMNMLEN characters. If modname is set to the name
(basename only) of a dynamically loaded module, then the search for the symbol name will only be in that
module. If modname is NULL, then the search order for the symbol name will be the static kernel fol-
lowed by each of the currently loaded modules in the order in which they were loaded. The module name
can be no more than MODMAXNAMELEN
characters.
If both a non-zero value and a symname are provided, the behavior of
getksym() is undefined. If a zero
value and an empty or NULL symname is provided, the behavior of getksym() is undefined.
If getksym() is given a valid non-zero address in the statically configured kernel or one of the currently
loaded modules in the space pointed to by value , it will return, in the space pointed to by symname , the
name of the symbol whose value is the closest one less than or equal to the given value and, in space
pointed to by info , the difference between the address given and the value of the symbol found.
NOTE: If two symbols (an
STT_SECTION symbol and an STT_FUNC/STT_OBJECT symbol) have the
same address, getksym() returns the STT_FUNC/STT_OBJECT symbol.
The space pointed to by symname must be at least MAXSYMNMLEN characters long.
RETURN VALUE
getksym() returns 0 upon successful completion. If an error occurs, a value of -1 is returned and
errno is set to indicate the error.
ERRORS
getksym() fails if one or more of the following are true:
[EINVAL]
modname does not represent a currently loaded module.
HP-UX 11i Version 3: September 2010 1 Hewlett-Packard Company 1

Summary of content (2 pages)