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: mips64 n32 and n64 support in dl-machine.h


On Mar 14, 2003, Alexandre Oliva <aoliva at redhat dot com> wrote:

> The problem here is that the compiler legitimately assumes that a
> pointer is aligned, but we have to turn that into a pointer that's not
> guaranteed to be aligned while preventing the compiler from being
> smart and figuring out the pointers are the same and doing the
> optimization anyway.

Here's the patch I came up with. Ok to install?

Index: ChangeLog
from  Alexandre Oliva  <aoliva at redhat dot com>
	* sysdeps/mips/dl-machine.h (elf_machine_rel): Force the compiler
	to drop any alignment assumptions it could make about reloc_addr.

Index: sysdeps/mips/dl-machine.h
===================================================================
RCS file: /cvs/glibc/libc/sysdeps/mips/dl-machine.h,v
retrieving revision 1.66
diff -u -p -r1.66 dl-machine.h
--- sysdeps/mips/dl-machine.h 14 Mar 2003 08:43:13 -0000 1.66
+++ sysdeps/mips/dl-machine.h 14 Mar 2003 11:42:06 -0000
@@ -530,7 +530,7 @@ static inline void
 #endif
 elf_machine_rel (struct link_map *map, const ElfW(Rel) *reloc,
 		 const ElfW(Sym) *sym, const struct r_found_version *version,
-		 ElfW(Addr) *const reloc_addr)
+		 ElfW(Addr) *const reloc_addr_)
 {
   const unsigned long int r_type = ELFW(R_TYPE) (reloc->r_info);
 
@@ -554,6 +554,13 @@ elf_machine_rel (struct link_map *map, c
       {
 	int symidx = ELFW(R_SYM) (reloc->r_info);
 	ElfW(Addr) reloc_value;
+	void *reloc_addr = reloc_addr_;
+
+	/* Hide from the compiler the fact that reloc_addr and
+	   reloc_addr_ are the same, so that it can't make any
+	   assumptions about the alignment of the pointed-to data any
+	   more.  */
+	asm ("" : "+rm" (reloc_addr));
 
 	/* Support relocations on mis-aligned offsets.  Should we ever
 	   implement RELA, this should be replaced with an assignment
-- 
Alexandre Oliva   Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/
Red Hat GCC Developer                 aoliva at {redhat dot com, gcc.gnu.org}
CS PhD student at IC-Unicamp        oliva at {lsd dot ic dot unicamp dot 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]