1213688Smm@section File formats 2213688SmmA format is a BFD concept of high level file contents type. The 3213688Smmformats supported by BFD are: 4213688Smm 5213688Smm@itemize @bullet 6213688Smm 7213688Smm@item 8213688Smm@code{bfd_object} 9219001Smm@end itemize 10213688SmmThe BFD may contain data, symbols, relocations and debug info. 11213688Smm 12213688Smm@itemize @bullet 13213688Smm 14213688Smm@item 15213688Smm@code{bfd_archive} 16213688Smm@end itemize 17213688SmmThe BFD contains other BFDs and an optional index. 18213688Smm 19213688Smm@itemize @bullet 20213688Smm 21213688Smm@item 22213688Smm@code{bfd_core} 23213688Smm@end itemize 24213688SmmThe BFD contains the result of an executable core dump. 25213688Smm 26213688Smm@subsection File format functions 27213688Smm 28213688Smm 29213688Smm@findex bfd_check_format 30219001Smm@subsubsection @code{bfd_check_format} 31219001Smm@strong{Synopsis} 32213688Smm@example 33213688Smmbfd_boolean bfd_check_format (bfd *abfd, bfd_format format); 34213688Smm@end example 35213688Smm@strong{Description}@* 36213688SmmVerify if the file attached to the BFD @var{abfd} is compatible 37213688Smmwith the format @var{format} (i.e., one of @code{bfd_object}, 38213688Smm@code{bfd_archive} or @code{bfd_core}). 39213688Smm 40213688SmmIf the BFD has been set to a specific target before the 41213688Smmcall, only the named target and format combination is 42213688Smmchecked. If the target has not been set, or has been set to 43213688Smm@code{default}, then all the known target backends is 44219001Smminterrogated to determine a match. If the default target 45219001Smmmatches, it is used. If not, exactly one target must recognize 46213688Smmthe file, or an error results. 47213688Smm 48213688SmmThe function returns @code{TRUE} on success, otherwise @code{FALSE} 49213688Smmwith one of the following error codes: 50213688Smm 51213688Smm@itemize @bullet 52213688Smm 53219001Smm@item 54219001Smm@code{bfd_error_invalid_operation} - 55219001Smmif @code{format} is not one of @code{bfd_object}, @code{bfd_archive} or 56213688Smm@code{bfd_core}. 57213688Smm 58213688Smm@item 59213688Smm@code{bfd_error_system_call} - 60213688Smmif an error occured during a read - even some file mismatches 61213688Smmcan cause bfd_error_system_calls. 62213688Smm 63213688Smm@item 64213688Smm@code{file_not_recognised} - 65213688Smmnone of the backends recognised the file format. 66213688Smm 67213688Smm@item 68213688Smm@code{bfd_error_file_ambiguously_recognized} - 69213688Smmmore than one backend recognised the file format. 70213688Smm@end itemize 71213688Smm 72213688Smm@findex bfd_check_format_matches 73213688Smm@subsubsection @code{bfd_check_format_matches} 74213688Smm@strong{Synopsis} 75213688Smm@example 76219001Smmbfd_boolean bfd_check_format_matches 77219001Smm (bfd *abfd, bfd_format format, char ***matching); 78219001Smm@end example 79219001Smm@strong{Description}@* 80219001SmmLike @code{bfd_check_format}, except when it returns FALSE with 81219001Smm@code{bfd_errno} set to @code{bfd_error_file_ambiguously_recognized}. In that 82213688Smmcase, if @var{matching} is not NULL, it will be filled in with 83213688Smma NULL-terminated list of the names of the formats that matched, 84213688Smmallocated with @code{malloc}. 85213688SmmThen the user may choose a format and try again. 86213688Smm 87213688SmmWhen done with the list that @var{matching} points to, the caller 88213688Smmshould free it. 89213688Smm 90213688Smm@findex bfd_set_format 91213688Smm@subsubsection @code{bfd_set_format} 92213688Smm@strong{Synopsis} 93213688Smm@example 94213688Smmbfd_boolean bfd_set_format (bfd *abfd, bfd_format format); 95213688Smm@end example 96219001Smm@strong{Description}@* 97219001SmmThis function sets the file format of the BFD @var{abfd} to the 98213688Smmformat @var{format}. If the target set in the BFD does not 99213688Smmsupport the format requested, the format is invalid, or the BFD 100213688Smmis not open for writing, then an error occurs. 101213688Smm 102213688Smm@findex bfd_format_string 103213688Smm@subsubsection @code{bfd_format_string} 104213688Smm@strong{Synopsis} 105213688Smm@example 106213688Smmconst char *bfd_format_string (bfd_format format); 107213688Smm@end example 108213688Smm@strong{Description}@* 109213688SmmReturn a pointer to a const string 110213688Smm@code{invalid}, @code{object}, @code{archive}, @code{core}, or @code{unknown}, 111213688Smmdepending upon the value of @var{format}. 112213688Smm 113213688Smm