{
    "mode": "man",
    "parameter": "rtld-audit",
    "section": "7",
    "url": "https://www.chedong.com/phpMan.php/man/rtld-audit/7/json",
    "generated": "2026-05-30T06:10:35Z",
    "synopsis": "#define GNUSOURCE             /* See featuretestmacros(7) */",
    "sections": {
        "NAME": {
            "content": "rtld-audit - auditing API for the dynamic linker\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "#define GNUSOURCE             /* See featuretestmacros(7) */",
            "subsections": [
                {
                    "name": "#include <link.h>",
                    "content": ""
                }
            ]
        },
        "DESCRIPTION": {
            "content": "The  GNU dynamic linker (run-time linker) provides an auditing API that allows an application\nto be notified when various dynamic linking events occur.  This API is very  similar  to  the\nauditing interface provided by the Solaris run-time linker.  The necessary constants and pro‐\ntotypes are defined by including <link.h>.\n\nTo use this interface, the programmer creates a shared library that implements a standard set\nof  function  names.   Not all of the functions need to be implemented: in most cases, if the\nprogrammer is not interested in a particular class of auditing event, then no  implementation\nneeds to be provided for the corresponding auditing function.\n\nTo  employ  the auditing interface, the environment variable LDAUDIT must be defined to con‐\ntain a colon-separated list of shared libraries, each of which can implement (parts  of)  the\nauditing  API.  When an auditable event occurs, the corresponding function is invoked in each\nlibrary, in the order that the libraries are listed.\n\nlaversion()\n\nunsigned int laversion(unsigned int version);\n\nThis is the only function that must be defined by an auditing library: it performs  the  ini‐\ntial handshake between the dynamic linker and the auditing library.  When invoking this func‐\ntion, the dynamic linker passes, in version, the highest version of  the  auditing  interface\nthat the linker supports.\n\nA  typical implementation of this function simply returns the constant LAVCURRENT, which in‐\ndicates the version of <link.h> that was used to build the  audit  module.   If  the  dynamic\nlinker  does not support this version of the audit interface, it will refuse to activate this\naudit module.  If the function returns zero, the dynamic linker also does not  activate  this\naudit module.\n\nIn  order  to  enable backwards compatibility with older dynamic linkers, an audit module can\nexamine the version argument and return an earlier version  than  LAVCURRENT,  assuming  the\nmodule can adjust its implementation to match the requirements of the previous version of the\naudit interface.  The laversion function should not return the value of version without fur‐\nther checks because it could correspond to an interface that does not match the <link.h> def‐\ninitions used to build the audit module.\n\nlaobjsearch()\n\nchar *laobjsearch(const char *name, uintptrt *cookie,\nunsigned int flag);\n\nThe dynamic linker invokes this function to inform the auditing library that it is  about  to\nsearch  for  a  shared  object.   The name argument is the filename or pathname that is to be\nsearched for.  cookie identifies the shared object that initiated the search.  flag is set to\none of the following values:\n\nLASERORIG      This  is the original name that is being searched for.  Typically, this name\ncomes from an ELF DTNEEDED entry, or is  the  filename  argument  given  to\ndlopen(3).\n\nLASERLIBPATH   name was created using a directory specified in LDLIBRARYPATH.\n\nLASERRUNPATH   name  was  created using a directory specified in an ELF DTRPATH or DTRUN‐‐\nPATH list.\n\nLASERCONFIG    name was found via the ldconfig(8) cache (/etc/ld.so.cache).\n\nLASERDEFAULT   name was found via a search of one of the default directories.\n\nLASERSECURE    name is specific to a secure object (unused on Linux).\n\nAs its function result, laobjsearch() returns the pathname that the  dynamic  linker  should\nuse  for  further processing.  If NULL is returned, then this pathname is ignored for further\nprocessing.  If this audit library simply intends to monitor search paths, then  name  should\nbe returned.\n\nlaactivity()\n\nvoid laactivity( uintptrt *cookie, unsigned int flag);\n\nThe  dynamic linker calls this function to inform the auditing library that link-map activity\nis occurring.  cookie identifies the object at the head of the link map.   When  the  dynamic\nlinker invokes this function, flag is set to one of the following values:\n\nLAACTADD         New objects are being added to the link map.\n\nLAACTDELETE      Objects are being removed from the link map.\n\nLAACTCONSISTENT  Link-map activity has been completed: the map is once again consistent.\n\nlaobjopen()\n\nunsigned int laobjopen(struct linkmap *map, Lmidt lmid,\nuintptrt *cookie);\n\nThe  dynamic linker calls this function when a new shared object is loaded.  The map argument\nis a pointer to a link-map structure that describes the object.  The lmid field  has  one  of\nthe following values\n\nLMIDBASE       Link map is part of the initial namespace.\n\nLMIDNEWLM      Link map is part of a new namespace requested via dlmopen(3).\n\ncookie  is  a  pointer to an identifier for this object.  The identifier is provided to later\ncalls to functions in the auditing library in order to identify this object.  This identifier\nis initialized to point to object's link map, but the audit library can change the identifier\nto some other value that it may prefer to use to identify the object.\n\nAs its return value, laobjopen() returns a bit mask created by ORing zero  or  more  of  the\nfollowing  constants,  which allow the auditing library to select the objects to be monitored\nby lasymbind*():\n\nLAFLGBINDTO    Audit symbol bindings to this object.\n\nLAFLGBINDFROM  Audit symbol bindings from this object.\n\nA return value of 0 from laobjopen() indicates that no symbol bindings should be audited for\nthis object.\n\nlaobjclose()\n\nunsigned int laobjclose(uintptrt *cookie);\n\nThe  dynamic linker invokes this function after any finalization code for the object has been\nexecuted, before the object is unloaded.  The cookie argument is the identifier obtained from\na previous invocation of laobjopen().\n\nIn the current implementation, the value returned by laobjclose() is ignored.\n\nlapreinit()\n\nvoid lapreinit(uintptrt *cookie);\n\nThe  dynamic  linker  invokes this function after all shared objects have been loaded, before\ncontrol is passed to the application (i.e., before calling main()).   Note  that  main()  may\nstill later dynamically load objects using dlopen(3).\n\nlasymbind*()\n\nuintptrt lasymbind32(Elf32Sym *sym, unsigned int ndx,\nuintptrt *refcook, uintptrt *defcook,\nunsigned int *flags, const char *symname);\nuintptrt lasymbind64(Elf64Sym *sym, unsigned int ndx,\nuintptrt *refcook, uintptrt *defcook,\nunsigned int *flags, const char *symname);\n\nThe  dynamic  linker  invokes one of these functions when a symbol binding occurs between two\nshared objects that have been marked for auditing notification by laobjopen().  The  lasym‐‐\nbind32() function is employed on 32-bit platforms; the lasymbind64() function is employed on\n64-bit platforms.\n\nThe sym argument is a pointer to a structure that provides information about the symbol being\nbound.   The  structure  definition is shown in <elf.h>.  Among the fields of this structure,\nstvalue indicates the address to which the symbol is bound.\n\nThe ndx argument gives the index of the symbol in the symbol table of the  bound  shared  ob‐\nject.\n\nThe  refcook  argument identifies the shared object that is making the symbol reference; this\nis the  same  identifier  that  is  provided  to  the  laobjopen()  function  that  returned\nLAFLGBINDFROM.   The  defcook argument identifies the shared object that defines the refer‐\nenced symbol; this is the same identifier that is provided to the laobjopen() function  that\nreturned LAFLGBINDTO.\n\nThe symname argument points a string containing the name of the symbol.\n\nThe  flags  argument is a bit mask that both provides information about the symbol and can be\nused to modify further auditing of this PLT (Procedure Linkage  Table)  entry.   The  dynamic\nlinker may supply the following bit values in this argument:\n\nLASYMBDLSYM         The binding resulted from a call to dlsym(3).\n\nLASYMBALTVALUE      A previous lasymbind*() call returned an alternate value for this sym‐\nbol.\n\nBy default, if the auditing library implements lapltenter() and lapltexit() functions  (see\nbelow),  then these functions are invoked, after lasymbind(), for PLT entries, each time the\nsymbol is referenced.  The following flags can be ORed into *flags to change this default be‐\nhavior:\n\nLASYMBNOPLTENTER    Don't call lapltenter() for this symbol.\n\nLASYMBNOPLTEXIT     Don't call lapltexit() for this symbol.\n\nThe  return value of lasymbind32() and lasymbind64() is the address to which control should\nbe passed after the function returns.  If the auditing library is  simply  monitoring  symbol\nbindings,  then it should return sym->stvalue.  A different value may be returned if the li‐\nbrary wishes to direct control to an alternate location.\n\nlapltenter()\nThe precise name and argument types for this function depend on the hardware platform.   (The\nappropriate definition is supplied by <link.h>.)  Here is the definition for x86-32:\n\nElf32Addr lai86gnupltenter(Elf32Sym *sym, unsigned int ndx,\nuintptrt *refcook, uintptrt *defcook,\nLai86regs *regs, unsigned int *flags,\nconst char *symname, long *framesizep);\n\nThis  function  is invoked just before a PLT entry is called, between two shared objects that\nhave been marked for binding notification.\n\nThe sym, ndx, refcook, defcook, and symname are as for lasymbind*().\n\nThe regs argument points to a structure (defined in <link.h>) containing the values of regis‐\nters to be used for the call to this PLT entry.\n\nThe  flags  argument  points to a bit mask that conveys information about, and can be used to\nmodify subsequent auditing of, this PLT entry, as for lasymbind*().\n\nThe framesizep argument points to a long int buffer that can be used to  explicitly  set  the\nframe  size  used for the call to this PLT entry.  If different lapltenter() invocations for\nthis symbol return different values, then the maximum returned value  is  used.   The  lapl‐‐\ntexit() function is called only if this buffer is explicitly set to a suitable value.\n\nThe return value of lapltenter() is as for lasymbind*().\n\nlapltexit()\nThe  precise name and argument types for this function depend on the hardware platform.  (The\nappropriate definition is supplied by <link.h>.)  Here is the definition for x86-32:\n\nunsigned int lai86gnupltexit(Elf32Sym *sym, unsigned int ndx,\nuintptrt *refcook, uintptrt *defcook,\nconst Lai86regs *inregs, Lai86retval *outregs,\nconst char *symname);\n\nThis function is called when a PLT entry, made between two  shared  objects  that  have  been\nmarked for binding notification, returns.  The function is called just before control returns\nto the caller of the PLT entry.\n\nThe sym, ndx, refcook, defcook, and symname are as for lasymbind*().\n\nThe inregs argument points to a structure (defined in <link.h>) containing the values of reg‐\nisters  used for the call to this PLT entry.  The outregs argument points to a structure (de‐\nfined in <link.h>) containing return values for the call to this PLT entry.  These values can\nbe modified by the caller, and the changes will be visible to the caller of the PLT entry.\n\nIn the current GNU implementation, the return value of lapltexit() is ignored.\n",
            "subsections": []
        },
        "CONFORMING TO": {
            "content": "This API is nonstandard, but very similar to the Solaris API, described in the Solaris Linker\nand Libraries Guide, in the chapter Runtime Linker Auditing Interface.\n",
            "subsections": []
        },
        "NOTES": {
            "content": "Note the following differences from the Solaris dynamic linker auditing API:\n\n*  The Solaris laobjfilter() interface is not supported by the GNU implementation.\n\n*  The Solaris lasymbind32() and lapltexit() functions do not provide a symname argument.\n\n*  The Solaris lapltexit() function does not provide inregs and outregs arguments (but  does\nprovide a retval argument with the function return value).\n",
            "subsections": []
        },
        "BUGS": {
            "content": "In  glibc  versions up to and include 2.9, specifying more than one audit library in LDAUDIT\nresults in a run-time crash.  This is reportedly fixed in glibc 2.10.\n",
            "subsections": []
        },
        "EXAMPLES": {
            "content": "#include <link.h>\n#include <stdio.h>\n\nunsigned int\nlaversion(unsigned int version)\n{\nprintf(\"laversion(): version = %u; LAVCURRENT = %u\\n\",\nversion, LAVCURRENT);\n\nreturn LAVCURRENT;\n}\n\nchar *\nlaobjsearch(const char *name, uintptrt *cookie, unsigned int flag)\n{\nprintf(\"laobjsearch(): name = %s; cookie = %p\", name, cookie);\nprintf(\"; flag = %s\\n\",\n(flag == LASERORIG) ?    \"LASERORIG\" :\n(flag == LASERLIBPATH) ? \"LASERLIBPATH\" :\n(flag == LASERRUNPATH) ? \"LASERRUNPATH\" :\n(flag == LASERDEFAULT) ? \"LASERDEFAULT\" :\n(flag == LASERCONFIG) ?  \"LASERCONFIG\" :\n(flag == LASERSECURE) ?  \"LASERSECURE\" :\n\"???\");\n\nreturn name;\n}\n\nvoid\nlaactivity (uintptrt *cookie, unsigned int flag)\n{\nprintf(\"laactivity(): cookie = %p; flag = %s\\n\", cookie,\n(flag == LAACTCONSISTENT) ? \"LAACTCONSISTENT\" :\n(flag == LAACTADD) ?        \"LAACTADD\" :\n(flag == LAACTDELETE) ?     \"LAACTDELETE\" :\n\"???\");\n}\n\nunsigned int\nlaobjopen(struct linkmap *map, Lmidt lmid, uintptrt *cookie)\n{\nprintf(\"laobjopen(): loading \\\"%s\\\"; lmid = %s; cookie=%p\\n\",\nmap->lname,\n(lmid == LMIDBASE) ?  \"LMIDBASE\" :\n(lmid == LMIDNEWLM) ? \"LMIDNEWLM\" :\n\"???\",\ncookie);\n\nreturn LAFLGBINDTO | LAFLGBINDFROM;\n}\n\nunsigned int\nlaobjclose (uintptrt *cookie)\n{\nprintf(\"laobjclose(): %p\\n\", cookie);\n\nreturn 0;\n}\n\nvoid\nlapreinit(uintptrt *cookie)\n{\nprintf(\"lapreinit(): %p\\n\", cookie);\n}\n\nuintptrt\nlasymbind32(Elf32Sym *sym, unsigned int ndx, uintptrt *refcook,\nuintptrt *defcook, unsigned int *flags, const char *symname)\n{\nprintf(\"lasymbind32(): symname = %s; sym->stvalue = %p\\n\",\nsymname, sym->stvalue);\nprintf(\"        ndx = %u; flags = %#x\", ndx, *flags);\nprintf(\"; refcook = %p; defcook = %p\\n\", refcook, defcook);\n\nreturn sym->stvalue;\n}\n\nuintptrt\nlasymbind64(Elf64Sym *sym, unsigned int ndx, uintptrt *refcook,\nuintptrt *defcook, unsigned int *flags, const char *symname)\n{\nprintf(\"lasymbind64(): symname = %s; sym->stvalue = %p\\n\",\nsymname, sym->stvalue);\nprintf(\"        ndx = %u; flags = %#x\", ndx, *flags);\nprintf(\"; refcook = %p; defcook = %p\\n\", refcook, defcook);\n\nreturn sym->stvalue;\n}\n\nElf32Addr\nlai86gnupltenter(Elf32Sym *sym, unsigned int ndx,\nuintptrt *refcook, uintptrt *defcook, Lai86regs *regs,\nunsigned int *flags, const char *symname, long *framesizep)\n{\nprintf(\"lai86gnupltenter(): %s (%p)\\n\", symname, sym->stvalue);\n\nreturn sym->stvalue;\n}\n",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "ldd(1), dlopen(3), ld.so(8), ldconfig(8)\n",
            "subsections": []
        },
        "COLOPHON": {
            "content": "This page is part of release 5.10 of the Linux  man-pages  project.   A  description  of  the\nproject,  information about reporting bugs, and the latest version of this page, can be found\nat https://www.kernel.org/doc/man-pages/.\n\n\n\nLinux                                        2020-11-01                                RTLD-AUDIT(7)",
            "subsections": []
        }
    },
    "summary": "rtld-audit - auditing API for the dynamic linker",
    "flags": [],
    "examples": [
        "#include <link.h>",
        "#include <stdio.h>",
        "unsigned int",
        "laversion(unsigned int version)",
        "printf(\"laversion(): version = %u; LAVCURRENT = %u\\n\",",
        "version, LAVCURRENT);",
        "return LAVCURRENT;",
        "char *",
        "laobjsearch(const char *name, uintptrt *cookie, unsigned int flag)",
        "printf(\"laobjsearch(): name = %s; cookie = %p\", name, cookie);",
        "printf(\"; flag = %s\\n\",",
        "(flag == LASERORIG) ?    \"LASERORIG\" :",
        "(flag == LASERLIBPATH) ? \"LASERLIBPATH\" :",
        "(flag == LASERRUNPATH) ? \"LASERRUNPATH\" :",
        "(flag == LASERDEFAULT) ? \"LASERDEFAULT\" :",
        "(flag == LASERCONFIG) ?  \"LASERCONFIG\" :",
        "(flag == LASERSECURE) ?  \"LASERSECURE\" :",
        "\"???\");",
        "return name;",
        "void",
        "laactivity (uintptrt *cookie, unsigned int flag)",
        "printf(\"laactivity(): cookie = %p; flag = %s\\n\", cookie,",
        "(flag == LAACTCONSISTENT) ? \"LAACTCONSISTENT\" :",
        "(flag == LAACTADD) ?        \"LAACTADD\" :",
        "(flag == LAACTDELETE) ?     \"LAACTDELETE\" :",
        "\"???\");",
        "unsigned int",
        "laobjopen(struct linkmap *map, Lmidt lmid, uintptrt *cookie)",
        "printf(\"laobjopen(): loading \\\"%s\\\"; lmid = %s; cookie=%p\\n\",",
        "map->lname,",
        "(lmid == LMIDBASE) ?  \"LMIDBASE\" :",
        "(lmid == LMIDNEWLM) ? \"LMIDNEWLM\" :",
        "\"???\",",
        "cookie);",
        "return LAFLGBINDTO | LAFLGBINDFROM;",
        "unsigned int",
        "laobjclose (uintptrt *cookie)",
        "printf(\"laobjclose(): %p\\n\", cookie);",
        "return 0;",
        "void",
        "lapreinit(uintptrt *cookie)",
        "printf(\"lapreinit(): %p\\n\", cookie);",
        "uintptrt",
        "lasymbind32(Elf32Sym *sym, unsigned int ndx, uintptrt *refcook,",
        "uintptrt *defcook, unsigned int *flags, const char *symname)",
        "printf(\"lasymbind32(): symname = %s; sym->stvalue = %p\\n\",",
        "symname, sym->stvalue);",
        "printf(\"        ndx = %u; flags = %#x\", ndx, *flags);",
        "printf(\"; refcook = %p; defcook = %p\\n\", refcook, defcook);",
        "return sym->stvalue;",
        "uintptrt",
        "lasymbind64(Elf64Sym *sym, unsigned int ndx, uintptrt *refcook,",
        "uintptrt *defcook, unsigned int *flags, const char *symname)",
        "printf(\"lasymbind64(): symname = %s; sym->stvalue = %p\\n\",",
        "symname, sym->stvalue);",
        "printf(\"        ndx = %u; flags = %#x\", ndx, *flags);",
        "printf(\"; refcook = %p; defcook = %p\\n\", refcook, defcook);",
        "return sym->stvalue;",
        "Elf32Addr",
        "lai86gnupltenter(Elf32Sym *sym, unsigned int ndx,",
        "uintptrt *refcook, uintptrt *defcook, Lai86regs *regs,",
        "unsigned int *flags, const char *symname, long *framesizep)",
        "printf(\"lai86gnupltenter(): %s (%p)\\n\", symname, sym->stvalue);",
        "return sym->stvalue;"
    ],
    "see_also": [
        {
            "name": "ldd",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/ldd/1/json"
        },
        {
            "name": "dlopen",
            "section": "3",
            "url": "https://www.chedong.com/phpMan.php/man/dlopen/3/json"
        },
        {
            "name": "ld.so",
            "section": "8",
            "url": "https://www.chedong.com/phpMan.php/man/ld.so/8/json"
        },
        {
            "name": "ldconfig",
            "section": "8",
            "url": "https://www.chedong.com/phpMan.php/man/ldconfig/8/json"
        }
    ]
}