This is the mail archive of the libc-ports@sources.redhat.com mailing list for the libc-ports project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [patch] handle unaligned arm abs relocs


On Wednesday 14 December 2011 17:05:25 Carlos O'Donell wrote:
> On 12/12/2011 7:20 PM, Mike Frysinger wrote:
> > background can be found here:
> > http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51456
> > 
> > 2011-12-12  Mike Frysinger  <vapier@gentoo.org>
> > 
> > 	* dl-machine.h (elf_machine_rel, R_ARM_ABS32): Declare "reloc_value".
> > 	Replace reloc_addr addition with memcpy's.
> > 
> > diff --git a/sysdeps/arm/dl-machine.h b/sysdeps/arm/dl-machine.h
> > index 5ceeaa9..fe64800 100644
> > --- a/sysdeps/arm/dl-machine.h
> > +++ b/sysdeps/arm/dl-machine.h
> > @@ -413,6 +413,7 @@ elf_machine_rel (struct link_map *map, const
> >  	  break;
> >  	case R_ARM_ABS32:
> >  	  {
> > +	    Elf32_Addr reloc_value;
> >  # 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 +432,10 @@ elf_machine_rel (struct link_map *map, const
> >  		 used while loading those libraries.  */
> >  	      value -= map->l_addr + refsym->st_value;
> >  # endif
> > -	    *reloc_addr += value;
> > +	    /* Support relocations on mis-aligned offsets.  */
> > +	    memcpy (&reloc_value, reloc_addr_arg, sizeof (reloc_value));
> > +	    reloc_value += value;
> > +	    memcpy (reloc_addr_arg, &reloc_value, sizeof (reloc_value));
> 
> I don't believe that memcpy is safe this early in the loader.
> 
> You might be lucky and get an inlined memcpy or builtin, but you
> might not and if you go through the PLT you'll fault since
> it's not yet setup.

i thought it should be OK because R_ARM_COPY already calls memcpy() a few 
lines up, but i don't know the ARM loader that well to say what is necessary

looking at the relocs that exist on my local arm ldso and i only see:
	R_ARM_RELATIVE
	R_ARM_GLOB_DAT
	R_ARM_JUMP_SLOT

hopefully someone who understands ARM better can comment ...
-mike

Attachment: signature.asc
Description: This is a digitally signed message part.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]