This is the mail archive of the 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 18, 2003, Daniel Jacobowitz <drow at mvista dot com> wrote:

> If unrelated cleanups change the void* to the actual type, and it
> doesn't always have the alignment of that type, the cleanups are in
> error - period.

I see.  Agreed.  Thanks for pushing me in the right direction.  Here's
the patch, that fixes some warnings and a bug I spotted while cleaning
them up.  Ok?

Index: ChangeLog
from  Alexandre Oliva  <aoliva at redhat dot com>

	* sysdeps/mips/dl-machine.h (ELF_MIPS_GNU_GOT1_MASK): Define
	properly for n64.
	(elf_machine_runtime_setup): Cast link_map pointer to Elf Addr
	(elf_machine_rel, elf_machine_rel_relative): Cast symidx to Elf
	Word before comparing with gotsym.  Take reloc_addr argument as
	void*.  Remove the code added for the compiler to drop any
	alignment assumptions.

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 20 Mar 2003 06:42:13 -0000
@@ -130,7 +130,11 @@ elf_machine_load_address (void)
 /* The MSB of got[1] of a gnu object is set to identify gnu objects.  */
-#define ELF_MIPS_GNU_GOT1_MASK	0x80000000
+#ifdef _ABI64 && _MIPS_SIM == _ABI64
+# define ELF_MIPS_GNU_GOT1_MASK	0x8000000000000000L
+# define ELF_MIPS_GNU_GOT1_MASK	0x80000000L
 /* We can't rely on elf_machine_got_rel because _dl_object_relocation_scope
    fiddles with global data.  */
@@ -530,7 +534,10 @@ static inline void
 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)
+		 /* We use void* because the location to be relocated
+		    is not required to be properly aligned for a
+		    ELFW(Addr).  */
+		 void /* ElfW(Addr) */ *const reloc_addr)
   const unsigned long int r_type = ELFW(R_TYPE) (reloc->r_info);
@@ -565,7 +572,7 @@ elf_machine_rel (struct link_map *map, c
 	    const ElfW(Word) gotsym
 	      = (const ElfW(Word)) map->l_info[DT_MIPS (GOTSYM)]->d_un.d_val;
-	    if (symidx < gotsym)
+	    if ((ElfW(Word))symidx < gotsym)
 		/* This wouldn't work for a symbol imported from other
 		   libraries for which there's no GOT entry, but MIPS
@@ -633,7 +640,7 @@ elf_machine_rel (struct link_map *map, c
 static inline void
 elf_machine_rel_relative (ElfW(Addr) l_addr, const ElfW(Rel) *reloc,
-			  ElfW(Addr) *const reloc_addr)
+			  void /* ElfW(Addr) */ *const reloc_addr)
   /* XXX Nothing to do.  There is no relative relocation, right?  */
@@ -758,7 +765,7 @@ elf_machine_runtime_setup (struct link_m
 	 of got[1] of a gnu object is set to identify gnu objects.
 	 Where we can store l for non gnu objects? XXX  */
       if ((got[1] & ELF_MIPS_GNU_GOT1_MASK) != 0)
-	got[1] = (ElfW(Addr)) ((unsigned) l | ELF_MIPS_GNU_GOT1_MASK);
+	got[1] = ((ElfW(Addr)) l | ELF_MIPS_GNU_GOT1_MASK);
 	_dl_mips_gnu_objects = 0;
Alexandre Oliva   Enjoy Guarana', see
Red Hat GCC Developer                 aoliva at {redhat dot com,}
CS PhD student at IC-Unicamp        oliva at {lsd dot ic dot unicamp dot br,}
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]