This is the mail archive of the libc-hacker@sourceware.cygnus.com mailing list for the glibc project.

Note that libc-hacker is a closed list. You may look at the archives of this list, but subscription and posting are not open.


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

Re: Patch to allow ARM dynamic linker to fix up PC24 relocs...


> >This will only happen during program startup.  The code in
> >question is not in the Icache yet.
> 
> Yes; the danger is that on a system with a writeback Dcache and/or a store
> buffer, the modified data might not get flushed out to main memory before
> the Icache fill happens.

Seems Phil and Richard are both right.  The attached patch adds a cache
flush just after the readonly protection is restored to .text.  I've
done this in generic code, because the cache flush is an extremely
expensive operation on the ARM.  We don't want to do this after every
fixup, and only if we do fixups.  The patch as written should only
affect the ARM (or anyone else who defines CLEAR_CACHE).  For all other
targets it will disappear after pre-processing.

1999-12-17  Scott Bambrough  <scottb@netwinder.org>

	* sysdeps/arm/dl-machine.h (CLEAR_CACHE): New macro to force a
	cache flush.
	* elf/dl-reloc.c (_dl_relocate_object): Add call to flush cache
	after .text segment fixups.

Scott

-- 
Scott Bambrough - Software Engineer
REBEL.COM    http://www.rebel.com
NetWinder    http://www.netwinder.org
diff -upr glibc-2.1.2.orig/elf/dl-reloc.c glibc-2.1.2/elf/dl-reloc.c
--- glibc-2.1.2.orig/elf/dl-reloc.c	Sat Feb 20 09:45:53 1999
+++ glibc-2.1.2/elf/dl-reloc.c	Fri Dec 10 10:36:33 1999
@@ -126,6 +126,10 @@ _dl_relocate_object (struct link_map *l,
 	    if (__mprotect (mapstart, mapend - mapstart, prot) < 0)
 	      _dl_signal_error (errno, l->l_name,
 				"can't restore segment prot after reloc");
+
+#ifdef CLEAR_CACHE
+	    CLEAR_CACHE (mapstart, mapend);
+#endif 
 	  }
     }
 }
diff -upr glibc-2.1.2.orig/sysdeps/arm/dl-machine.h glibc-2.1.2/sysdeps/arm/dl-machine.h
--- glibc-2.1.2.orig/sysdeps/arm/dl-machine.h	Tue Aug 10 01:13:22 1999
+++ glibc-2.1.2/sysdeps/arm/dl-machine.h	Fri Dec 10 10:36:57 1999
@@ -35,6 +35,14 @@
   VALID_ELF_ABIVERSION(hdr[EI_ABIVERSION]) \
 )
 
+#define CLEAR_CACHE(BEG,END)						\
+{									\
+  register unsigned long _beg __asm ("a1") = (unsigned long)(BEG);	\
+  register unsigned long _end __asm ("a2") = (unsigned long)((END) - (BEG));\
+  register unsigned long _flg __asm ("a3") = 0;				\
+  __asm __volatile ("swi 0x9f0002");					\
+}
+
 /* Return nonzero iff E_MACHINE is compatible with the running host.  */
 static inline int __attribute__ ((unused))
 elf_machine_matches_host (Elf32_Half e_machine)

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