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