[patch 4/4] uml: make it link in tt mode against NPTL glibc

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



To make sure switcheroo() can execute when we remap all the executable image,
we used a trick to make it use a local copy of errno... this trick does not
work with NPTL glibc, only with LinuxThreads, so use another (simpler) one to
make it work anyway.

Might need compile testing on different host archs, since it changes
__syscall_return from <asm/unistd.h>.

Signed-off-by: Paolo 'Blaisorblade' Giarrusso <[email protected]>
---

 linux-2.6.git-paolo/arch/um/kernel/tt/unmap.c |   25 +++++++++++++------------
 linux-2.6.git-paolo/arch/um/kernel/uml.lds.S  |   12 +-----------
 2 files changed, 14 insertions(+), 23 deletions(-)

diff -puN arch/um/kernel/tt/unmap.c~uml-link-tt-mode-against-nptl arch/um/kernel/tt/unmap.c
--- linux-2.6.git/arch/um/kernel/tt/unmap.c~uml-link-tt-mode-against-nptl	2005-05-25 01:22:23.000000000 +0200
+++ linux-2.6.git-paolo/arch/um/kernel/tt/unmap.c	2005-05-25 01:22:23.000000000 +0200
@@ -1,16 +1,28 @@
 /* 
  * Copyright (C) 2000 Jeff Dike ([email protected])
+ * Copyright (C) 2005 Paolo 'Blaisorblade' Giarrusso ([email protected])
  * Licensed under the GPL
  */
 
 #include <sys/mman.h>
+#include <linux/unistd.h>
+
+/* We can't rely on errno here! */
+#undef __syscall_return
+#define __syscall_return(type, res) \
+do { \
+	return (type) (res); \
+} while (0)
+
+static inline _syscall6(void *, mmap2, void *, start, size_t, length, int, prot, int, flags, int, fd, off_t, pgoffset)
+inline _syscall2(int, munmap, void *, start, size_t, length)
 
 int switcheroo(int fd, int prot, void *from, void *to, int size)
 {
 	if(munmap(to, size) < 0){
 		return(-1);
 	}
-	if(mmap(to, size, prot,	MAP_SHARED | MAP_FIXED, fd, 0) != to){
+	if(mmap2(to, size, prot, MAP_SHARED | MAP_FIXED, fd, 0) != to){
 		return(-1);
 	}
 	if(munmap(from, size) < 0){
@@ -18,14 +30,3 @@ int switcheroo(int fd, int prot, void *f
 	}
 	return(0);
 }
-
-/*
- * Overrides for Emacs so that we follow Linus's tabbing style.
- * Emacs will notice this stuff at the end of the file and automatically
- * adjust the settings for this buffer only.  This must remain at the end
- * of the file.
- * ---------------------------------------------------------------------------
- * Local variables:
- * c-file-style: "linux"
- * End:
- */
diff -puN arch/um/kernel/uml.lds.S~uml-link-tt-mode-against-nptl arch/um/kernel/uml.lds.S
--- linux-2.6.git/arch/um/kernel/uml.lds.S~uml-link-tt-mode-against-nptl	2005-05-25 01:22:23.000000000 +0200
+++ linux-2.6.git-paolo/arch/um/kernel/uml.lds.S	2005-05-25 01:22:23.000000000 +0200
@@ -15,19 +15,9 @@ SECTIONS
    * is remapped.*/
   __binary_start = .;
 #ifdef MODE_TT
-  .thread_private : {
-    __start_thread_private = .;
-    errno = .;
-    . += 4;
-    arch/um/kernel/tt/unmap_fin.o (.data)
-    __end_thread_private = .;
-  }
-  . = ALIGN(4096);
+  .remap_data: { arch/um/kernel/tt/unmap_fin.o (.data) }
   .remap : { arch/um/kernel/tt/unmap_fin.o (.text) }
 
-  /* We want it only if we are in MODE_TT. In both cases, however, when MODE_TT
-   * is off the resulting binary segfaults.*/
-
   . = ALIGN(4096);		/* Init code and data */
 #endif
 
_
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux