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 3174 2015-03-27 17:13:41Z emaste $ 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 60 #define ELFTC_FAILURE 0 61 #define ELFTC_ISDIGIT(C) (isdigit((C) & 0xFF)) 62 #define ELFTC_SUCCESS 1 63 64 #define VECTOR_DEF_CAPACITY 8 65 66 67 #ifdef __cplusplus 68 extern "C" { 69 #endif 70 char *cpp_demangle_ARM(const char *_org); 71 char *cpp_demangle_gnu2(const char *_org); 72 char *cpp_demangle_gnu3(const char *_org); 73 bool is_cpp_mangled_ARM(const char *_org); 74 bool is_cpp_mangled_gnu2(const char *_org); 75 bool is_cpp_mangled_gnu3(const char *_org); 76 unsigned int libelftc_hash_string(const char *); 77 void vector_str_dest(struct vector_str *_vec); 78 int vector_str_find(const struct vector_str *_vs, const char *_str, 79 size_t _len); 80 char *vector_str_get_flat(const struct vector_str *_vs, size_t *_len); 81 bool vector_str_init(struct vector_str *_vs); 82 bool vector_str_pop(struct vector_str *_vs); 83 bool vector_str_push(struct vector_str *_vs, const char *_str, 84 size_t _len); 85 bool vector_str_push_vector_head(struct vector_str *_dst, 86 struct vector_str *_org); 87 char *vector_str_substr(const struct vector_str *_vs, size_t _begin, 88 size_t _end, size_t *_rlen); 89 #ifdef __cplusplus 90 } 91 #endif 92 93 #endif /* __LIBELFTC_H */ 94