xref: /freebsd/contrib/elftoolchain/libelf/elf_errmsg.3 (revision ae500c1ff8974130f7f2692772cf288b90349e0d)
12de3b87aSKai Wang.\" Copyright (c) 2006,2008 Joseph Koshy.  All rights reserved.
22de3b87aSKai Wang.\"
32de3b87aSKai Wang.\" Redistribution and use in source and binary forms, with or without
42de3b87aSKai Wang.\" modification, are permitted provided that the following conditions
52de3b87aSKai Wang.\" are met:
62de3b87aSKai Wang.\" 1. Redistributions of source code must retain the above copyright
72de3b87aSKai Wang.\"    notice, this list of conditions and the following disclaimer.
82de3b87aSKai Wang.\" 2. Redistributions in binary form must reproduce the above copyright
92de3b87aSKai Wang.\"    notice, this list of conditions and the following disclaimer in the
102de3b87aSKai Wang.\"    documentation and/or other materials provided with the distribution.
112de3b87aSKai Wang.\"
122de3b87aSKai Wang.\" This software is provided by Joseph Koshy ``as is'' and
132de3b87aSKai Wang.\" any express or implied warranties, including, but not limited to, the
142de3b87aSKai Wang.\" implied warranties of merchantability and fitness for a particular purpose
152de3b87aSKai Wang.\" are disclaimed.  in no event shall Joseph Koshy be liable
162de3b87aSKai Wang.\" for any direct, indirect, incidental, special, exemplary, or consequential
172de3b87aSKai Wang.\" damages (including, but not limited to, procurement of substitute goods
182de3b87aSKai Wang.\" or services; loss of use, data, or profits; or business interruption)
192de3b87aSKai Wang.\" however caused and on any theory of liability, whether in contract, strict
202de3b87aSKai Wang.\" liability, or tort (including negligence or otherwise) arising in any way
212de3b87aSKai Wang.\" out of the use of this software, even if advised of the possibility of
222de3b87aSKai Wang.\" such damage.
232de3b87aSKai Wang.\"
24*ae500c1fSEd Maste.\" $Id: elf_errmsg.3 3639 2018-10-14 14:07:02Z jkoshy $
252de3b87aSKai Wang.\"
262de3b87aSKai Wang.Dd June 11, 2006
272de3b87aSKai Wang.Dt ELF_ERRMSG 3
28*ae500c1fSEd Maste.Os
292de3b87aSKai Wang.Sh NAME
302de3b87aSKai Wang.Nm elf_errmsg ,
312de3b87aSKai Wang.Nm elf_errno
322de3b87aSKai Wang.Nd ELF library error message handling
332de3b87aSKai Wang.Sh LIBRARY
342de3b87aSKai Wang.Lb libelf
352de3b87aSKai Wang.Sh SYNOPSIS
362de3b87aSKai Wang.In libelf.h
372de3b87aSKai Wang.Ft int
382de3b87aSKai Wang.Fn elf_errno "void"
392de3b87aSKai Wang.Ft "const char *"
402de3b87aSKai Wang.Fn elf_errmsg "int error"
412de3b87aSKai Wang.Sh DESCRIPTION
422de3b87aSKai WangWhen an error occurs during an ELF library API call, the library
432de3b87aSKai Wangencodes the error using an error number and stores the error number
442de3b87aSKai Wanginternally for retrieval by the application at a later point of time.
452de3b87aSKai WangError numbers may contain an OS supplied error code in addition to
462de3b87aSKai Wangan ELF API specific error code.
472de3b87aSKai WangAn error number value of zero indicates no error.
482de3b87aSKai Wang.Pp
492de3b87aSKai WangFunction
502de3b87aSKai Wang.Fn elf_errno
512de3b87aSKai Wangis used to retrieve the last error recorded by the ELF library.
522de3b87aSKai WangInvoking this function has the side-effect of resetting the
532de3b87aSKai WangELF library's recorded error number to zero.
542de3b87aSKai Wang.Pp
552de3b87aSKai WangThe function
562de3b87aSKai Wang.Fn elf_errmsg
572de3b87aSKai Wangreturns a null-terminated string with a human readable
582de3b87aSKai Wangdescription of the error specified in argument
592de3b87aSKai Wang.Ar error .
602de3b87aSKai WangA zero value for argument
612de3b87aSKai Wang.Ar error
622de3b87aSKai Wangretrieves the most recent error encountered by the ELF
632de3b87aSKai Wanglibrary.
642de3b87aSKai WangAn argument value of -1 behaves identically, except that
652de3b87aSKai Wangit guarantees a non-NULL return from
662de3b87aSKai Wang.Fn elf_errmsg .
672de3b87aSKai Wang.Sh RETURN VALUES
682de3b87aSKai WangFunction
692de3b87aSKai Wang.Fn elf_errno
702de3b87aSKai Wangreturns a non-zero value encoding the last error encountered
712de3b87aSKai Wangby the ELF library, or zero if no error was encountered.
722de3b87aSKai Wang.Pp
732de3b87aSKai WangFunction
742de3b87aSKai Wang.Fn elf_errmsg
752de3b87aSKai Wangreturns a pointer to library local storage for non-zero values
762de3b87aSKai Wangof argument
772de3b87aSKai Wang.Ar error .
782de3b87aSKai WangWith a zero argument, the function will return a NULL pointer if no
792de3b87aSKai Wangerror had been encountered by the library, or will return a pointer to
802de3b87aSKai Wanglibrary local storage containing an appropriate message otherwise.
812de3b87aSKai Wang.Sh EXAMPLES
822de3b87aSKai WangClearing the ELF library's recorded error number can be accomplished
832de3b87aSKai Wangby invoking
842de3b87aSKai Wang.Fn elf_errno
852de3b87aSKai Wangand discarding its return value.
862de3b87aSKai Wang.Bd -literal -offset indent
872de3b87aSKai Wang/* clear error */
882de3b87aSKai Wang(void) elf_errno();
892de3b87aSKai Wang.Ed
902de3b87aSKai Wang.Pp
912de3b87aSKai WangRetrieving a human-readable description of the current error number
922de3b87aSKai Wangcan be done with the following snippet:
932de3b87aSKai Wang.Bd -literal -offset indent
942de3b87aSKai Wangint err;
952de3b87aSKai Wangconst char *errmsg;
962de3b87aSKai Wang\&...
972de3b87aSKai Wangerr = elf_errno();
982de3b87aSKai Wangif (err != 0)
992de3b87aSKai Wang	errmsg = elf_errmsg(err);
1002de3b87aSKai Wang.Ed
1012de3b87aSKai Wang.Sh SEE ALSO
1022de3b87aSKai Wang.Xr elf 3 ,
1032de3b87aSKai Wang.Xr gelf 3
1042de3b87aSKai Wang.Sh BUGS
1052de3b87aSKai WangFunction
1062de3b87aSKai Wang.Fn elf_errmsg
1072de3b87aSKai Wangis not localized.
108