When an error occurs during an ELF library API call, the library encodes the error using an error number and stores the error number internally for retrieval by the application at a later point of time. Error numbers may contain an OS supplied error code in addition to an ELF API specific error code. An error number value of zero indicates no error.
Function
elf_errno() is used to retrieve the last error recorded by the ELF library. Invoking this function has the side-effect of resetting the ELF library's recorded error number to zero.
The function
elf_errmsg() returns a null-terminated string with a human readable description of the error specified in argument
error. A zero value for argument
error retrieves the most recent error encountered by the ELF library. An argument value of -1 behaves identically, except that it guarantees a non-NULL return from
elf_errmsg().