From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/3608 Path: news.gmane.org!not-for-mail From: Timo Teras Newsgroups: gmane.linux.lib.musl.general Subject: Re: [PATCH 2/3] Unwind support for ARM EABI Date: Wed, 10 Jul 2013 20:35:18 +0300 Message-ID: <20130710203518.576804e3@vostro> References: <1373463541-17170-1-git-send-email-timo.teras@iki.fi> <1373463541-17170-2-git-send-email-timo.teras@iki.fi> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1373477706 21932 80.91.229.3 (10 Jul 2013 17:35:06 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 10 Jul 2013 17:35:06 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-3612-gllmg-musl=m.gmane.org@lists.openwall.com Wed Jul 10 19:35:08 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 1UwyIF-00021e-1O for gllmg-musl@plane.gmane.org; Wed, 10 Jul 2013 19:35:07 +0200 Original-Received: (qmail 9450 invoked by uid 550); 10 Jul 2013 17:35:06 -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 9442 invoked from network); 10 Jul 2013 17:35:05 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:date:from:to:subject:message-id:in-reply-to:references :x-mailer:mime-version:content-type:content-transfer-encoding; bh=P15EqfAqXvyahNMXYBqXeSnDKIB3mba/psn6vyF+o4k=; b=oU5b981xZeJjgsoYA8oyEJVwl5mTEakLYeiN7luSs/ClEybdEvfMzgRJg9qFDOqjCZ hV9D11ykxdHApNdhMLVSPdhWDtikJLyy+5vdh6BZlVS7vUxeMXChEMo5RDhcSdhZerir y4pd7YGiNIkwsjWOiXa0T/r3sfU0oywj50rtCqtgvuYWyvUwcF/H0FgkZaDh9m2JLiRt sacIeMAiqm4K9MlJd2Dxx2OMO7o3CDAOguuXEmcsetRW7yQyRP96uhLq9BIoQnRXzNw1 7nnnrKfOxxSBG58CVvvIPxuXyBNZhcs8UYkjtaJlSovpCi+sotKuL65/AiegcY+DUxXf ftqw== X-Received: by 10.15.99.2 with SMTP id bk2mr37463192eeb.76.1373477694471; Wed, 10 Jul 2013 10:34:54 -0700 (PDT) Original-Sender: =?UTF-8?Q?Timo_Ter=C3=A4s?= In-Reply-To: <1373463541-17170-2-git-send-email-timo.teras@iki.fi> X-Mailer: Claws Mail 3.9.2 (GTK+ 2.24.17; i686-pc-linux-gnu) Xref: news.gmane.org gmane.linux.lib.musl.general:3608 Archived-At: On Wed, 10 Jul 2013 16:39:00 +0300 Timo Ter=C3=A4s wrote: > 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. >=20 > 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 >=20 > 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; As noted on #musl, this has __attribute__((pointer)) in the original definition. But trying to avoid the #include on GCC's headers, and the GCCisms.=20 Would uintptr_t be more suitable here then? > +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 =3D ptr; > + const ElfW(Phdr) *phdr =3D info->dlpi_phdr; > + _Unwind_Ptr addr; > + int match =3D 0, i; > + > + for (i =3D info->dlpi_phnum; i > 0; i--, phdr++) { > + addr =3D info->dlpi_addr + phdr->p_vaddr; > + switch (phdr->p_type) { > + case PT_LOAD: > + match |=3D data->pc >=3D addr && data->pc < addr > + phdr->p_memsz; > + break; > + case PT_ARM_EXIDX: > + data->exidx_start =3D addr; > + data->exidx_len =3D phdr->p_memsz; > + break; > + } > + } > + return match; > +} The above function has a slight bug in it, so I'll fix that for next send. Basically it can return other dso's exidx data if the matching dso did not have PT_ARM_EXIDX at all. - Timo