arm: handle unaligned ABS relocs

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>
This commit is contained in:
Mike Frysinger 2012-01-01 02:36:32 -05:00
parent 121dce05fe
commit 3447612d3c
2 changed files with 12 additions and 1 deletions

View File

@ -1,3 +1,9 @@
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.
2012-08-09 Roland McGrath <roland@hack.frob.com> 2012-08-09 Roland McGrath <roland@hack.frob.com>
* sysdeps/arm/arm-features.h: Document ARM_ASSUME_NO_IWMMXT. * sysdeps/arm/arm-features.h: Document ARM_ASSUME_NO_IWMMXT.

View File

@ -413,6 +413,10 @@ elf_machine_rel (struct link_map *map, const Elf32_Rel *reloc,
break; break;
case R_ARM_ABS32: case R_ARM_ABS32:
{ {
struct unaligned
{
Elf32_Addr x;
} __attribute__((packed, may_alias));
# ifndef RTLD_BOOTSTRAP # ifndef RTLD_BOOTSTRAP
/* This is defined in rtld.c, but nowhere in the static /* This is defined in rtld.c, but nowhere in the static
libc.a; make the reference weak so static programs can 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. */ used while loading those libraries. */
value -= map->l_addr + refsym->st_value; value -= map->l_addr + refsym->st_value;
# endif # endif
*reloc_addr += value; /* Support relocations on mis-aligned offsets. */
((struct unaligned *) reloc_addr)->x += value;
break; break;
} }
case R_ARM_TLS_DESC: case R_ARM_TLS_DESC: