*nix Documentation Project
·  Home
 +   man pages
·  Linux HOWTOs
·  FreeBSD Tips
·  *niX Forums

  man pages->HP-UX 11i man pages -> getksym (2)              
Title
Content
Arch
Section
 

Contents


 getksym(2)                                                       getksym(2)




 NAME    [Toc]    [Back]
      getksym - get information for a global kernel symbol

 SYNOPSIS    [Toc]    [Back]
      #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);

    Remarks    [Toc]    [Back]
      getksym is currently implemented as a macro.

 DESCRIPTION    [Toc]    [Back]
      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 a global (STB_GLOBAL or STB_WEAK)
      symbol 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.

      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

      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 followed 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



 Hewlett-Packard Company            - 1 -   HP-UX 11i Version 2: August 2003






 getksym(2)                                                       getksym(2)




      difference between the address given and the value of the symbol
      found.  The space pointed to by symname must be at least MAXSYMNMLEN
      characters long.

 RETURN VALUE    [Toc]    [Back]
      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    [Toc]    [Back]
      getksym fails if one or more of the following are true:

      [ENOMATCH]  The symbol name given is not found, or the value given is
                  not a currently valid address.

      [EINVAL]    modname does not represent a currently loaded module.

      [ENAMETOOLONG]
                  modname is greater than MODMAXNAMELEN characters long, or
                  symname is greater than MAXSYMNMLEN characters long.

 EXAMPLES    [Toc]    [Back]
      The following code sequence and call to getksym() obtains a symbol
      name (and an offset) given an address.

           #include <sys/types.h>
           #include <sys/ksym.h>
           #include <elf.h>
           uint64_t value=0x12345678, info=0;
           char symname[MAXSYMNMLEN];
           /* name will be placed in symname, and offset in info */
           if (getksym(symname, NULL, &value, &info) != 0) {
               perror("getksym");
               return(-1);
           }

      The following code sequence and call to getksym() obtains an address
      given a symbol name.

           #include <sys/types.h>
           #include <sys/ksym.h>
           #include <elf.h>
           uint64_t value=0, info=0;
           /* The address will be placed in value */
           if (getksym("bzero",NULL, &value, &info) != 0) {
               perror("getksym");
               return(-1);
           }

 SEE ALSO    [Toc]    [Back]
      kmem(7).


 Hewlett-Packard Company            - 2 -   HP-UX 11i Version 2: August 2003
[ Back ]
      
      
 Similar pages
Name OS Title
intro Tru64 Introduction to kernel module routines, data structures, and global variables
modpath HP-UX change global search path for dynamically loadable kernel modules
ksyms OpenBSD kernel symbol table device
kmem HP-UX perform I/O on kernel memory based on symbol name.
kvm_nlist OpenBSD retrieve symbol table names from a kernel image
kvm_nlist FreeBSD retrieve symbol table names from a kernel image
kvm_nlist NetBSD retrieve symbol table names from a kernel image
genksyms Linux generate symbol version information
strip HP-UX strip symbol and line number information from an object file
st_pp_find_tag Tru64 access and modify optimization symbol table information in an object file
Copyright © 2004-2005 DeniX Solutions SRL
newsletter delivery service