1elf_errmsg(3ELF)             ELF Library Functions            elf_errmsg(3ELF)
2
3
4

NAME

6       elf_errmsg, elf_errno - error handling
7

SYNOPSIS

9       cc [ flag ... ] file ... -lelf [ library ... ]
10       #include <libelf.h>
11
12       const char *elf_errmsg(int err);
13
14
15       int elf_errno(void);
16
17

DESCRIPTION

19       If  an  ELF  library  function fails, a program can call elf_errno() to
20       retrieve the library's internal error number. As a  side  effect,  this
21       function  resets  the  internal  error  number to 0, which indicates no
22       error.
23
24
25       The elf_errmsg() function takes an error number,  err,  and  returns  a
26       null-terminated   error   message  (with  no  trailing  new-line)  that
27       describes the problem. A zero err retrieves  a  message  for  the  most
28       recent  error.  If  no  error  has occurred, the return value is a null
29       pointer (not a pointer to the  null  string).  Using  err  of  −1  also
30       retrieves the most recent error, except it guarantees a non-null return
31       value, even when no error has occurred. If no message is available  for
32       the given number, elf_errmsg() returns a pointer to an appropriate mes‐
33       sage. This function does not have  the  side  effect  of  clearing  the
34       internal error number.
35

EXAMPLES

37       Example 1 A sample program of calling the elf_errmsg() function.
38
39
40       The  following  fragment clears the internal error number and checks it
41       later for errors. Unless an  error  occurs  after  the  first  call  to
42       elf_errno(), the next call will return 0.
43
44
45         (void)elf_errno();
46         /* processing ... */
47         while (more_to_do)
48         {
49              if ((err = elf_errno()) != 0)
50              {
51                   /* print msg */
52                   msg = elf_errmsg(err);
53              }
54         }
55
56

ATTRIBUTES

58       See attributes(5) for descriptions of the following attributes:
59
60
61
62
63       ┌─────────────────────────────┬─────────────────────────────┐
64       │      ATTRIBUTE TYPE         │      ATTRIBUTE VALUE        │
65       ├─────────────────────────────┼─────────────────────────────┤
66       │Interface Stability          │Stable                       │
67       ├─────────────────────────────┼─────────────────────────────┤
68       │MT-Level                     │MT-Safe                      │
69       └─────────────────────────────┴─────────────────────────────┘
70

SEE ALSO

72       elf(3ELF), libelf(3LIB), attributes(5)
73
74
75
76SunOS 5.11                        11 Jul 2001                 elf_errmsg(3ELF)
Impressum