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.\"
24839529caSEd Maste.\" $Id: elftc_bfd_find_target.3 3348 2016-01-18 14:18:50Z emaste $
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:
61839529caSEd Maste.Bl -column -offset "XXXX" ".Li elf32-x86-64-freebsd" "Object format" "Byte Order" "Bit Width"
62839529caSEd Maste.It Em Name Ta Em "Object Format" Ta Em "Byte Order" Ta Em "Bit Width"
63a85fe12eSEd Maste.It Li binary Ta Binary Ta - Ta -
64839529caSEd Maste.It Li efi-app-ia32 Ta PE Ta LSB Ta 32
65839529caSEd Maste.It Li efi-app-x86_64 Ta PE Ta LSB Ta 64
66a85fe12eSEd Maste.It Li elf32-avr Ta ELF Ta LSB Ta 32
67a85fe12eSEd Maste.It Li elf32-big Ta ELF Ta MSB Ta 32
68a85fe12eSEd Maste.It Li elf32-bigarm Ta ELF Ta MSB Ta 32
69a85fe12eSEd Maste.It Li elf32-bigmips Ta ELF Ta MSB Ta 32
70a85fe12eSEd Maste.It Li elf32-i386 Ta ELF Ta LSB Ta 32
71a85fe12eSEd Maste.It Li elf32-i386-freebsd Ta ELF Ta LSB Ta 32
72a85fe12eSEd Maste.It Li elf32-ia64-big Ta ELF Ta MSB Ta 32
73a85fe12eSEd Maste.It Li elf32-little Ta ELF Ta LSB Ta 32
74a85fe12eSEd Maste.It Li elf32-littlearm Ta ELF Ta LSB Ta 32
75a85fe12eSEd Maste.It Li elf32-littlemips Ta ELF Ta LSB Ta 32
76a85fe12eSEd Maste.It Li elf32-powerpc Ta ELF Ta MSB Ta 32
77a85fe12eSEd Maste.It Li elf32-powerpcle Ta ELF Ta LSB Ta 32
78a85fe12eSEd Maste.It Li elf32-sh Ta ELF Ta MSB Ta 32
79a85fe12eSEd Maste.It Li elf32-shl Ta ELF Ta LSB Ta 32
80a85fe12eSEd Maste.It Li elf32-sh-nbsd Ta ELF Ta MSB Ta 32
81a85fe12eSEd Maste.It Li elf32-shl-nbsd Ta ELF Ta LSB Ta 32
82a85fe12eSEd Maste.It Li elf32-shbig-linux Ta ELF Ta MSB Ta 32
83a85fe12eSEd Maste.It Li elf32-shl-linux Ta ELF Ta LSB Ta 32
84a85fe12eSEd Maste.It Li elf32-sparc Ta ELF Ta MSB Ta 32
85a85fe12eSEd Maste.It Li elf64-alpha Ta ELF Ta LSB Ta 64
86a85fe12eSEd Maste.It Li elf64-alpha-freebsd Ta ELF Ta LSB Ta 64
87a85fe12eSEd Maste.It Li elf64-big Ta ELF Ta MSB Ta 64
88a85fe12eSEd Maste.It Li elf64-bigmips Ta ELF Ta MSB Ta 64
89a85fe12eSEd Maste.It Li elf64-ia64-big Ta ELF Ta MSB Ta 64
90a85fe12eSEd Maste.It Li elf64-ia64-little Ta ELF Ta LSB Ta 64
91a85fe12eSEd Maste.It Li elf64-little Ta ELF Ta LSB Ta 64
92e85c2b0bSEd Maste.It Li elf64-littleaarch64 Ta ELF Ta LSB Ta 64
93a85fe12eSEd Maste.It Li elf64-littlemips Ta ELF Ta LSB Ta 64
94a85fe12eSEd Maste.It Li elf64-powerpc Ta ELF Ta MSB Ta 64
95a85fe12eSEd Maste.It Li elf64-powerpcle Ta ELF Ta LSB Ta 64
96a85fe12eSEd Maste.It Li elf64-sh64 Ta ELF Ta MSB Ta 64
97a85fe12eSEd Maste.It Li elf64-sh64l Ta ELF Ta LSB Ta 64
98a85fe12eSEd Maste.It Li elf64-sh64-nbsd Ta ELF Ta MSB Ta 64
99a85fe12eSEd Maste.It Li elf64-sh64l-nbsd Ta ELF Ta LSB Ta 64
100a85fe12eSEd Maste.It Li elf64-sh64big-linux Ta ELF Ta MSB Ta 64
101a85fe12eSEd Maste.It Li elf64-sh64-linux Ta ELF Ta LSB Ta 64
102a85fe12eSEd Maste.It Li elf64-sparc Ta ELF Ta MSB Ta 64
103a85fe12eSEd Maste.It Li elf64-sparc-freebsd Ta ELF Ta MSB Ta 64
104a85fe12eSEd Maste.It Li elf64-x86-64 Ta ELF Ta LSB Ta 64
105a85fe12eSEd Maste.It Li elf64-x86-64-freebsd Ta ELF Ta LSB Ta 64
106a85fe12eSEd Maste.It Li ihex Ta IHEX Ta - Ta -
107839529caSEd Maste.It Li pei-i386 Ta PE Ta LSB Ta 32
108839529caSEd Maste.It Li pei-x86-64 Ta PE Ta LSB Ta 64
109a85fe12eSEd Maste.It Li srec Ta SREC Ta - Ta -
110a85fe12eSEd Maste.It Li symbolsrec Ta SREC Ta - Ta -
111a85fe12eSEd Maste.El
112a85fe12eSEd Maste.Pp
113a85fe12eSEd MasteFunction
114a85fe12eSEd Maste.Fn elftc_bfd_target_byteorder
115a85fe12eSEd Mastereturns the ELF byte order associated with target descriptor
116a85fe12eSEd Maste.Ar target .
117a85fe12eSEd Maste.Pp
118a85fe12eSEd MasteFunction
119a85fe12eSEd Maste.Fn elftc_bfd_target_class
120a85fe12eSEd Mastereturns the ELF class associated with target descriptor
121a85fe12eSEd Maste.Ar target .
122a85fe12eSEd Maste.Pp
123a85fe12eSEd MasteFunction
124a85fe12eSEd Maste.Fn elftc_bfd_target_flavor
125a85fe12eSEd Mastereturns the object format associated with target descriptor
126a85fe12eSEd Maste.Ar target .
127a85fe12eSEd MasteThe known object formats are:
128a85fe12eSEd Maste.Bl -tag -offset "XXXX" -width ".Dv ETF_BINARY" -compact
129a85fe12eSEd Maste.It Dv ETF_ELF
130a85fe12eSEd MasteAn ELF object.
131a85fe12eSEd Maste.It Dv ETF_BINARY
132a85fe12eSEd MasteRaw binary.
133a85fe12eSEd Maste.It Dv ETF_IHEX
134a85fe12eSEd MasteAn object encoded in
135a85fe12eSEd Maste.Tn Intel
136a85fe12eSEd Mastehex format.
137a85fe12eSEd Maste.It Dv ETF_NONE
138a85fe12eSEd MasteAn unknown object format.
139a85fe12eSEd Maste.It Dv ETF_SREC
140a85fe12eSEd MasteAn object encoded as S-records.
141a85fe12eSEd Maste.El
142a85fe12eSEd Maste.Sh RETURN VALUES
143a85fe12eSEd MasteFunction
144a85fe12eSEd Maste.Fn elftc_bfd_find_target
145a85fe12eSEd Mastereturns a valid pointer to an opaque binary target descriptor if
146a85fe12eSEd Mastesuccessful, or NULL in case of an error.
147a85fe12eSEd Maste.Pp
148a85fe12eSEd MasteFunction
149a85fe12eSEd Maste.Fn elftc_bfd_target_byteorder
150a85fe12eSEd Mastereturns the ELF byte order associated with the target descriptor; one of
151a85fe12eSEd Maste.Dv ELFDATA2MSB
152a85fe12eSEd Masteor
153a85fe12eSEd Maste.Dv ELFDATA2LSB .
154a85fe12eSEd Maste.Pp
155a85fe12eSEd MasteFunction
156a85fe12eSEd Maste.Fn elftc_bfd_target_class
157a85fe12eSEd Mastereturns the ELF class associated with the target descriptor; one of
158a85fe12eSEd Maste.Dv ELFCLASS32
159a85fe12eSEd Masteor
160a85fe12eSEd Maste.Dv ELFCLASS64 .
161a85fe12eSEd Maste.Pp
162a85fe12eSEd MasteFunction
163a85fe12eSEd Maste.Fn elftc_bfd_target_machine
164a85fe12eSEd Mastereturns the ELF architecture associated with the target descriptor.
165a85fe12eSEd Maste.Pp
166a85fe12eSEd MasteFunction
167a85fe12eSEd Maste.Fn elftc_bfd_target_flavor
168a85fe12eSEd Mastereturns one of
169a85fe12eSEd Maste.Dv ETF_BINARY ,
170a85fe12eSEd Maste.Dv ETF_ELF ,
171a85fe12eSEd Maste.Dv ETF_IHEX
172a85fe12eSEd Masteor
173a85fe12eSEd Maste.Dv ETF_SREC
174a85fe12eSEd Masteif successful or
175a85fe12eSEd Maste.Dv ETF_NONE
176a85fe12eSEd Mastein case of error.
177a85fe12eSEd Maste.Sh EXAMPLES
178a85fe12eSEd MasteTo return descriptor information associated with target name
179a85fe12eSEd Maste.Dq elf64-big
180a85fe12eSEd Masteuse:
181a85fe12eSEd Maste.Bd -literal -offset indent
182a85fe12eSEd Mastestruct Elftc_Bfd_Target *t;
183a85fe12eSEd Maste
184a85fe12eSEd Masteif ((t = elftc_bfd_find_target("elf64-big")) == NULL)
185a85fe12eSEd Maste	errx(EXIT_FAILURE, "Cannot find target descriptor");
186a85fe12eSEd Maste
187a85fe12eSEd Masteprintf("Class: %s\\n", elftc_bfd_target_class(t) == ELFCLASS32 ?
188a85fe12eSEd Maste    "ELFCLASS32" : "ELFCLASS64");
189a85fe12eSEd Masteprintf("Byteorder: %s\\n",
190a85fe12eSEd Maste    elftc_bfd_target_byteorder(t) == ELFDATA2LSB ? "LSB" : "MSB");
191a85fe12eSEd Masteprintf("Flavor: %d\\n", elftc_bfd_target_flavor(t));
192a85fe12eSEd Maste.Ed
193a85fe12eSEd Maste.Sh SEE ALSO
194a85fe12eSEd Maste.Xr elf 3
195