1a85fe12eSEd Maste /*- 2a85fe12eSEd Maste * Copyright (c) 2009 Kai Wang 3a85fe12eSEd Maste * Copyright (c) 2007,2008 Hyogeol Lee <hyogeollee@gmail.com> 4a85fe12eSEd Maste * All rights reserved. 5a85fe12eSEd Maste * 6a85fe12eSEd Maste * Redistribution and use in source and binary forms, with or without 7a85fe12eSEd Maste * modification, are permitted provided that the following conditions 8a85fe12eSEd Maste * are met: 9a85fe12eSEd Maste * 1. Redistributions of source code must retain the above copyright 10a85fe12eSEd Maste * notice, this list of conditions and the following disclaimer 11a85fe12eSEd Maste * in this position and unchanged. 12a85fe12eSEd Maste * 2. Redistributions in binary form must reproduce the above copyright 13a85fe12eSEd Maste * notice, this list of conditions and the following disclaimer in the 14a85fe12eSEd Maste * documentation and/or other materials provided with the distribution. 15a85fe12eSEd Maste * 16a85fe12eSEd Maste * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR 17a85fe12eSEd Maste * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 18a85fe12eSEd Maste * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 19a85fe12eSEd Maste * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 20a85fe12eSEd Maste * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21a85fe12eSEd Maste * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22a85fe12eSEd Maste * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23a85fe12eSEd Maste * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24a85fe12eSEd Maste * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 25a85fe12eSEd Maste * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26a85fe12eSEd Maste * 2718f4c9dbSEd Maste * $Id: _libelftc.h 3531 2017-06-05 05:08:43Z kaiwang27 $ 28a85fe12eSEd Maste */ 29a85fe12eSEd Maste 30a85fe12eSEd Maste #ifndef __LIBELFTC_H_ 31a85fe12eSEd Maste #define __LIBELFTC_H_ 32a85fe12eSEd Maste 33a85fe12eSEd Maste #include <stdbool.h> 34a85fe12eSEd Maste 35a85fe12eSEd Maste #include "_elftc.h" 36a85fe12eSEd Maste 37a85fe12eSEd Maste struct _Elftc_Bfd_Target { 38a85fe12eSEd Maste const char *bt_name; /* target name. */ 39a85fe12eSEd Maste unsigned int bt_type; /* target type. */ 40a85fe12eSEd Maste unsigned int bt_byteorder; /* elf target byteorder. */ 41a85fe12eSEd Maste unsigned int bt_elfclass; /* elf target class (32/64bit). */ 42a85fe12eSEd Maste unsigned int bt_machine; /* elf target arch. */ 43a85fe12eSEd Maste unsigned int bt_osabi; /* elf target abi. */ 44a85fe12eSEd Maste }; 45a85fe12eSEd Maste 46a85fe12eSEd Maste extern struct _Elftc_Bfd_Target _libelftc_targets[]; 47a85fe12eSEd Maste 48a85fe12eSEd Maste /** @brief Dynamic vector data for string. */ 49a85fe12eSEd Maste struct vector_str { 50a85fe12eSEd Maste /** Current size */ 51a85fe12eSEd Maste size_t size; 52a85fe12eSEd Maste /** Total capacity */ 53a85fe12eSEd Maste size_t capacity; 54a85fe12eSEd Maste /** String array */ 55a85fe12eSEd Maste char **container; 56a85fe12eSEd Maste }; 57a85fe12eSEd Maste 58a85fe12eSEd Maste #define BUFFER_GROWFACTOR 1.618 59*c2bffd0aSDimitry Andric #define BUFFER_GROW(x) (((x)+0.5)*BUFFER_GROWFACTOR) 60a85fe12eSEd Maste 61a85fe12eSEd Maste #define ELFTC_FAILURE 0 62a85fe12eSEd Maste #define ELFTC_ISDIGIT(C) (isdigit((C) & 0xFF)) 63a85fe12eSEd Maste #define ELFTC_SUCCESS 1 64a85fe12eSEd Maste 65a85fe12eSEd Maste #define VECTOR_DEF_CAPACITY 8 66a85fe12eSEd Maste 67a85fe12eSEd Maste 6867d97fe7SEd Maste #ifdef __cplusplus 6967d97fe7SEd Maste extern "C" { 7067d97fe7SEd Maste #endif 71a85fe12eSEd Maste char *cpp_demangle_ARM(const char *_org); 72a85fe12eSEd Maste char *cpp_demangle_gnu2(const char *_org); 73a85fe12eSEd Maste char *cpp_demangle_gnu3(const char *_org); 74a85fe12eSEd Maste bool is_cpp_mangled_ARM(const char *_org); 75a85fe12eSEd Maste bool is_cpp_mangled_gnu2(const char *_org); 76a85fe12eSEd Maste bool is_cpp_mangled_gnu3(const char *_org); 77a85fe12eSEd Maste unsigned int libelftc_hash_string(const char *); 78a85fe12eSEd Maste void vector_str_dest(struct vector_str *_vec); 79a85fe12eSEd Maste int vector_str_find(const struct vector_str *_vs, const char *_str, 80a85fe12eSEd Maste size_t _len); 81a85fe12eSEd Maste char *vector_str_get_flat(const struct vector_str *_vs, size_t *_len); 82a85fe12eSEd Maste bool vector_str_init(struct vector_str *_vs); 83a85fe12eSEd Maste bool vector_str_pop(struct vector_str *_vs); 84a85fe12eSEd Maste bool vector_str_push(struct vector_str *_vs, const char *_str, 85a85fe12eSEd Maste size_t _len); 8618f4c9dbSEd Maste bool vector_str_push_vector(struct vector_str *_dst, 8718f4c9dbSEd Maste struct vector_str *_org); 88a85fe12eSEd Maste bool vector_str_push_vector_head(struct vector_str *_dst, 89a85fe12eSEd Maste struct vector_str *_org); 90a85fe12eSEd Maste char *vector_str_substr(const struct vector_str *_vs, size_t _begin, 91a85fe12eSEd Maste size_t _end, size_t *_rlen); 9267d97fe7SEd Maste #ifdef __cplusplus 9367d97fe7SEd Maste } 9467d97fe7SEd Maste #endif 95a85fe12eSEd Maste 96a85fe12eSEd Maste #endif /* __LIBELFTC_H */ 97