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