ex_tables.h revision cf8d5e41af582b9070576889dcc479397a19bf48
1bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant/* libunwind - a platform-independent unwind library 2bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant Copyright 2011 Linaro Limited 3f5256e16dfc425c1d466f6308d4026d529ce9e0bHoward Hinnant 4bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard HinnantThis file is part of libunwind. 5b64f8b07c104c6cc986570ac8ee0ed16a9f23976Howard Hinnant 6b64f8b07c104c6cc986570ac8ee0ed16a9f23976Howard HinnantPermission is hereby granted, free of charge, to any person obtaining 7bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnanta copy of this software and associated documentation files (the 8bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant"Software"), to deal in the Software without restriction, including 9bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnantwithout limitation the rights to use, copy, modify, merge, publish, 10bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnantdistribute, sublicense, and/or sell copies of the Software, and to 11bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnantpermit persons to whom the Software is furnished to do so, subject to 12bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnantthe following conditions: 130e20cae1a5be18fba591cd884aa2a389b66a3f49Howard Hinnant 140e20cae1a5be18fba591cd884aa2a389b66a3f49Howard HinnantThe above copyright notice and this permission notice shall be 150e20cae1a5be18fba591cd884aa2a389b66a3f49Howard Hinnantincluded in all copies or substantial portions of the Software. 16bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant 17bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard HinnantTHE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard HinnantEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard HinnantMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard HinnantNONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 21bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard HinnantLIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 22bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard HinnantOF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 23bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard HinnantWITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ 24bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant 25bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant#ifndef ARM_EX_TABLES_H 26bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant#define ARM_EX_TABLES_H 27bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant 28struct arm_exidx_entry { 29 uint32_t addr; 30 uint32_t data; 31}; 32 33struct arm_exidx_table { 34 const char *name; 35 struct arm_exidx_entry *start; 36 struct arm_exidx_entry *end; 37 void *start_addr; 38 void *end_addr; 39#ifdef ARM_EXIDX_TABLE_MALLOC 40 struct arm_exidx_table *next; 41#endif 42}; 43 44 45typedef enum arm_exbuf_cmd { 46 ARM_EXIDX_CMD_FINISH, 47 ARM_EXIDX_CMD_DATA_PUSH, 48 ARM_EXIDX_CMD_DATA_POP, 49 ARM_EXIDX_CMD_REG_POP, 50 ARM_EXIDX_CMD_REG_TO_SP, 51 ARM_EXIDX_CMD_VFP_POP, 52 ARM_EXIDX_CMD_WREG_POP, 53 ARM_EXIDX_CMD_WCGR_POP, 54 ARM_EXIDX_CMD_RESERVED, 55 ARM_EXIDX_CMD_REFUSED, 56} arm_exbuf_cmd_t; 57 58enum arm_exbuf_cmd_flags { 59 ARM_EXIDX_VFP_SHIFT_16 = 1 << 16, 60 ARM_EXIDX_VFP_DOUBLE = 1 << 17, 61}; 62 63#define ARM_EXBUF_START(x) (((x) >> 4) & 0x0f) 64#define ARM_EXBUF_COUNT(x) ((x) & 0x0f) 65#define ARM_EXBUF_END(x) (ARM_EXBUF_START(x) + ARM_EXBUF_COUNT(x)) 66 67struct arm_exbuf_data 68{ 69 arm_exbuf_cmd_t cmd; 70 uint32_t data; 71}; 72 73static inline void * 74prel31_to_addr (void *addr) 75{ 76 uint32_t offset = ((long)*(uint32_t *)addr << 1) >> 1; 77 return (char *)addr + offset; 78} 79 80int arm_exidx_init_local (const char *appname); 81 82int arm_exidx_table_add (const char *name, 83 struct arm_exidx_entry *start, struct arm_exidx_entry *end); 84struct arm_exidx_table *arm_exidx_table_find (void *pc); 85struct arm_exidx_entry *arm_exidx_table_lookup ( 86 struct arm_exidx_table *table, void *pc); 87 88void arm_exidx_section_find (struct elf_image *ei, 89 Elf_W (Shdr) **exidx, Elf_W (Shdr) **extbl); 90int arm_exidx_entry_lookup (struct elf_image *ei, 91 Elf_W (Shdr) *exidx, uint32_t ip); 92int arm_exidx_entry_extract (struct elf_image *ei, 93 Elf_W (Shdr) *exidx, Elf_W (Shdr) *extbl, 94 unsigned i, uint8_t *buf); 95int arm_exidx_extract (struct arm_exidx_entry *entry, uint8_t *buf); 96 97int arm_exidx_decode (const uint8_t *buf, uint8_t len, 98 struct dwarf_cursor *c); 99int arm_exidx_apply_cmd (struct arm_exbuf_data *edata, struct dwarf_cursor *c); 100 101#endif // ARM_EX_TABLES_H 102