mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Timo Teras <timo.teras@iki.fi>
To: musl@lists.openwall.com
Subject: Re: [PATCH 2/3] Unwind support for ARM EABI
Date: Wed, 10 Jul 2013 20:35:18 +0300	[thread overview]
Message-ID: <20130710203518.576804e3@vostro> (raw)
In-Reply-To: <1373463541-17170-2-git-send-email-timo.teras@iki.fi>

On Wed, 10 Jul 2013 16:39:00 +0300
Timo Teräs <timo.teras@iki.fi> 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.
> 
> 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 <link.h>
> +
> +typedef unsigned _Unwind_Ptr;

As noted on #musl, this has  __attribute__((pointer)) in the original
definition. But trying to avoid the #include <unwind.h> on GCC's
headers, and the GCCisms. 

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 = 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;
> +}

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


  reply	other threads:[~2013-07-10 17:35 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-10 13:38 [PATCH 1/3] PIE support for arm Timo Teräs
2013-07-10 13:39 ` [PATCH 2/3] Unwind support for ARM EABI Timo Teräs
2013-07-10 17:35   ` Timo Teras [this message]
2013-07-10 18:05     ` Rich Felker
2013-07-10 18:41       ` [PATCH v2] " Timo Teräs
2013-07-10 19:55         ` [PATCH v3] " Timo Teräs
2013-07-10 13:39 ` [PATCH 3/3] [FYI] fix dynamic linker dso loading Timo Teräs
2013-07-10 15:00   ` Rich Felker
2013-07-10 15:47     ` Timo Teras
2013-07-10 16:52       ` Richard Felker
2013-07-10 19:23 ` [PATCH 1/3] PIE support for arm (copyright...) Isaac
2013-07-10 19:28   ` Rich Felker
2013-07-10 21:03     ` Rich Felker

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20130710203518.576804e3@vostro \
    --to=timo.teras@iki.fi \
    --cc=musl@lists.openwall.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).