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.\"
24ae500c1fSEd Maste.\" $Id: elftc_bfd_find_target.3 3645 2018-10-15 20:17:14Z jkoshy $
25a85fe12eSEd Maste.\"
26a85fe12eSEd Maste.Dd November 30, 2011
27ae500c1fSEd Maste.Dt ELFTC_BFD_FIND_TARGET 3
28a85fe12eSEd Maste.Os
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
77bee2765cSEd Maste.It Li elf32-powerpc-freebsd Ta ELF Ta MSB Ta 32
78a85fe12eSEd Maste.It Li elf32-powerpcle Ta ELF Ta LSB Ta 32
79a85fe12eSEd Maste.It Li elf32-sh Ta ELF Ta MSB Ta 32
80a85fe12eSEd Maste.It Li elf32-shl Ta ELF Ta LSB Ta 32
81a85fe12eSEd Maste.It Li elf32-sh-nbsd Ta ELF Ta MSB Ta 32
82a85fe12eSEd Maste.It Li elf32-shl-nbsd Ta ELF Ta LSB Ta 32
83a85fe12eSEd Maste.It Li elf32-shbig-linux Ta ELF Ta MSB Ta 32
84a85fe12eSEd Maste.It Li elf32-shl-linux Ta ELF Ta LSB Ta 32
85a85fe12eSEd Maste.It Li elf32-sparc Ta ELF Ta MSB Ta 32
86adb25d1eSEd Maste.It Li elf32-tradbigmips Ta ELF Ta MSB Ta 32
873ca2845dSEd Maste.It Li elf32-tradlittlemips Ta ELF Ta LSB Ta 32
88a85fe12eSEd Maste.It Li elf64-alpha Ta ELF Ta LSB Ta 64
89a85fe12eSEd Maste.It Li elf64-alpha-freebsd Ta ELF Ta LSB Ta 64
90a85fe12eSEd Maste.It Li elf64-big Ta ELF Ta MSB Ta 64
91a85fe12eSEd Maste.It Li elf64-bigmips Ta ELF Ta MSB Ta 64
92a85fe12eSEd Maste.It Li elf64-ia64-big Ta ELF Ta MSB Ta 64
93a85fe12eSEd Maste.It Li elf64-ia64-little Ta ELF Ta LSB Ta 64
94a85fe12eSEd Maste.It Li elf64-little Ta ELF Ta LSB Ta 64
95e85c2b0bSEd Maste.It Li elf64-littleaarch64 Ta ELF Ta LSB Ta 64
96a85fe12eSEd Maste.It Li elf64-littlemips Ta ELF Ta LSB Ta 64
97a85fe12eSEd Maste.It Li elf64-powerpc Ta ELF Ta MSB Ta 64
98bee2765cSEd Maste.It Li elf64-powerpc-freebsd Ta ELF Ta MSB Ta 64
99a85fe12eSEd Maste.It Li elf64-powerpcle Ta ELF Ta LSB Ta 64
100a85fe12eSEd Maste.It Li elf64-sh64 Ta ELF Ta MSB Ta 64
101a85fe12eSEd Maste.It Li elf64-sh64l Ta ELF Ta LSB Ta 64
102a85fe12eSEd Maste.It Li elf64-sh64-nbsd Ta ELF Ta MSB Ta 64
103a85fe12eSEd Maste.It Li elf64-sh64l-nbsd Ta ELF Ta LSB Ta 64
104a85fe12eSEd Maste.It Li elf64-sh64big-linux Ta ELF Ta MSB Ta 64
105a85fe12eSEd Maste.It Li elf64-sh64-linux Ta ELF Ta LSB Ta 64
106a85fe12eSEd Maste.It Li elf64-sparc Ta ELF Ta MSB Ta 64
107a85fe12eSEd Maste.It Li elf64-sparc-freebsd Ta ELF Ta MSB Ta 64
108adb25d1eSEd Maste.It Li elf64-tradbigmips Ta ELF Ta MSB Ta 64
1093ca2845dSEd Maste.It Li elf64-tradlittlemips Ta ELF Ta LSB Ta 64
110a85fe12eSEd Maste.It Li elf64-x86-64 Ta ELF Ta LSB Ta 64
111a85fe12eSEd Maste.It Li elf64-x86-64-freebsd Ta ELF Ta LSB Ta 64
112a85fe12eSEd Maste.It Li ihex Ta IHEX Ta - Ta -
113839529caSEd Maste.It Li pei-i386 Ta PE Ta LSB Ta 32
114839529caSEd Maste.It Li pei-x86-64 Ta PE Ta LSB Ta 64
115a85fe12eSEd Maste.It Li srec Ta SREC Ta - Ta -
116a85fe12eSEd Maste.It Li symbolsrec Ta SREC Ta - Ta -
117a85fe12eSEd Maste.El
118a85fe12eSEd Maste.Pp
119a85fe12eSEd MasteFunction
120a85fe12eSEd Maste.Fn elftc_bfd_target_byteorder
121a85fe12eSEd Mastereturns the ELF byte order associated with target descriptor
122a85fe12eSEd Maste.Ar target .
123a85fe12eSEd Maste.Pp
124a85fe12eSEd MasteFunction
125a85fe12eSEd Maste.Fn elftc_bfd_target_class
126a85fe12eSEd Mastereturns the ELF class associated with target descriptor
127a85fe12eSEd Maste.Ar target .
128a85fe12eSEd Maste.Pp
129a85fe12eSEd MasteFunction
130a85fe12eSEd Maste.Fn elftc_bfd_target_flavor
131a85fe12eSEd Mastereturns the object format associated with target descriptor
132a85fe12eSEd Maste.Ar target .
133a85fe12eSEd MasteThe known object formats are:
134a85fe12eSEd Maste.Bl -tag -offset "XXXX" -width ".Dv ETF_BINARY" -compact
135a85fe12eSEd Maste.It Dv ETF_ELF
136a85fe12eSEd MasteAn ELF object.
137a85fe12eSEd Maste.It Dv ETF_BINARY
138a85fe12eSEd MasteRaw binary.
139a85fe12eSEd Maste.It Dv ETF_IHEX
140a85fe12eSEd MasteAn object encoded in
141a85fe12eSEd Maste.Tn Intel
142a85fe12eSEd Mastehex format.
143a85fe12eSEd Maste.It Dv ETF_NONE
144a85fe12eSEd MasteAn unknown object format.
145a85fe12eSEd Maste.It Dv ETF_SREC
146a85fe12eSEd MasteAn object encoded as S-records.
147a85fe12eSEd Maste.El
148a85fe12eSEd Maste.Sh RETURN VALUES
149a85fe12eSEd MasteFunction
150a85fe12eSEd Maste.Fn elftc_bfd_find_target
151a85fe12eSEd Mastereturns a valid pointer to an opaque binary target descriptor if
152a85fe12eSEd Mastesuccessful, or NULL in case of an error.
153a85fe12eSEd Maste.Pp
154a85fe12eSEd MasteFunction
155a85fe12eSEd Maste.Fn elftc_bfd_target_byteorder
156a85fe12eSEd Mastereturns the ELF byte order associated with the target descriptor; one of
157a85fe12eSEd Maste.Dv ELFDATA2MSB
158a85fe12eSEd Masteor
159a85fe12eSEd Maste.Dv ELFDATA2LSB .
160a85fe12eSEd Maste.Pp
161a85fe12eSEd MasteFunction
162a85fe12eSEd Maste.Fn elftc_bfd_target_class
163a85fe12eSEd Mastereturns the ELF class associated with the target descriptor; one of
164a85fe12eSEd Maste.Dv ELFCLASS32
165a85fe12eSEd Masteor
166a85fe12eSEd Maste.Dv ELFCLASS64 .
167a85fe12eSEd Maste.Pp
168a85fe12eSEd MasteFunction
169a85fe12eSEd Maste.Fn elftc_bfd_target_machine
170a85fe12eSEd Mastereturns the ELF architecture associated with the target descriptor.
171a85fe12eSEd Maste.Pp
172a85fe12eSEd MasteFunction
173a85fe12eSEd Maste.Fn elftc_bfd_target_flavor
174a85fe12eSEd Mastereturns one of
175a85fe12eSEd Maste.Dv ETF_BINARY ,
176a85fe12eSEd Maste.Dv ETF_ELF ,
177a85fe12eSEd Maste.Dv ETF_IHEX
178a85fe12eSEd Masteor
179a85fe12eSEd Maste.Dv ETF_SREC
180a85fe12eSEd Masteif successful or
181a85fe12eSEd Maste.Dv ETF_NONE
182a85fe12eSEd Mastein case of error.
183a85fe12eSEd Maste.Sh EXAMPLES
184a85fe12eSEd MasteTo return descriptor information associated with target name
185a85fe12eSEd Maste.Dq elf64-big
186a85fe12eSEd Masteuse:
187a85fe12eSEd Maste.Bd -literal -offset indent
188a85fe12eSEd Mastestruct Elftc_Bfd_Target *t;
189a85fe12eSEd Maste
190a85fe12eSEd Masteif ((t = elftc_bfd_find_target("elf64-big")) == NULL)
191a85fe12eSEd Maste	errx(EXIT_FAILURE, "Cannot find target descriptor");
192a85fe12eSEd Maste
193a85fe12eSEd Masteprintf("Class: %s\\n", elftc_bfd_target_class(t) == ELFCLASS32 ?
194a85fe12eSEd Maste    "ELFCLASS32" : "ELFCLASS64");
195a85fe12eSEd Masteprintf("Byteorder: %s\\n",
196a85fe12eSEd Maste    elftc_bfd_target_byteorder(t) == ELFDATA2LSB ? "LSB" : "MSB");
197a85fe12eSEd Masteprintf("Flavor: %d\\n", elftc_bfd_target_flavor(t));
198a85fe12eSEd Maste.Ed
199a85fe12eSEd Maste.Sh SEE ALSO
200a85fe12eSEd Maste.Xr elf 3
201