xref: /freebsd/contrib/elftoolchain/libelftc/libelftc.h (revision a85fe12e361c14018a24f0f7714663b490206c7f)
1*a85fe12eSEd Maste /*-
2*a85fe12eSEd Maste  * Copyright (c) 2009 Kai Wang
3*a85fe12eSEd Maste  * All rights reserved.
4*a85fe12eSEd Maste  *
5*a85fe12eSEd Maste  * Redistribution and use in source and binary forms, with or without
6*a85fe12eSEd Maste  * modification, are permitted provided that the following conditions
7*a85fe12eSEd Maste  * are met:
8*a85fe12eSEd Maste  * 1. Redistributions of source code must retain the above copyright
9*a85fe12eSEd Maste  *    notice, this list of conditions and the following disclaimer
10*a85fe12eSEd Maste  *    in this position and unchanged.
11*a85fe12eSEd Maste  * 2. Redistributions in binary form must reproduce the above copyright
12*a85fe12eSEd Maste  *    notice, this list of conditions and the following disclaimer in the
13*a85fe12eSEd Maste  *    documentation and/or other materials provided with the distribution.
14*a85fe12eSEd Maste  *
15*a85fe12eSEd Maste  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
16*a85fe12eSEd Maste  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17*a85fe12eSEd Maste  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18*a85fe12eSEd Maste  * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
19*a85fe12eSEd Maste  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20*a85fe12eSEd Maste  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21*a85fe12eSEd Maste  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22*a85fe12eSEd Maste  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23*a85fe12eSEd Maste  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24*a85fe12eSEd Maste  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25*a85fe12eSEd Maste  *
26*a85fe12eSEd Maste  * $FreeBSD: users/kaiwang27/elftc/libelftc.h 392 2009-05-31 19:17:46Z kaiwang27 $
27*a85fe12eSEd Maste  * $Id: libelftc.h 2863 2013-01-06 03:18:32Z jkoshy $
28*a85fe12eSEd Maste  */
29*a85fe12eSEd Maste 
30*a85fe12eSEd Maste #ifndef	_LIBELFTC_H_
31*a85fe12eSEd Maste #define	_LIBELFTC_H_
32*a85fe12eSEd Maste 
33*a85fe12eSEd Maste #include <sys/stat.h>
34*a85fe12eSEd Maste 
35*a85fe12eSEd Maste #include <libelf.h>
36*a85fe12eSEd Maste 
37*a85fe12eSEd Maste typedef struct _Elftc_Bfd_Target Elftc_Bfd_Target;
38*a85fe12eSEd Maste typedef struct _Elftc_String_Table Elftc_String_Table;
39*a85fe12eSEd Maste 
40*a85fe12eSEd Maste /* Target types. */
41*a85fe12eSEd Maste typedef enum {
42*a85fe12eSEd Maste 	ETF_NONE,
43*a85fe12eSEd Maste 	ETF_ELF,
44*a85fe12eSEd Maste 	ETF_BINARY,
45*a85fe12eSEd Maste 	ETF_SREC,
46*a85fe12eSEd Maste 	ETF_IHEX
47*a85fe12eSEd Maste } Elftc_Bfd_Target_Flavor;
48*a85fe12eSEd Maste 
49*a85fe12eSEd Maste /*
50*a85fe12eSEd Maste  * Demangler flags.
51*a85fe12eSEd Maste  */
52*a85fe12eSEd Maste 
53*a85fe12eSEd Maste /* Name mangling style. */
54*a85fe12eSEd Maste #define	ELFTC_DEM_UNKNOWN	0x00000000U /* Not specified. */
55*a85fe12eSEd Maste #define	ELFTC_DEM_ARM		0x00000001U /* C++ Ann. Ref. Manual. */
56*a85fe12eSEd Maste #define	ELFTC_DEM_GNU2		0x00000002U /* GNU version 2. */
57*a85fe12eSEd Maste #define	ELFTC_DEM_GNU3		0x00000004U /* GNU version 3. */
58*a85fe12eSEd Maste 
59*a85fe12eSEd Maste /* Demangling behaviour control. */
60*a85fe12eSEd Maste #define ELFTC_DEM_NOPARAM	0x00010000U
61*a85fe12eSEd Maste 
62*a85fe12eSEd Maste __BEGIN_DECLS
63*a85fe12eSEd Maste Elftc_Bfd_Target	*elftc_bfd_find_target(const char *_tgt_name);
64*a85fe12eSEd Maste Elftc_Bfd_Target_Flavor	 elftc_bfd_target_flavor(Elftc_Bfd_Target *_tgt);
65*a85fe12eSEd Maste unsigned int	elftc_bfd_target_byteorder(Elftc_Bfd_Target *_tgt);
66*a85fe12eSEd Maste unsigned int	elftc_bfd_target_class(Elftc_Bfd_Target *_tgt);
67*a85fe12eSEd Maste unsigned int	elftc_bfd_target_machine(Elftc_Bfd_Target *_tgt);
68*a85fe12eSEd Maste int		elftc_copyfile(int _srcfd,  int _dstfd);
69*a85fe12eSEd Maste int		elftc_demangle(const char *_mangledname, char *_buffer,
70*a85fe12eSEd Maste     size_t _bufsize, unsigned int _flags);
71*a85fe12eSEd Maste int		elftc_set_timestamps(const char *_filename, struct stat *_sb);
72*a85fe12eSEd Maste Elftc_String_Table	*elftc_string_table_create(int _hint);
73*a85fe12eSEd Maste void		elftc_string_table_destroy(Elftc_String_Table *_table);
74*a85fe12eSEd Maste Elftc_String_Table	*elftc_string_table_from_section(Elf_Scn *_scn,
75*a85fe12eSEd Maste     int _hint);
76*a85fe12eSEd Maste const char	*elftc_string_table_image(Elftc_String_Table *_table,
77*a85fe12eSEd Maste     size_t *_sz);
78*a85fe12eSEd Maste size_t		elftc_string_table_insert(Elftc_String_Table *_table,
79*a85fe12eSEd Maste     const char *_string);
80*a85fe12eSEd Maste size_t		elftc_string_table_lookup(Elftc_String_Table *_table,
81*a85fe12eSEd Maste     const char *_string);
82*a85fe12eSEd Maste int		elftc_string_table_remove(Elftc_String_Table *_table,
83*a85fe12eSEd Maste     const char *_string);
84*a85fe12eSEd Maste const char	*elftc_string_table_to_string(Elftc_String_Table *_table,
85*a85fe12eSEd Maste     size_t offset);
86*a85fe12eSEd Maste const char	*elftc_version(void);
87*a85fe12eSEd Maste __END_DECLS
88*a85fe12eSEd Maste 
89*a85fe12eSEd Maste #endif	/* _LIBELFTC_H_ */
90