1a85fe12eSEd Maste.\" Copyright (c) 2010-2011 Joseph Koshy.  All rights reserved.
2a85fe12eSEd Maste.\"
3a85fe12eSEd Maste.\" Redistribution and use in source and binary forms, with or without
4a85fe12eSEd Maste.\" modification, are permitted provided that the following conditions
5a85fe12eSEd Maste.\" are met:
6a85fe12eSEd Maste.\" 1. Redistributions of source code must retain the above copyright
7a85fe12eSEd Maste.\"    notice, this list of conditions and the following disclaimer.
8a85fe12eSEd Maste.\" 2. Redistributions in binary form must reproduce the above copyright
9a85fe12eSEd Maste.\"    notice, this list of conditions and the following disclaimer in the
10a85fe12eSEd Maste.\"    documentation and/or other materials provided with the distribution.
11a85fe12eSEd Maste.\"
12a85fe12eSEd Maste.\" This software is provided by Joseph Koshy ``as is'' and
13a85fe12eSEd Maste.\" any express or implied warranties, including, but not limited to, the
14a85fe12eSEd Maste.\" implied warranties of merchantability and fitness for a particular purpose
15a85fe12eSEd Maste.\" are disclaimed.  in no event shall Joseph Koshy be liable
16a85fe12eSEd Maste.\" for any direct, indirect, incidental, special, exemplary, or consequential
17a85fe12eSEd Maste.\" damages (including, but not limited to, procurement of substitute goods
18a85fe12eSEd Maste.\" or services; loss of use, data, or profits; or business interruption)
19a85fe12eSEd Maste.\" however caused and on any theory of liability, whether in contract, strict
20a85fe12eSEd Maste.\" liability, or tort (including negligence or otherwise) arising in any way
21a85fe12eSEd Maste.\" out of the use of this software, even if advised of the possibility of
22a85fe12eSEd Maste.\" such damage.
23a85fe12eSEd Maste.\"
24a85fe12eSEd Maste.\" $Id: elftc_bfd_find_target.3 2251 2011-11-30 16:50:06Z jkoshy $
25a85fe12eSEd Maste.\"
26a85fe12eSEd Maste.Dd November 30, 2011
27a85fe12eSEd Maste.Os
28a85fe12eSEd Maste.Dt ELFTC_BFD_FIND_TARGET
29a85fe12eSEd Maste.Sh NAME
30a85fe12eSEd Maste.Nm elftc_bfd_find_target ,
31a85fe12eSEd Maste.Nm elftc_bfd_target_byteorder ,
32a85fe12eSEd Maste.Nm elftc_bfd_target_class ,
33a85fe12eSEd Maste.Nm elftc_bfd_target_flavor ,
34a85fe12eSEd Maste.Nm elftc_bfd_target_machine
35a85fe12eSEd Maste.Nd binary object descriptor handling
36a85fe12eSEd Maste.Sh LIBRARY
37a85fe12eSEd Maste.Lb libelftc
38a85fe12eSEd Maste.Sh SYNOPSIS
39a85fe12eSEd Maste.In libelftc.h
40a85fe12eSEd Maste.Vt struct Elftc_Bfd_Target;
41a85fe12eSEd Maste.Ft "Elftc_Bfd_Target *"
42a85fe12eSEd Maste.Fn elftc_bfd_find_target "const char *target_name"
43a85fe12eSEd Maste.Ft "unsigned int"
44a85fe12eSEd Maste.Fn elftc_bfd_target_class "Elftc_Bfd_Target *target"
45a85fe12eSEd Maste.Ft "unsigned int"
46a85fe12eSEd Maste.Fn elftc_bfd_target_byteorder "Elftc_Bfd_Target *target"
47a85fe12eSEd Maste.Ft Elftc_Bfd_Target_Flavor
48a85fe12eSEd Maste.Fn elftc_bfd_target_flavor "Elftc_Bfd_Target *target"
49a85fe12eSEd Maste.Ft "unsigned int"
50a85fe12eSEd Maste.Fn elftc_bfd_target_machine "Elftc_Bfd_Target *target"
51a85fe12eSEd Maste.Sh DESCRIPTION
52a85fe12eSEd MasteFunction
53a85fe12eSEd Maste.Fn elftc_bfd_find_target
54a85fe12eSEd Mastelocates a binary object descriptor corresponding to the descriptor
55a85fe12eSEd Mastename in argument
56a85fe12eSEd Maste.Ar "target_name" .
57a85fe12eSEd MasteBinary object descriptors encapsulate properties of an object format
58a85fe12eSEd Mastesuch as its file representation, ELF class, and byte endianness.
59a85fe12eSEd Maste.Pp
60a85fe12eSEd MasteKnown descriptor names and their properties include:
61a85fe12eSEd Maste.Bl -column -offset "XXXX" ".Li elf32-x86-64-freebsd" "Object format" "Byte Order" "ELF Class"
62a85fe12eSEd Maste.It Em Name Ta Em "Object Format" Ta Em "Byte Order" Ta Em "ELF Class"
63a85fe12eSEd Maste.It Li binary Ta Binary Ta - Ta -
64a85fe12eSEd Maste.It Li elf32-avr Ta ELF Ta LSB Ta 32
65a85fe12eSEd Maste.It Li elf32-big Ta ELF Ta MSB Ta 32
66a85fe12eSEd Maste.It Li elf32-bigarm Ta ELF Ta MSB Ta 32
67a85fe12eSEd Maste.It Li elf32-bigmips Ta ELF Ta MSB Ta 32
68a85fe12eSEd Maste.It Li elf32-i386 Ta ELF Ta LSB Ta 32
69a85fe12eSEd Maste.It Li elf32-i386-freebsd Ta ELF Ta LSB Ta 32
70a85fe12eSEd Maste.It Li elf32-ia64-big Ta ELF Ta MSB Ta 32
71a85fe12eSEd Maste.It Li elf32-little Ta ELF Ta LSB Ta 32
72a85fe12eSEd Maste.It Li elf32-littlearm Ta ELF Ta LSB Ta 32
73a85fe12eSEd Maste.It Li elf32-littlemips Ta ELF Ta LSB Ta 32
74a85fe12eSEd Maste.It Li elf32-powerpc Ta ELF Ta MSB Ta 32
75a85fe12eSEd Maste.It Li elf32-powerpcle Ta ELF Ta LSB Ta 32
76a85fe12eSEd Maste.It Li elf32-sh Ta ELF Ta MSB Ta 32
77a85fe12eSEd Maste.It Li elf32-shl Ta ELF Ta LSB Ta 32
78a85fe12eSEd Maste.It Li elf32-sh-nbsd Ta ELF Ta MSB Ta 32
79a85fe12eSEd Maste.It Li elf32-shl-nbsd Ta ELF Ta LSB Ta 32
80a85fe12eSEd Maste.It Li elf32-shbig-linux Ta ELF Ta MSB Ta 32
81a85fe12eSEd Maste.It Li elf32-shl-linux Ta ELF Ta LSB Ta 32
82a85fe12eSEd Maste.It Li elf32-sparc Ta ELF Ta MSB Ta 32
83a85fe12eSEd Maste.It Li elf64-alpha Ta ELF Ta LSB Ta 64
84a85fe12eSEd Maste.It Li elf64-alpha-freebsd Ta ELF Ta LSB Ta 64
85a85fe12eSEd Maste.It Li elf64-big Ta ELF Ta MSB Ta 64
86a85fe12eSEd Maste.It Li elf64-bigmips Ta ELF Ta MSB Ta 64
87a85fe12eSEd Maste.It Li elf64-ia64-big Ta ELF Ta MSB Ta 64
88a85fe12eSEd Maste.It Li elf64-ia64-little Ta ELF Ta LSB Ta 64
89a85fe12eSEd Maste.It Li elf64-little Ta ELF Ta LSB Ta 64
90a85fe12eSEd Maste.It Li elf64-littlemips Ta ELF Ta LSB Ta 64
91a85fe12eSEd Maste.It Li elf64-powerpc Ta ELF Ta MSB Ta 64
92a85fe12eSEd Maste.It Li elf64-powerpcle Ta ELF Ta LSB Ta 64
93a85fe12eSEd Maste.It Li elf64-sh64 Ta ELF Ta MSB Ta 64
94a85fe12eSEd Maste.It Li elf64-sh64l Ta ELF Ta LSB Ta 64
95a85fe12eSEd Maste.It Li elf64-sh64-nbsd Ta ELF Ta MSB Ta 64
96a85fe12eSEd Maste.It Li elf64-sh64l-nbsd Ta ELF Ta LSB Ta 64
97a85fe12eSEd Maste.It Li elf64-sh64big-linux Ta ELF Ta MSB Ta 64
98a85fe12eSEd Maste.It Li elf64-sh64-linux Ta ELF Ta LSB Ta 64
99a85fe12eSEd Maste.It Li elf64-sparc Ta ELF Ta MSB Ta 64
100a85fe12eSEd Maste.It Li elf64-sparc-freebsd Ta ELF Ta MSB Ta 64
101a85fe12eSEd Maste.It Li elf64-x86-64 Ta ELF Ta LSB Ta 64
102a85fe12eSEd Maste.It Li elf64-x86-64-freebsd Ta ELF Ta LSB Ta 64
103a85fe12eSEd Maste.It Li ihex Ta IHEX Ta - Ta -
104a85fe12eSEd Maste.It Li srec Ta SREC Ta - Ta -
105a85fe12eSEd Maste.It Li symbolsrec Ta SREC Ta - Ta -
106a85fe12eSEd Maste.El
107a85fe12eSEd Maste.Pp
108a85fe12eSEd MasteFunction
109a85fe12eSEd Maste.Fn elftc_bfd_target_byteorder
110a85fe12eSEd Mastereturns the ELF byte order associated with target descriptor
111a85fe12eSEd Maste.Ar target .
112a85fe12eSEd Maste.Pp
113a85fe12eSEd MasteFunction
114a85fe12eSEd Maste.Fn elftc_bfd_target_class
115a85fe12eSEd Mastereturns the ELF class associated with target descriptor
116a85fe12eSEd Maste.Ar target .
117a85fe12eSEd Maste.Pp
118a85fe12eSEd MasteFunction
119a85fe12eSEd Maste.Fn elftc_bfd_target_flavor
120a85fe12eSEd Mastereturns the object format associated with target descriptor
121a85fe12eSEd Maste.Ar target .
122a85fe12eSEd MasteThe known object formats are:
123a85fe12eSEd Maste.Bl -tag -offset "XXXX" -width ".Dv ETF_BINARY" -compact
124a85fe12eSEd Maste.It Dv ETF_ELF
125a85fe12eSEd MasteAn ELF object.
126a85fe12eSEd Maste.It Dv ETF_BINARY
127a85fe12eSEd MasteRaw binary.
128a85fe12eSEd Maste.It Dv ETF_IHEX
129a85fe12eSEd MasteAn object encoded in
130a85fe12eSEd Maste.Tn Intel
131a85fe12eSEd Mastehex format.
132a85fe12eSEd Maste.It Dv ETF_NONE
133a85fe12eSEd MasteAn unknown object format.
134a85fe12eSEd Maste.It Dv ETF_SREC
135a85fe12eSEd MasteAn object encoded as S-records.
136a85fe12eSEd Maste.El
137a85fe12eSEd Maste.Sh RETURN VALUES
138a85fe12eSEd MasteFunction
139a85fe12eSEd Maste.Fn elftc_bfd_find_target
140a85fe12eSEd Mastereturns a valid pointer to an opaque binary target descriptor if
141a85fe12eSEd Mastesuccessful, or NULL in case of an error.
142a85fe12eSEd Maste.Pp
143a85fe12eSEd MasteFunction
144a85fe12eSEd Maste.Fn elftc_bfd_target_byteorder
145a85fe12eSEd Mastereturns the ELF byte order associated with the target descriptor; one of
146a85fe12eSEd Maste.Dv ELFDATA2MSB
147a85fe12eSEd Masteor
148a85fe12eSEd Maste.Dv ELFDATA2LSB .
149a85fe12eSEd Maste.Pp
150a85fe12eSEd MasteFunction
151a85fe12eSEd Maste.Fn elftc_bfd_target_class
152a85fe12eSEd Mastereturns the ELF class associated with the target descriptor; one of
153a85fe12eSEd Maste.Dv ELFCLASS32
154a85fe12eSEd Masteor
155a85fe12eSEd Maste.Dv ELFCLASS64 .
156a85fe12eSEd Maste.Pp
157a85fe12eSEd MasteFunction
158a85fe12eSEd Maste.Fn elftc_bfd_target_machine
159a85fe12eSEd Mastereturns the ELF architecture associated with the target descriptor.
160a85fe12eSEd Maste.Pp
161a85fe12eSEd MasteFunction
162a85fe12eSEd Maste.Fn elftc_bfd_target_flavor
163a85fe12eSEd Mastereturns one of
164a85fe12eSEd Maste.Dv ETF_BINARY ,
165a85fe12eSEd Maste.Dv ETF_ELF ,
166a85fe12eSEd Maste.Dv ETF_IHEX
167a85fe12eSEd Masteor
168a85fe12eSEd Maste.Dv ETF_SREC
169a85fe12eSEd Masteif successful or
170a85fe12eSEd Maste.Dv ETF_NONE
171a85fe12eSEd Mastein case of error.
172a85fe12eSEd Maste.Sh EXAMPLES
173a85fe12eSEd MasteTo return descriptor information associated with target name
174a85fe12eSEd Maste.Dq elf64-big
175a85fe12eSEd Masteuse:
176a85fe12eSEd Maste.Bd -literal -offset indent
177a85fe12eSEd Mastestruct Elftc_Bfd_Target *t;
178a85fe12eSEd Maste
179a85fe12eSEd Masteif ((t = elftc_bfd_find_target("elf64-big")) == NULL)
180a85fe12eSEd Maste	errx(EXIT_FAILURE, "Cannot find target descriptor");
181a85fe12eSEd Maste
182a85fe12eSEd Masteprintf("Class: %s\\n", elftc_bfd_target_class(t) == ELFCLASS32 ?
183a85fe12eSEd Maste    "ELFCLASS32" : "ELFCLASS64");
184a85fe12eSEd Masteprintf("Byteorder: %s\\n",
185a85fe12eSEd Maste    elftc_bfd_target_byteorder(t) == ELFDATA2LSB ? "LSB" : "MSB");
186a85fe12eSEd Masteprintf("Flavor: %d\\n", elftc_bfd_target_flavor(t));
187a85fe12eSEd Maste.Ed
188a85fe12eSEd Maste.Sh SEE ALSO
189a85fe12eSEd Maste.Xr elf 3
190