From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22103 invoked by alias); 12 Aug 2012 13:26:58 -0000 Received: (qmail 22095 invoked by uid 22791); 12 Aug 2012 13:26:58 -0000 X-SWARE-Spam-Status: No, hits=-4.9 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,FREEMAIL_FROM,KHOP_RCVD_TRUST,KHOP_THREADED,RCVD_IN_DNSWL_LOW,RCVD_IN_HOSTKARMA_YE,TW_FN X-Spam-Check-By: sourceware.org Received: from mail-vc0-f169.google.com (HELO mail-vc0-f169.google.com) (209.85.220.169) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sun, 12 Aug 2012 13:26:43 +0000 Received: by vcbfl10 with SMTP id fl10so3209143vcb.0 for ; Sun, 12 Aug 2012 06:26:42 -0700 (PDT) MIME-Version: 1.0 Received: by 10.52.21.174 with SMTP id w14mr5769375vde.24.1344778002718; Sun, 12 Aug 2012 06:26:42 -0700 (PDT) Received: by 10.58.236.198 with HTTP; Sun, 12 Aug 2012 06:26:42 -0700 (PDT) In-Reply-To: <1344750618-13673-1-git-send-email-vapier@gentoo.org> References: <201112121920.17908.vapier@gentoo.org> <1344750618-13673-1-git-send-email-vapier@gentoo.org> Date: Sun, 12 Aug 2012 13:26:00 -0000 Message-ID: Subject: Re: [PATCH v2] arm: handle unaligned ABS relocs From: "Carlos O'Donell" To: Mike Frysinger Cc: libc-ports@sourceware.org, Richard Henderson , "Joseph S. Myers" Content-Type: text/plain; charset=ISO-8859-1 X-IsSubscribed: yes Mailing-List: contact libc-ports-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: libc-ports-owner@sourceware.org X-SW-Source: 2012-08/txt/msg00102.txt.bz2 On Sun, Aug 12, 2012 at 1:50 AM, Mike Frysinger wrote: > 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 > > 2012-08-12 Mike Frysinger > > * 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. Almost every other architecture that does this uses a char array and pulls the data out of the char array. Why? > --- > 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)); Packed only says that the internals of the structure will be packed with minimal alignment. It doesn't say anything about the alignment of the structure itself IIRC. Will this actually do what you want consistently and across supported compiler versions? As opposed to the char array method used by other machines. > # 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 > Cheers, Carlos.