Removing CSU patches

* Removed startup code patches in lib/csu regarding kernel to userland
   ABI.

 * Aligned stack layout on NetBSD stack layout.

 * Generate valid stack pointers instead of offsets by taking into account
   _minix_kerninfo->kinfo->user_sp.

 * Refactored stack generation, by moving part of execve in two
   functions {minix_stack_params(), minix_stack_fill()} and using them
   in execve(), rs and vm.

 * Changed load offset of rtld (ld.so) to:
      execi.args.stack_high - execi.args.stack_size - 0xa00000
   which is 10MB below the main executable stack.

Change-Id: I839daf3de43321cded44105634102d419cb36cec
This commit is contained in:
2013-09-13 20:12:22 +02:00
parent 5d04b92e06
commit cfd3379bb1
29 changed files with 608 additions and 485 deletions

View File

@@ -36,33 +36,16 @@ RCSID("$NetBSD: crt0.S,v 1.1 2012/08/13 02:49:04 matt Exp $")
STRONG_ALIAS(_start,__start)
_ENTRY(__start)
#ifdef __minix
mov r3, r2 /* cleanup */
mov r4, r1 /* obj_main */
and r5, r5, #0 /* ps_strings, always NULL on MINIX */
/* Get argc, argv, and envp from stack */
ldr r0, [sp, #0] /* get argc */
add r1, sp, #4 /* argv = sp + 4 */
add r2, r1, r0, lsl #2 /* envp = argv + argc*4 */
add r2, r2, #4 /* skip NULL terminator */
#else
/*
* We need to swap ps_strings and cleanup
*/
mov ip, r0 /* ps_strings -> tmp */
mov r0, r2 /* cleanup -> ps_strings */
mov r2, ip /* tmp -> ps_strings */
#endif /* __minix */
/* Ensure the stack is properly aligned before calling C code. */
bic sp, sp, #7
#ifdef __minix
/* Store obj and ps_strings on the stack */
sub sp, sp, #8
str r5, [sp, #4]
str r4, [sp, #0]
#endif
/*
* void ___start(void (*cleanup)(void),
* const Obj_Entry *obj,

View File

@@ -46,12 +46,4 @@ _ENTRY(__start)
pushl %ebx
pushl %ecx
pushl %edx
#ifdef __minix
movl 12(%esp),%eax
leal 16(%esp),%edx
leal 20(%esp,%eax,4),%ecx
pushl %ecx
pushl %edx
pushl %eax
#endif /* __minix */
call ___start

View File

@@ -80,15 +80,12 @@ struct ps_strings *__ps_strings = 0;
static char empty_string[] = "";
char *__progname = empty_string;
#ifndef __minix
__dead __dso_hidden void ___start(void (*)(void), const Obj_Entry *,
struct ps_strings *);
#ifndef __minix
#define write(fd, s, n) __syscall(SYS_write, (fd), (s), (n))
#else
__dead __dso_hidden void ___start(int, char **, char **, void (*)(void),
const Obj_Entry *, struct ps_strings *);
#define write(fd, s, n) /* NO write() from here on minix */
#endif
@@ -129,30 +126,11 @@ _fini(void)
#endif /* HAVE_INITFINI_ARRAY */
void
#ifdef __minix
___start(int argc, char **argv, char **envp,
void (*cleanup)(void), /* from shared loader */
#else
___start(void (*cleanup)(void), /* from shared loader */
#endif /* __minix */
const Obj_Entry *obj, /* from shared loader */
struct ps_strings *ps_strings)
{
#ifdef __minix
/* LSC: We have not yet updated the way we pass arguments to
the userspace, so here some code to adapt this to the new
ways. */
struct ps_strings minix_ps_strings;
if (ps_strings == NULL) {
memset(&minix_ps_strings, 0, sizeof(minix_ps_strings));
minix_ps_strings.ps_envstr = envp;
minix_ps_strings.ps_argvstr = argv;
minix_ps_strings.ps_nargvstr = argc;
ps_strings = &minix_ps_strings;
}
#endif /* __minix */
if (ps_strings == NULL)
_FATAL("ps_strings missing\n");
__ps_strings = ps_strings;