xref: /netbsd-src/external/bsd/elftoolchain/dist/libelf/elf_getident.3 (revision 5ac3bc719ce6e70593039505b491894133237d12)
1.\"	$NetBSD: elf_getident.3,v 1.6 2024/03/03 17:37:33 christos Exp $
2.\"
3.\" Copyright (c) 2006,2008 Joseph Koshy.  All rights reserved.
4.\"
5.\" Redistribution and use in source and binary forms, with or without
6.\" modification, are permitted provided that the following conditions
7.\" are met:
8.\" 1. Redistributions of source code must retain the above copyright
9.\"    notice, this list of conditions and the following disclaimer.
10.\" 2. Redistributions in binary form must reproduce the above copyright
11.\"    notice, this list of conditions and the following disclaimer in the
12.\"    documentation and/or other materials provided with the distribution.
13.\"
14.\" This software is provided by Joseph Koshy ``as is'' and
15.\" any express or implied warranties, including, but not limited to, the
16.\" implied warranties of merchantability and fitness for a particular purpose
17.\" are disclaimed.  in no event shall Joseph Koshy be liable
18.\" for any direct, indirect, incidental, special, exemplary, or consequential
19.\" damages (including, but not limited to, procurement of substitute goods
20.\" or services; loss of use, data, or profits; or business interruption)
21.\" however caused and on any theory of liability, whether in contract, strict
22.\" liability, or tort (including negligence or otherwise) arising in any way
23.\" out of the use of this software, even if advised of the possibility of
24.\" such damage.
25.\"
26.\" Id: elf_getident.3 3956 2022-03-12 12:39:30Z jkoshy
27.\"
28.Dd July 3, 2006
29.Dt ELF_GETIDENT 3
30.Os
31.Sh NAME
32.Nm elf_getident
33.Nd return the initial bytes of a file
34.Sh LIBRARY
35.Lb libelf
36.Sh SYNOPSIS
37.In libelf.h
38.Ft char *
39.Fn elf_getident "Elf *elf" "size_t *sz"
40.Sh DESCRIPTION
41Function
42.Fn elf_getident
43returns a pointer to the initial bytes of the file for descriptor
44.Fa elf .
45.Pp
46If argument
47.Fa sz
48is non-null, the size of the identification area returned is written
49to the location pointed to by
50.Fa sz .
51This location is set to zero on errors.
52.Sh RETURN VALUES
53Function
54.Fn elf_getident
55will return a
56.No non- Ns Dv NULL
57pointer to the initial bytes of the file if successful, or
58.Dv NULL
59if an error condition is detected.
60.Sh ERRORS
61Function
62.Fn elf_getident
63can fail with the following errors:
64.Bl -tag -width "[ELF_E_RESOURCE]"
65.It Bq Er ELF_E_ARGUMENT
66A
67.Dv NULL
68value was passed in for argument
69.Fa elf .
70.It Bq Er ELF_E_SEQUENCE
71ELF descriptor
72.Fa elf
73was opened for writing and function
74.Fn elf_getident
75was called before a call to
76.Xr elf_update 3 .
77.El
78.Sh SEE ALSO
79.Xr elf 3 ,
80.Xr elf32_getehdr 3 ,
81.Xr elf64_getehdr 3 ,
82.Xr elf_getarhdr 3 ,
83.Xr elf_getbase 3 ,
84.Xr elf_getflags 3 ,
85.Xr elf_kind 3 ,
86.Xr elf_rawfile 3 ,
87.Xr elf_update 3 ,
88.Xr gelf 3 ,
89.Xr gelf_getclass 3 ,
90.Xr gelf_getehdr 3
91