public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jeff Dike <jdike@addtoit.com>
To: akpm@osdl.org, torvalds@osdl.org
Cc: linux-kernel@vger.kernel.org,
	user-mode-linux-devel@lists.sourceforge.net
Subject: [PATCH 3/5] UML - Clean up tt mode remapping of UML binary
Date: Mon, 06 Jun 2005 16:08:09 -0400	[thread overview]
Message-ID: <200506062008.j56K89YA008957@ccure.user-mode-linux.org> (raw)

>From Al Viro - this turns the tt mode remapping of the binary into arch 
code.

Signed-off-by: Jeff Dike <jdike@addtoit.com>

Index: linux-2.6.12-rc/arch/um/Makefile
===================================================================
--- linux-2.6.12-rc.orig/arch/um/Makefile	2005-06-02 17:04:01.000000000 -0400
+++ linux-2.6.12-rc/arch/um/Makefile	2005-06-06 11:36:06.000000000 -0400
@@ -119,7 +119,7 @@ ifndef START
   START = $$(($(TOP_ADDR) - $(SIZE)))
 endif
 
-CPPFLAGS_vmlinux.lds = $(shell echo -U$(SUBARCH) \
+CPPFLAGS_vmlinux.lds = $(shell echo -U$(SUBARCH) -I$(SYS_DIR) \
 	-DSTART=$(START) -DELF_ARCH=$(ELF_ARCH) \
 	-DELF_FORMAT=\"$(ELF_FORMAT)\" $(CPP_MODE-y) \
 	-DKERNEL_STACK_SIZE=$(STACK_SIZE))
Index: linux-2.6.12-rc/arch/um/include/sysdep-i386/unmap.lds
===================================================================
--- linux-2.6.12-rc.orig/arch/um/include/sysdep-i386/unmap.lds	2005-06-06 05:54:35.815704808 -0400
+++ linux-2.6.12-rc/arch/um/include/sysdep-i386/unmap.lds	2005-06-02 17:04:44.000000000 -0400
@@ -0,0 +1,14 @@
+  .thread_private : {
+    __start_thread_private = .;
+    errno = .;
+    . += 4;
+    arch/um/sys-i386/unmap_fin.o (.bss)
+    __end_thread_private = .;
+  }
+  . = ALIGN(4096);
+  .remap : { arch/um/sys-i386/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 */
Index: linux-2.6.12-rc/arch/um/include/sysdep-x86_64/unmap.lds
===================================================================
--- linux-2.6.12-rc.orig/arch/um/include/sysdep-x86_64/unmap.lds	2005-06-06 05:54:35.815704808 -0400
+++ linux-2.6.12-rc/arch/um/include/sysdep-x86_64/unmap.lds	2005-06-02 17:04:44.000000000 -0400
@@ -0,0 +1,6 @@
+  . = ALIGN(4096);		/* Init code and data */
+  .remap : {
+	arch/um/sys-x86_64/unmap_fin.o (.bss)
+	arch/um/sys-x86_64/unmap_fin.o (.text)
+  }
+  . = ALIGN(4096);		/* Init code and data */
Index: linux-2.6.12-rc/arch/um/kernel/tt/Makefile
===================================================================
--- linux-2.6.12-rc.orig/arch/um/kernel/tt/Makefile	2005-06-02 17:04:01.000000000 -0400
+++ linux-2.6.12-rc/arch/um/kernel/tt/Makefile	2005-06-06 11:52:11.000000000 -0400
@@ -3,10 +3,6 @@
 # Licensed under the GPL
 #
 
-extra-y := unmap_fin.o
-targets := unmap.o
-clean-files := unmap_tmp.o
-
 obj-y = exec_kern.o exec_user.o gdb.o ksyms.o mem.o mem_user.o process_kern.o \
 	syscall_kern.o syscall_user.o time.o tlb.o tracer.o trap_user.o \
 	uaccess.o uaccess_user.o
@@ -16,14 +12,3 @@ obj-$(CONFIG_PT_PROXY) += gdb_kern.o ptp
 USER_OBJS := gdb.o time.o tracer.o
 
 include arch/um/scripts/Makefile.rules
-
-UNMAP_CFLAGS := $(patsubst -pg -DPROFILING,,$(USER_CFLAGS))
-UNMAP_CFLAGS := $(patsubst -fprofile-arcs -ftest-coverage,,$(UNMAP_CFLAGS))
-
-#XXX: partially copied from arch/um/scripts/Makefile.rules
-$(obj)/unmap.o: c_flags = -Wp,-MD,$(depfile) $(UNMAP_CFLAGS)
-
-$(obj)/unmap_fin.o : $(obj)/unmap.o
-	$(LD) -r -o $(obj)/unmap_tmp.o $< $(shell $(CC) -print-file-name=libc.a)
-	$(OBJCOPY) $(obj)/unmap_tmp.o $@ -G switcheroo
-
Index: linux-2.6.12-rc/arch/um/kernel/tt/unmap.c
===================================================================
--- linux-2.6.12-rc.orig/arch/um/kernel/tt/unmap.c	2005-06-02 17:04:01.000000000 -0400
+++ linux-2.6.12-rc/arch/um/kernel/tt/unmap.c	2005-06-06 05:54:35.815704808 -0400
@@ -1,31 +0,0 @@
-/* 
- * Copyright (C) 2000 Jeff Dike (jdike@karaya.com)
- * Licensed under the GPL
- */
-
-#include <sys/mman.h>
-
-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){
-		return(-1);
-	}
-	if(munmap(from, size) < 0){
-		return(-1);
-	}
-	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:
- */
Index: linux-2.6.12-rc/arch/um/kernel/uml.lds.S
===================================================================
--- linux-2.6.12-rc.orig/arch/um/kernel/uml.lds.S	2005-06-02 17:04:01.000000000 -0400
+++ linux-2.6.12-rc/arch/um/kernel/uml.lds.S	2005-06-06 11:52:10.000000000 -0400
@@ -15,20 +15,7 @@ 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 : { 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 */
+#include <unmap.lds>
 #endif
 
   _stext = .;
Index: linux-2.6.12-rc/arch/um/scripts/Makefile.rules
===================================================================
--- linux-2.6.12-rc.orig/arch/um/scripts/Makefile.rules	2005-06-06 12:14:26.000000000 -0400
+++ linux-2.6.12-rc/arch/um/scripts/Makefile.rules	2005-06-06 12:15:45.000000000 -0400
@@ -10,6 +10,11 @@ USER_OBJS := $(foreach file,$(USER_OBJS)
 $(USER_OBJS) : c_flags = -Wp,-MD,$(depfile) $(USER_CFLAGS) \
 	$(CFLAGS_$(notdir $@))
 
+# The stubs and unmap.o can't try to call mcount or update basic block data
+define unprofile
+	$(patsubst -pg,,$(patsubst -fprofile-arcs -ftest-coverage,,$(1)))
+endef
+
 quiet_cmd_make_link = SYMLINK $@
 cmd_make_link       = ln -sf $(srctree)/arch/$(SUBARCH)/$($(notdir $@)-dir)/$(notdir $@) $@
 
Index: linux-2.6.12-rc/arch/um/sys-i386/Makefile
===================================================================
--- linux-2.6.12-rc.orig/arch/um/sys-i386/Makefile	2005-06-02 17:04:01.000000000 -0400
+++ linux-2.6.12-rc/arch/um/sys-i386/Makefile	2005-06-06 11:52:10.000000000 -0400
@@ -2,6 +2,8 @@ obj-y = bitops.o bugs.o checksum.o delay
 	ptrace_user.o semaphore.o signal.o sigcontext.o syscalls.o sysrq.o \
 	sys_call_table.o
 
+extra-$(CONFIG_MODE_TT) := unmap_fin.o
+
 obj-$(CONFIG_HIGHMEM) += highmem.o
 obj-$(CONFIG_MODULES) += module.o
 
@@ -16,4 +18,6 @@ semaphore.c-dir = kernel
 highmem.c-dir = mm
 module.c-dir = kernel
 
+$(obj)/unmap_fin.o : _c_flags = $(call unprofile,$(CFLAGS))
+
 subdir- := util
Index: linux-2.6.12-rc/arch/um/sys-i386/unmap_fin.c
===================================================================
--- linux-2.6.12-rc.orig/arch/um/sys-i386/unmap_fin.c	2005-06-06 05:54:35.815704808 -0400
+++ linux-2.6.12-rc/arch/um/sys-i386/unmap_fin.c	2005-06-03 15:36:17.000000000 -0400
@@ -0,0 +1,25 @@
+/* 
+ * Copyright (C) 2000 Jeff Dike (jdike@karaya.com)
+ * Licensed under the GPL
+ */
+
+#include <linux/mman.h>
+#include <asm/unistd.h>
+
+static int errno;
+
+static inline _syscall2(int,munmap,void *,start,size_t,len)
+static inline _syscall6(void *,mmap2,void *,addr,size_t,len,int,prot,int,flags,int,fd,off_t,offset)
+int switcheroo(int fd, int prot, void *from, void *to, int size)
+{
+        if(munmap(to, size) < 0){
+                return(-1);
+        }
+        if(mmap2(to, size, prot, MAP_SHARED | MAP_FIXED, fd, 0) != to){
+                return(-1);
+        }
+        if(munmap(from, size) < 0){
+                return(-1);
+        }
+        return(0);
+}
Index: linux-2.6.12-rc/arch/um/sys-x86_64/Makefile
===================================================================
--- linux-2.6.12-rc.orig/arch/um/sys-x86_64/Makefile	2005-06-02 17:04:01.000000000 -0400
+++ linux-2.6.12-rc/arch/um/sys-x86_64/Makefile	2005-06-06 11:52:10.000000000 -0400
@@ -4,6 +4,8 @@
 # Licensed under the GPL
 #
 
+extra-$(CONFIG_MODE_TT) := unmap_fin.o
+
 #XXX: why into lib-y?
 lib-y = bitops.o bugs.o csum-partial.o delay.o fault.o mem.o memcpy.o \
 	ptrace.o ptrace_user.o semaphore.o sigcontext.o signal.o \
@@ -29,3 +31,5 @@ thunk.S-dir = lib
 module.c-dir = kernel
 
 subdir- := util
+
+$(obj)/unmap_fin.o: _c_flags = $(call unprofile,$(CFLAGS))
Index: linux-2.6.12-rc/arch/um/sys-x86_64/unmap_fin.c
===================================================================
--- linux-2.6.12-rc.orig/arch/um/sys-x86_64/unmap_fin.c	2005-06-06 05:54:35.815704808 -0400
+++ linux-2.6.12-rc/arch/um/sys-x86_64/unmap_fin.c	2005-06-02 17:04:44.000000000 -0400
@@ -0,0 +1,25 @@
+/* 
+ * Copyright (C) 2000 Jeff Dike (jdike@karaya.com)
+ * Licensed under the GPL
+ */
+
+#include <linux/mman.h>
+#include <asm/unistd.h>
+
+static int errno;
+
+static inline _syscall2(int,munmap,void *,start,size_t,len)
+static inline _syscall6(void *,mmap,void *,addr,size_t,len,int,prot,int,flags,int,fd,off_t,offset)
+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){
+                return(-1);
+        }
+        if(munmap(from, size) < 0){
+                return(-1);
+        }
+        return(0);
+}


             reply	other threads:[~2005-06-06 22:27 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-06-06 20:08 Jeff Dike [this message]
2005-06-06 23:05 ` [uml-devel] [PATCH 3/5] UML - Clean up tt mode remapping of UML binary Blaisorblade
2005-06-06 23:53   ` Al Viro
2005-06-07  0:56     ` Blaisorblade
2005-06-07  0:59       ` Al Viro
2005-06-07  1:18         ` Blaisorblade
2005-06-07  3:46           ` Rob Landley
2005-06-07  2:00         ` Jeff Dike
2005-06-07  0:40   ` Jeff Dike

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200506062008.j56K89YA008957@ccure.user-mode-linux.org \
    --to=jdike@addtoit.com \
    --cc=akpm@osdl.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@osdl.org \
    --cc=user-mode-linux-devel@lists.sourceforge.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox