Oracle® Solaris 11.2 Linkers and Libraries Guide

Exit Print View

Updated: July 2014

Audit Interface Example

The following simple example creates an audit library that prints the name of each shared object dependency loaded by the dynamic executable date(1).

$ cat audit.c
#include    <link.h>
#include    <stdio.h>

la_version(uint_t version)
        return (LAV_CURRENT);

la_objopen(Link_map *lmp, Lmid_t lmid, uintptr_t *cookie)
        if (lmid == LM_ID_BASE)
                 (void) printf("file: %s loaded\n", lmp->l_name);
        return (0);
$ cc -o -G -K pic -z defs audit.c -lmapmalloc -lc
$ LD_AUDIT=./  date
file: date loaded
file: /lib/ loaded
file: /lib/ loaded
file: /usr/lib/locale/en_US/ loaded
Thur Aug  10 17:03:55 PST 2012