aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2002-08-10 00:35:24 +0000
committerH. Peter Anvin <hpa@zytor.com>2002-08-10 00:35:24 +0000
commit1d5c01ba8676528624b4a49c6410a57f75a53cfd (patch)
tree6f410e567dbed83e35ac3d682be3dbfd82df48cc
parente098aa6c1a9983f6f5e88ed65112bb965bb2fb49 (diff)
downloadklibc-1d5c01ba8676528624b4a49c6410a57f75a53cfd.tar.gz
a) Clean up crt0.c somewhatklibc-0.6
b) Support $(CROSS) in the makefile c) Compile with -nostdinc -iwithprefix include
-rw-r--r--crt0.c48
-rw-r--r--klibc/Makefile11
-rw-r--r--klibc/crt0.c48
3 files changed, 54 insertions, 53 deletions
diff --git a/crt0.c b/crt0.c
index 09700a0fbf09f..cb33c78e01484 100644
--- a/crt0.c
+++ b/crt0.c
@@ -8,46 +8,46 @@ char **environ;
extern int main(int argc, char **argv, char **envp);
-void _start(void)
-{
- /*
- * The argument block begins above the current stack frame, because we
- * have no return address.
- *
- * FIXME: this needs to be ported to all platforms...
- */
-
- int argc;
- char **argv;
-
#if defined(__i386__)
- register uintptr_t *params asm("%esp");
+register uintptr_t *params asm("%esp");
#elif defined(__x86_64__)
- register uintptr_t *params asm("%rsp");
+register uintptr_t *params asm("%rsp");
#elif defined(__sparc64__)
- register uintptr_t sp asm("%sp");
+register uintptr_t sp asm("%sp");
#define BIAS 2047
- uintptr_t *params = (uintptr_t *)(sp+BIAS) + 16;
+#define params ((uintptr_t *)(sp+BIAS) + 16)
#elif defined(__sparc__) && !defined(__sparc64__)
- register uintptr_t *sp asm("%sp");
- uintptr_t *params = sp+16; /* SPARC needs a window save area */
+register uintptr_t *sp asm("%sp");
+#define params (sp+16)
#elif defined(__mips__) || defined(__mips64__)
- register uintptr_t *params asm("$sp");
+register uintptr_t *params asm("$sp");
#elif defined(__powerpc__)
- register uintptr_t *params asm("r9");
+register uintptr_t *params asm("r9");
#elif defined(__hppa__)
# define STACK_GROWS_UP
- register uintptr_t *params asm("%r25");
+register uintptr_t *params asm("%r25");
#elif defined(__s390__)
- register uintptr_t *params asm("%r15");
+register uintptr_t *params asm("%r15");
#elif defined(__alpha__)
- register uintptr_t *params asm("$sp");
+register uintptr_t *params asm("$sp");
#elif defined(__arm__)
- register uintptr_t *params asm("sp");
+register uintptr_t *params asm("sp");
#else
#error "Need crt0.c port for this architecture!"
#endif
+void _start(void)
+{
+ /*
+ * The argument block begins above the current stack frame, because we
+ * have no return address.
+ *
+ * FIXME: this needs to be ported to all platforms...
+ */
+
+ int argc;
+ char **argv;
+
/* These seem to be standard for all the ELF ABIs... */
#ifdef STACK_GROWS_UP
argc = (int) *params;
diff --git a/klibc/Makefile b/klibc/Makefile
index ea68b318ea5fe..b6750470fa4c1 100644
--- a/klibc/Makefile
+++ b/klibc/Makefile
@@ -1,12 +1,13 @@
ARCH = i386
-CC = gcc
-LD = ld
+CROSS =
+CC = $(CROSS)gcc
+LD = $(CROSS)ld
OPTFLAGS = -Os -fomit-frame-pointer -march=i386 -mcpu=i686 \
-malign-functions=0 -malign-jumps=0 -malign-loops=0
-CFLAGS = -I. -I./include -I./linux/include -Wall -g $(OPTFLAGS)
+CFLAGS = -nostdinc -iwithprefix include -I. -I./include -I./linux/include -Wall -g $(OPTFLAGS)
LDFLAGS =
-AR = ar
-RANLIB = ranlib
+AR = $(CROSS)ar
+RANLIB = $(CROSS)ranlib
PERL = perl
TESTS = testvsnp hello minihello microhello getenvtest \
diff --git a/klibc/crt0.c b/klibc/crt0.c
index 09700a0fbf09f..cb33c78e01484 100644
--- a/klibc/crt0.c
+++ b/klibc/crt0.c
@@ -8,46 +8,46 @@ char **environ;
extern int main(int argc, char **argv, char **envp);
-void _start(void)
-{
- /*
- * The argument block begins above the current stack frame, because we
- * have no return address.
- *
- * FIXME: this needs to be ported to all platforms...
- */
-
- int argc;
- char **argv;
-
#if defined(__i386__)
- register uintptr_t *params asm("%esp");
+register uintptr_t *params asm("%esp");
#elif defined(__x86_64__)
- register uintptr_t *params asm("%rsp");
+register uintptr_t *params asm("%rsp");
#elif defined(__sparc64__)
- register uintptr_t sp asm("%sp");
+register uintptr_t sp asm("%sp");
#define BIAS 2047
- uintptr_t *params = (uintptr_t *)(sp+BIAS) + 16;
+#define params ((uintptr_t *)(sp+BIAS) + 16)
#elif defined(__sparc__) && !defined(__sparc64__)
- register uintptr_t *sp asm("%sp");
- uintptr_t *params = sp+16; /* SPARC needs a window save area */
+register uintptr_t *sp asm("%sp");
+#define params (sp+16)
#elif defined(__mips__) || defined(__mips64__)
- register uintptr_t *params asm("$sp");
+register uintptr_t *params asm("$sp");
#elif defined(__powerpc__)
- register uintptr_t *params asm("r9");
+register uintptr_t *params asm("r9");
#elif defined(__hppa__)
# define STACK_GROWS_UP
- register uintptr_t *params asm("%r25");
+register uintptr_t *params asm("%r25");
#elif defined(__s390__)
- register uintptr_t *params asm("%r15");
+register uintptr_t *params asm("%r15");
#elif defined(__alpha__)
- register uintptr_t *params asm("$sp");
+register uintptr_t *params asm("$sp");
#elif defined(__arm__)
- register uintptr_t *params asm("sp");
+register uintptr_t *params asm("sp");
#else
#error "Need crt0.c port for this architecture!"
#endif
+void _start(void)
+{
+ /*
+ * The argument block begins above the current stack frame, because we
+ * have no return address.
+ *
+ * FIXME: this needs to be ported to all platforms...
+ */
+
+ int argc;
+ char **argv;
+
/* These seem to be standard for all the ELF ABIs... */
#ifdef STACK_GROWS_UP
argc = (int) *params;