public inbox for libc-ports@sourceware.org
 help / color / mirror / Atom feed
From: Mike Frysinger <vapier@gentoo.org>
To: libc-ports@sourceware.org
Cc: Richard Henderson <rth@twiddle.net>,
	"Joseph S. Myers" <joseph@codesourcery.com>
Subject: [PATCH v2] arm: handle unaligned ABS relocs
Date: Sun, 12 Aug 2012 05:50:00 -0000	[thread overview]
Message-ID: <1344750618-13673-1-git-send-email-vapier@gentoo.org> (raw)
In-Reply-To: <201112121920.17908.vapier@gentoo.org>

When relocating a misaligned R_ARM_ABS32, glibc currently crashes.

URL: https://bugs.gentoo.org/394237
URL: http://gcc.gnu.org/PR51456
Signed-off-by: Mike Frysinger <vapier@gentoo.org>

2012-08-12  Mike Frysinger  <vapier@gentoo.org>

	* sysdeps/arm/dl-machine.h (elf_machine_rel) [R_ARM_ABS32]: Declare
	a new unaligned struct.  Cast reloc_addr to that when updating the
	value it points to.
---
 ports/sysdeps/arm/dl-machine.h |    7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/ports/sysdeps/arm/dl-machine.h b/ports/sysdeps/arm/dl-machine.h
index fe39a5e..ca66e83 100644
--- a/ports/sysdeps/arm/dl-machine.h
+++ b/ports/sysdeps/arm/dl-machine.h
@@ -413,6 +413,10 @@ elf_machine_rel (struct link_map *map, const Elf32_Rel *reloc,
 	  break;
 	case R_ARM_ABS32:
 	  {
+	    struct unaligned
+	      {
+		Elf32_Addr x;
+	      } __attribute__((packed, may_alias));
 # ifndef RTLD_BOOTSTRAP
 	   /* This is defined in rtld.c, but nowhere in the static
 	      libc.a; make the reference weak so static programs can
@@ -431,7 +435,8 @@ elf_machine_rel (struct link_map *map, const Elf32_Rel *reloc,
 		 used while loading those libraries.  */
 	      value -= map->l_addr + refsym->st_value;
 # endif
-	    *reloc_addr += value;
+	    /* Support relocations on mis-aligned offsets.  */
+	    ((struct unaligned *) reloc_addr)->x += value;
 	    break;
 	  }
 	case R_ARM_TLS_DESC:
-- 
1.7.9.7

  parent reply	other threads:[~2012-08-12  5:50 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-13  0:20 [patch] handle unaligned arm abs relocs Mike Frysinger
2011-12-14 22:05 ` Carlos O'Donell
2011-12-14 22:29   ` Mike Frysinger
2011-12-14 22:44     ` Carlos O'Donell
2011-12-15 17:48   ` Richard Henderson
2011-12-19 17:45 ` Joseph S. Myers
2011-12-19 18:27   ` Mike Frysinger
2011-12-19 19:57     ` Joseph S. Myers
2012-08-12  5:50 ` Mike Frysinger [this message]
2012-08-12 13:01   ` [PATCH v2] arm: handle unaligned ABS relocs Joseph S. Myers
2012-08-12 14:35     ` Mike Frysinger
2012-08-12 15:55       ` Joseph S. Myers
2012-08-12 18:51         ` Mike Frysinger
2012-08-12 13:26   ` Carlos O'Donell
2012-08-12 14:05     ` Andreas Schwab
2012-08-12 15:57     ` Joseph S. Myers
2012-08-14 21:49   ` Roland McGrath
2012-08-15  1:38     ` Mike Frysinger

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=1344750618-13673-1-git-send-email-vapier@gentoo.org \
    --to=vapier@gentoo.org \
    --cc=joseph@codesourcery.com \
    --cc=libc-ports@sourceware.org \
    --cc=rth@twiddle.net \
    /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.
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 read-only IMAP folder(s) and NNTP newsgroup(s).