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