|
Message-Id: <1373481699-17888-1-git-send-email-timo.teras@iki.fi> Date: Wed, 10 Jul 2013 21:41:39 +0300 From: Timo Teräs <timo.teras@....fi> To: musl@...ts.openwall.com Cc: Timo Teräs <timo.teras@....fi> Subject: [PATCH v2] Unwind support for ARM EABI ARM EABI does not use the .eh_frame and .eh_frame_hdr for unwinding. Instead the ABI specifies it's own way to unwind using .ARM.exidx and .ARM.extab. libgcc uses __gnu_Unwind_Find_exidx (libc must implement this) when unwinding using exidx. This function is implemented here. --- arch/arm/src/find_exidx.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 arch/arm/src/find_exidx.c diff --git a/arch/arm/src/find_exidx.c b/arch/arm/src/find_exidx.c new file mode 100644 index 0000000..8ba9f30 --- /dev/null +++ b/arch/arm/src/find_exidx.c @@ -0,0 +1,46 @@ +#define _GNU_SOURCE +#include <link.h> +#include <stdint.h> + +typedef uintptr_t _Unwind_Ptr; + +struct find_exidx_data { + _Unwind_Ptr pc, exidx_start; + int exidx_len; +}; + +static int find_exidx(struct dl_phdr_info *info, size_t size, void *ptr) +{ + struct find_exidx_data *data = ptr; + const ElfW(Phdr) *phdr = info->dlpi_phdr; + _Unwind_Ptr addr, exidx_start = 0; + int i, match = 0, exidx_len = 0; + + for (i = info->dlpi_phnum; i > 0; i--, phdr++) { + addr = info->dlpi_addr + phdr->p_vaddr; + switch (phdr->p_type) { + case PT_LOAD: + match |= data->pc >= addr && data->pc < addr + phdr->p_memsz; + break; + case PT_ARM_EXIDX: + exidx_start = addr; + exidx_len = phdr->p_memsz; + break; + } + } + if (match) { + data->exidx_start = exidx_start; + data->exidx_len = exidx_len; + } + return match; +} + +_Unwind_Ptr __gnu_Unwind_Find_exidx(_Unwind_Ptr pc, int *pcount) +{ + struct find_exidx_data data; + data.pc = pc; + if (dl_iterate_phdr(find_exidx, &data) <= 0) + return 0; + *pcount = data.exidx_len / 8; + return data.exidx_start; +} -- 1.8.3.2
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.