This is the mail archive of the libc-alpha@sources.redhat.com mailing list for the glibc 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: don't assume reloc_addr passed to elf_machine_rel* is aligned


On Jun 24, 2003, Roland McGrath <roland@redhat.com> wrote:

> s390/s390-32/dl-machine.h for example uses Elf32_Addr *reloc_addr for most
> of its reloc types, but casts it to char* or short* for some relocs.  As I
> understand it, the safer thing would be to use void *reloc_addr and use
> `*(Elf32_Addr *) reloc_addr' each place plain `*reloc_addr' now appears.

Right.  Casting to a type that requires less alignment doesn't
necessarily make the compiler forget the address was more alignment.

> Even in a case like i386, I wonder if the use as void * in memcpy for
> R_386_COPY relocs might be a possible source of trouble.  The compiler is
> free to turn that memcpy into inline checks for sizes like 4 and use a word
> store for that.

That's exactly why we changed the prototype for mips, and I posted the
patch that I reposted today, and then it was suggested to me to change
the prototype, such that all arches could win.

>> Would reloc__addr be any better?

> You're kidding, right?

'fraid not.  Clearly I have no taste :-D

> It just ain't hard to think up a more descriptive way to modify a
> variable name than inserting an underscore.

But then it requires me to think about it, and to ``prove that the
patch is correct,'' which is something I can't promise to do, since I
don't have access to the hardware, and I don't know the details about
the ABIs.  I can make guesses, but guesses can be wrong.

I'll try to come up with some patch that uses better names for
variables, and references the aligned or not-necessarily-aligned names
at the proper places.

-- 
Alexandre Oliva   Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/
Red Hat GCC Developer                 aoliva@{redhat.com, gcc.gnu.org}
CS PhD student at IC-Unicamp        oliva@{lsd.ic.unicamp.br, gnu.org}
Free Software Evangelist                Professional serial bug killer


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