From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/3602 Path: news.gmane.org!not-for-mail From: =?UTF-8?q?Timo=20Ter=C3=A4s?= Newsgroups: gmane.linux.lib.musl.general Subject: [PATCH 2/3] Unwind support for ARM EABI Date: Wed, 10 Jul 2013 16:39:00 +0300 Message-ID: <1373463541-17170-2-git-send-email-timo.teras@iki.fi> References: <1373463541-17170-1-git-send-email-timo.teras@iki.fi> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org X-Trace: ger.gmane.org 1373463539 16233 80.91.229.3 (10 Jul 2013 13:38:59 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 10 Jul 2013 13:38:59 +0000 (UTC) Cc: =?UTF-8?q?Timo=20Ter=C3=A4s?= To: musl@lists.openwall.com Original-X-From: musl-return-3607-gllmg-musl=m.gmane.org@lists.openwall.com Wed Jul 10 15:39:00 2013 Return-path: Envelope-to: gllmg-musl@plane.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by plane.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1Uwubg-0008HA-GS for gllmg-musl@plane.gmane.org; Wed, 10 Jul 2013 15:38:56 +0200 Original-Received: (qmail 1417 invoked by uid 550); 10 Jul 2013 13:38:55 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Original-Received: (qmail 1405 invoked from network); 10 Jul 2013 13:38:55 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; bh=YMe/PctZXRDDc36wowbx0Q6V1WeqrbSUrcwQ1vO44gI=; b=kFpPg0U+XiGUttOsb125en8cZLuP9LQgasjohFMoCPnm9+1kyNkxsjJ10Z08dotMCz depnS19pRzB2V6K4ltYl6oS9FSQKmjerQSItmNp6hYzAoMV40+GrFbxhaqPfsnOwoP0R raHiIz5RBMRFkbgBxhACElGynwn3wKaaQdGB04AQpu6eElnqXrVt0JD8VQFo9JQtyEMp xowiQZVciIlkwOUjdnztxjEG99H0uky4IDEGk2TTb80zsQVNsQwLZfuVkbRV+MPHLkMj DFYi2x+k30RgSJvL2+ZoII3IRC8t4/w2Sz6CWOHgcSONwzfuccUgsSBc4CH1OhpBiQd4 ReFQ== X-Received: by 10.14.224.201 with SMTP id x49mr35874630eep.6.1373463523678; Wed, 10 Jul 2013 06:38:43 -0700 (PDT) Original-Sender: =?UTF-8?Q?Timo_Ter=C3=A4s?= X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1373463541-17170-1-git-send-email-timo.teras@iki.fi> Xref: news.gmane.org gmane.linux.lib.musl.general:3602 Archived-At: 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 | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 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..ffbea1f --- /dev/null +++ b/arch/arm/src/find_exidx.c @@ -0,0 +1,44 @@ +#define _GNU_SOURCE +#include + +typedef unsigned _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; + int match = 0, i; + + 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: + data->exidx_start = addr; + data->exidx_len = phdr->p_memsz; + break; + } + } + return match; +} + +_Unwind_Ptr __gnu_Unwind_Find_exidx(_Unwind_Ptr pc, int * pcount) +{ + struct find_exidx_data data; + + data.pc = pc; + data.exidx_start = 0; + if (dl_iterate_phdr(find_exidx, &data) <= 0) + return 0; + *pcount = data.exidx_len / 8; + return data.exidx_start; +} + -- 1.8.3.2