Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 23 Sep 2002 01:10:00 -0700 (PDT)
From:      Peter Wemm <peter@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 17987 for review
Message-ID:  <200209230810.g8N8A0Wi097572@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://people.freebsd.org/~peter/p4db/chv.cgi?CH=17987

Change 17987 by peter@peter_overcee on 2002/09/23 01:09:14

	chop out i386 backwards compatability cruft
	initial translation of rtld_start.S.  Much more to be done, especially
	considering that the kernel side of the exec interface hasn't been done yet.

Affected files ...

.. //depot/projects/hammer/libexec/rtld-elf/x86_64/lockdflt.c#2 edit
.. //depot/projects/hammer/libexec/rtld-elf/x86_64/rtld_start.S#2 edit

Differences ...

==== //depot/projects/hammer/libexec/rtld-elf/x86_64/lockdflt.c#2 (text+ko) ====

@@ -48,7 +48,6 @@
  * instruction and catching the SIGILL which results on the 80386.
  */
 
-#include <setjmp.h>
 #include <signal.h>
 #include <stdlib.h>
 #include <time.h>
@@ -132,36 +131,6 @@
 }
 
 /*
- * Crude exclusive locks for the 80386, which does not support the
- * cmpxchg instruction.
- */
-static void
-lock80386_acquire(void *lock)
-{
-    Lock *l = (Lock *)lock;
-    sigset_t tmp_oldsigmask;
-
-    for ( ; ; ) {
-	sigprocmask(SIG_BLOCK, &fullsigmask, &tmp_oldsigmask);
-	if (xchgl(1, &l->lock) == 0)
-	    break;
-	sigprocmask(SIG_SETMASK, &tmp_oldsigmask, NULL);
-	while (l->lock != 0)
-	    ;	/* Spin */
-    }
-    oldsigmask = tmp_oldsigmask;
-}
-
-static void
-lock80386_release(void *lock)
-{
-    Lock *l = (Lock *)lock;
-
-    l->lock = 0;
-    sigprocmask(SIG_SETMASK, &oldsigmask, NULL);
-}
-
-/*
  * Better reader/writer locks for the 80486 and later CPUs.
  */
 static void
@@ -206,42 +175,6 @@
     sigprocmask(SIG_SETMASK, &oldsigmask, NULL);
 }
 
-/*
- * Code to determine at runtime whether the CPU supports the cmpxchg
- * instruction.  This instruction allows us to use locks that are more
- * efficient, but it didn't exist on the 80386.
- */
-static jmp_buf sigill_env;
-
-static void
-sigill(int sig)
-{
-    longjmp(sigill_env, 1);
-}
-
-static int
-cpu_supports_cmpxchg(void)
-{
-    struct sigaction act, oact;
-    int result;
-    volatile int lock;
-
-    memset(&act, 0, sizeof act);
-    act.sa_handler = sigill;
-    sigemptyset(&act.sa_mask);
-    act.sa_flags = 0;
-
-    sigaction(SIGILL, &act, &oact);
-    if (setjmp(sigill_env) == 0) {
-	lock = 0;
-	cmpxchgl(0, 1, &lock);
-	result = 1;
-    } else
-	result = 0;
-    sigaction(SIGILL, &oact, NULL);
-    return result;
-}
-
 void
 lockdflt_init(LockInfo *li)
 {
@@ -249,17 +182,10 @@
     li->context_destroy = NULL;
     li->lock_create = lock_create;
     li->lock_destroy = lock_destroy;
-    if (cpu_supports_cmpxchg()) {
-	/* Use fast locks that require an 80486 or later. */
-	li->rlock_acquire = rlock_acquire;
-	li->wlock_acquire = wlock_acquire;
-	li->rlock_release = rlock_release;
-	li->wlock_release = wlock_release;
-    } else {
-	/* It's a cruddy old 80386. */
-	li->rlock_acquire = li->wlock_acquire = lock80386_acquire;
-	li->rlock_release = li->wlock_release = lock80386_release;
-    }
+    li->rlock_acquire = rlock_acquire;
+    li->wlock_acquire = wlock_acquire;
+    li->rlock_release = rlock_release;
+    li->wlock_release = wlock_release;
     /*
      * Construct a mask to block all signals except traps which might
      * conceivably be generated within the dynamic linker itself.

==== //depot/projects/hammer/libexec/rtld-elf/x86_64/rtld_start.S#2 (text+ko) ====

@@ -25,32 +25,33 @@
  * $FreeBSD: src/libexec/rtld-elf/i386/rtld_start.S,v 1.3 1999/08/28 00:10:15 peter Exp $
  */
 
+.error finish update please. needs to be updated for calling conventions at the very least
 	.text
 	.align	4
 	.globl	.rtld_start
 	.type	.rtld_start,@function
 .rtld_start:
-	xorl	%ebp,%ebp		# Clear frame pointer for good form
-	movl	%esp,%eax		# Save initial stack pointer
-	subl	$8,%esp			# A place to store exit procedure addr
-	movl	%esp,%ebx		# save address of exit proc
-	movl	%esp,%ecx		# construct address of obj_main
-	addl	$4,%ecx
-	pushl	%ecx			# Pass address of obj_main
-	pushl	%ebx			# Pass address of exit proc
-	pushl	%eax			# Pass initial stack pointer to rtld
+	xorl	%rbp,%rbp		# Clear frame pointer for good form
+	movl	%rsp,%rax		# Save initial stack pointer
+	subl	$8,%rsp			# A place to store exit procedure addr
+	movl	%rsp,%rbx		# save address of exit proc
+	movl	%rsp,%rcx		# construct address of obj_main
+	addl	$4,%rcx
+	pushl	%rcx			# Pass address of obj_main
+	pushl	%rbx			# Pass address of exit proc
+	pushl	%rax			# Pass initial stack pointer to rtld
 	call	_rtld@PLT		# Call rtld(sp); returns entry point
-	addl	$12,%esp		# Remove arguments from stack
-	popl	%edx			# Get exit procedure address
-	addl	$4,%esp			# Ignore obj_main
+	addl	$12,%rsp		# Remove arguments from stack
+	popl	%rdx			# Get exit procedure address
+	addl	$4,%rsp			# Ignore obj_main
 /*
- * At this point, %eax contains the entry point of the main program, and
- * %edx contains a pointer to a termination function that should be
+ * At this point, %rax contains the entry point of the main program, and
+ * %rdx contains a pointer to a termination function that should be
  * registered with atexit().  (crt1.o registers it.)
  */
 .globl .rtld_goto_main
 .rtld_goto_main:	# This symbol exists just to make debugging easier.
-	jmp	*%eax			# Enter main program
+	jmp	*%rax			# Enter main program
 
 
 /*
@@ -69,20 +70,20 @@
 	.type	_rtld_bind_start,@function
 _rtld_bind_start:
 	pushf				# Save eflags
-	pushl	%eax			# Save %eax
-	pushl	%edx			# Save %edx
-	pushl	%ecx			# Save %ecx
-	pushl	20(%esp)		# Copy reloff argument
-	pushl	20(%esp)		# Copy obj argument
+	pushl	%rax			# Save %rax
+	pushl	%rdx			# Save %rdx
+	pushl	%rcx			# Save %rcx
+	pushl	20(%rsp)		# Copy reloff argument
+	pushl	20(%rsp)		# Copy obj argument
 
 	call	_rtld_bind@PLT		# Transfer control to the binder
-	/* Now %eax contains the entry point of the function being called. */
+	/* Now %rax contains the entry point of the function being called. */
 
-	addl	$8,%esp			# Discard binder arguments
-	movl	%eax,20(%esp)		# Store target over obj argument
-	popl	%ecx			# Restore %ecx
-	popl	%edx			# Restore %edx
-	popl	%eax			# Restore %eax
+	addl	$8,%rsp			# Discard binder arguments
+	movl	%rax,20(%rsp)		# Store target over obj argument
+	popl	%rcx			# Restore %rcx
+	popl	%rdx			# Restore %rdx
+	popl	%rax			# Restore %rax
 	popf				# Restore eflags
-	leal	4(%esp),%esp		# Discard reloff, do not change eflags
+	leal	4(%rsp),%rsp		# Discard reloff, do not change eflags
 	ret				# "Return" to target address

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe p4-projects" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200209230810.g8N8A0Wi097572>