xref: /minix3/external/bsd/elftoolchain/dist/libelf/elf_getarsym.3 (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1*0a6a1f1dSLionel Sambuc.\"	$NetBSD: elf_getarsym.3,v 1.2 2014/03/09 16:58:04 christos Exp $
2*0a6a1f1dSLionel Sambuc.\"
3*0a6a1f1dSLionel Sambuc.\" Copyright (c) 2006,2008 Joseph Koshy.  All rights reserved.
4*0a6a1f1dSLionel Sambuc.\"
5*0a6a1f1dSLionel Sambuc.\" Redistribution and use in source and binary forms, with or without
6*0a6a1f1dSLionel Sambuc.\" modification, are permitted provided that the following conditions
7*0a6a1f1dSLionel Sambuc.\" are met:
8*0a6a1f1dSLionel Sambuc.\" 1. Redistributions of source code must retain the above copyright
9*0a6a1f1dSLionel Sambuc.\"    notice, this list of conditions and the following disclaimer.
10*0a6a1f1dSLionel Sambuc.\" 2. Redistributions in binary form must reproduce the above copyright
11*0a6a1f1dSLionel Sambuc.\"    notice, this list of conditions and the following disclaimer in the
12*0a6a1f1dSLionel Sambuc.\"    documentation and/or other materials provided with the distribution.
13*0a6a1f1dSLionel Sambuc.\"
14*0a6a1f1dSLionel Sambuc.\" This software is provided by Joseph Koshy ``as is'' and
15*0a6a1f1dSLionel Sambuc.\" any express or implied warranties, including, but not limited to, the
16*0a6a1f1dSLionel Sambuc.\" implied warranties of merchantability and fitness for a particular purpose
17*0a6a1f1dSLionel Sambuc.\" are disclaimed.  in no event shall Joseph Koshy be liable
18*0a6a1f1dSLionel Sambuc.\" for any direct, indirect, incidental, special, exemplary, or consequential
19*0a6a1f1dSLionel Sambuc.\" damages (including, but not limited to, procurement of substitute goods
20*0a6a1f1dSLionel Sambuc.\" or services; loss of use, data, or profits; or business interruption)
21*0a6a1f1dSLionel Sambuc.\" however caused and on any theory of liability, whether in contract, strict
22*0a6a1f1dSLionel Sambuc.\" liability, or tort (including negligence or otherwise) arising in any way
23*0a6a1f1dSLionel Sambuc.\" out of the use of this software, even if advised of the possibility of
24*0a6a1f1dSLionel Sambuc.\" such damage.
25*0a6a1f1dSLionel Sambuc.\"
26*0a6a1f1dSLionel Sambuc.\" Id: elf_getarsym.3 189 2008-07-20 10:38:08Z jkoshy
27*0a6a1f1dSLionel Sambuc.\"
28*0a6a1f1dSLionel Sambuc.Dd August 15, 2006
29*0a6a1f1dSLionel Sambuc.Os
30*0a6a1f1dSLionel Sambuc.Dt ELF_GETARSYM 3
31*0a6a1f1dSLionel Sambuc.Sh NAME
32*0a6a1f1dSLionel Sambuc.Nm elf_getarsym
33*0a6a1f1dSLionel Sambuc.Nd retrieve the symbol table of an archive
34*0a6a1f1dSLionel Sambuc.Sh LIBRARY
35*0a6a1f1dSLionel Sambuc.Lb libelf
36*0a6a1f1dSLionel Sambuc.Sh SYNOPSIS
37*0a6a1f1dSLionel Sambuc.In libelf.h
38*0a6a1f1dSLionel Sambuc.Ft "Elf_Arsym *"
39*0a6a1f1dSLionel Sambuc.Fn elf_getarsym "Elf *elf" "size_t *ptr"
40*0a6a1f1dSLionel Sambuc.Sh DESCRIPTION
41*0a6a1f1dSLionel SambucThe function
42*0a6a1f1dSLionel Sambuc.Fn elf_getarsym
43*0a6a1f1dSLionel Sambucretrieves the symbol table for an
44*0a6a1f1dSLionel Sambuc.Xr ar 1
45*0a6a1f1dSLionel Sambucarchive, if one is available.
46*0a6a1f1dSLionel Sambuc.Pp
47*0a6a1f1dSLionel SambucArgument
48*0a6a1f1dSLionel Sambuc.Ar elf
49*0a6a1f1dSLionel Sambucshould be a descriptor for an
50*0a6a1f1dSLionel Sambuc.Xr ar 1
51*0a6a1f1dSLionel Sambucarchive opened using
52*0a6a1f1dSLionel Sambuc.Fn elf_begin
53*0a6a1f1dSLionel Sambucor
54*0a6a1f1dSLionel Sambuc.Fn elf_memory .
55*0a6a1f1dSLionel Sambuc.Pp
56*0a6a1f1dSLionel SambucIf the archive
57*0a6a1f1dSLionel Sambuc.Ar elf
58*0a6a1f1dSLionel Sambuccontains a symbol table with n entries, this function returns a
59*0a6a1f1dSLionel Sambucpointer to an array of n+1
60*0a6a1f1dSLionel Sambuc.Vt Elf_Arsym
61*0a6a1f1dSLionel Sambucstructures.
62*0a6a1f1dSLionel SambucAn
63*0a6a1f1dSLionel Sambuc.Vt Elf_Arsym
64*0a6a1f1dSLionel Sambucstructure has the following elements:
65*0a6a1f1dSLionel Sambuc.Bl -tag -width indent -compact
66*0a6a1f1dSLionel Sambuc.It Vt "char *" Va as_name
67*0a6a1f1dSLionel SambucThis structure member is a pointer to a null-terminated symbol name.
68*0a6a1f1dSLionel Sambuc.It Vt "off_t" Va as_off
69*0a6a1f1dSLionel SambucThis structure member contains the byte offset from the beginning of the archive to
70*0a6a1f1dSLionel Sambucthe header for the archive member.
71*0a6a1f1dSLionel SambucThis value is suitable for use with
72*0a6a1f1dSLionel Sambuc.Xr elf_rand 3 .
73*0a6a1f1dSLionel Sambuc.It Vt "unsigned long" Va as_hash
74*0a6a1f1dSLionel SambucThis structure member contains a portable hash value for the symbol
75*0a6a1f1dSLionel Sambucname, as computed by
76*0a6a1f1dSLionel Sambuc.Xr elf_hash 3 .
77*0a6a1f1dSLionel Sambuc.El
78*0a6a1f1dSLionel Sambuc.Pp
79*0a6a1f1dSLionel SambucThe last entry of the returned array will have a NULL value for member
80*0a6a1f1dSLionel Sambuc.Va as_name ,
81*0a6a1f1dSLionel Sambuca zero value for member
82*0a6a1f1dSLionel Sambuc.Va as_off
83*0a6a1f1dSLionel Sambucand an illegal value of ~0UL for
84*0a6a1f1dSLionel Sambuc.Va as_hash .
85*0a6a1f1dSLionel Sambuc.Pp
86*0a6a1f1dSLionel SambucIf argument
87*0a6a1f1dSLionel Sambuc.Ar ptr
88*0a6a1f1dSLionel Sambucis non-null, the
89*0a6a1f1dSLionel Sambuc.Fn elf_getarsym
90*0a6a1f1dSLionel Sambucfunction will store the number of table entries returned (including the
91*0a6a1f1dSLionel Sambucsentinel entry at the end) into the location it points to.
92*0a6a1f1dSLionel Sambuc.Sh RETURN VALUES
93*0a6a1f1dSLionel SambucFunction
94*0a6a1f1dSLionel Sambuc.Fn elf_getarsym
95*0a6a1f1dSLionel Sambucreturns a pointer to an array of
96*0a6a1f1dSLionel Sambuc.Vt Elf_Arsym
97*0a6a1f1dSLionel Sambucstructures if successful, or a NULL
98*0a6a1f1dSLionel Sambucpointer if an error was encountered.
99*0a6a1f1dSLionel Sambuc.Pp
100*0a6a1f1dSLionel SambucIf argument
101*0a6a1f1dSLionel Sambuc.Ar ptr
102*0a6a1f1dSLionel Sambucis non-null and there was no error, the library will store the
103*0a6a1f1dSLionel Sambucnumber of archive symbol entries returned into the location it
104*0a6a1f1dSLionel Sambucpoints to.
105*0a6a1f1dSLionel SambucIf argument
106*0a6a1f1dSLionel Sambuc.Ar ptr
107*0a6a1f1dSLionel Sambucis non-null and an error was encountered, the library will
108*0a6a1f1dSLionel Sambucset the location pointed to by it to zero.
109*0a6a1f1dSLionel Sambuc.Sh ERRORS
110*0a6a1f1dSLionel SambucFunction
111*0a6a1f1dSLionel Sambuc.Fn elf_getarsym
112*0a6a1f1dSLionel Sambucmay fail with the following errors:
113*0a6a1f1dSLionel Sambuc.Bl -tag -width "[ELF_E_RESOURCE]"
114*0a6a1f1dSLionel Sambuc.It Bq Er ELF_E_ARGUMENT
115*0a6a1f1dSLionel SambucArgument
116*0a6a1f1dSLionel Sambuc.Ar elf
117*0a6a1f1dSLionel Sambucwas NULL.
118*0a6a1f1dSLionel Sambuc.It Bq Er ELF_E_ARGUMENT
119*0a6a1f1dSLionel SambucArgument
120*0a6a1f1dSLionel Sambuc.Ar elf
121*0a6a1f1dSLionel Sambucwas not a descriptor for an
122*0a6a1f1dSLionel Sambuc.Xr ar 1
123*0a6a1f1dSLionel Sambucarchive.
124*0a6a1f1dSLionel Sambuc.El
125*0a6a1f1dSLionel Sambuc.Sh SEE ALSO
126*0a6a1f1dSLionel Sambuc.Xr elf 3 ,
127*0a6a1f1dSLionel Sambuc.Xr elf_begin 3 ,
128*0a6a1f1dSLionel Sambuc.Xr elf_getarhdr 3 ,
129*0a6a1f1dSLionel Sambuc.Xr elf_hash 3 ,
130*0a6a1f1dSLionel Sambuc.Xr elf_memory 3 ,
131*0a6a1f1dSLionel Sambuc.Xr elf_next 3 ,
132*0a6a1f1dSLionel Sambuc.Xr elf_rand 3
133