From 2c8cefb3a269d66a6a705bcb4912b0657379273c Mon Sep 17 00:00:00 2001 From: Michal Idziorek Date: Mon, 25 May 2015 13:04:41 +0200 Subject: fixed crt0.o for compiler toolchain (-lfool no more!) --- userspace/Makefile | 13 ++++--------- userspace/sys/Makefile | 22 +++++++--------------- userspace/sys/crt.S | 20 ++++++++++++++++++++ userspace/sys/crt0.S | 20 -------------------- userspace/sys/crt0.o | Bin 660 -> 0 bytes userspace/sys/libfool.a | Bin 37550 -> 0 bytes userspace/sys/linker.ld | 37 +++++++++++++++++++++++++++++++++++++ userspace/sys/sgtty.h | 15 +++++++++++++++ userspace/sys/sys.o | Bin 18236 -> 0 bytes userspace/sys/sys/ioctl.h | 0 userspace/sys/sys/termios.h | 20 ++++++++++++++++++++ userspace/sys/syscalls.o | Bin 18544 -> 0 bytes userspace/sys/termios.h | 20 -------------------- 13 files changed, 103 insertions(+), 64 deletions(-) create mode 100644 userspace/sys/crt.S delete mode 100644 userspace/sys/crt0.S delete mode 100644 userspace/sys/crt0.o delete mode 100644 userspace/sys/libfool.a create mode 100644 userspace/sys/linker.ld create mode 100644 userspace/sys/sgtty.h delete mode 100644 userspace/sys/sys.o create mode 100644 userspace/sys/sys/ioctl.h create mode 100644 userspace/sys/sys/termios.h delete mode 100644 userspace/sys/syscalls.o delete mode 100644 userspace/sys/termios.h diff --git a/userspace/Makefile b/userspace/Makefile index 1f562ab..d87b7a7 100644 --- a/userspace/Makefile +++ b/userspace/Makefile @@ -2,16 +2,14 @@ CC=i686-foolos-gcc CFLAGS= -#CFLAGS+=-fstack-protector-all CFLAGS+=-I.. CFLAGS+=-w CFLAGS+=-std=gnu11 -CFLAGS+=-O3 +CFLAGS+=-O0 CFLAGS+=-g -LDFLAGS= -LDFLAGS=-lfool +#CFLAGS+=-fstack-protector-all -#CFLAGS+=$(SYSROOT)/usr/lib/crt0.o +LDFLAGS= PROGS=foolshell ls simple brainfuck add checker clear task1 task2 init cat snake @@ -44,7 +42,7 @@ snake: snake.o foolshell: foolshell.o simple: simple.o add: add.o - $(CC) -o $@ $< -lm -lfool + $(CC) -o $@ $< -lm checker: checker.o task1: task1.o task2: task2.o @@ -64,6 +62,3 @@ umount: rm mnt -rf new: clean ext2.img - - - diff --git a/userspace/sys/Makefile b/userspace/sys/Makefile index 2e71714..05177a6 100644 --- a/userspace/sys/Makefile +++ b/userspace/sys/Makefile @@ -1,31 +1,23 @@ SYSROOT=/home/miguel/opt/foolos CC=i686-foolos-gcc +LD=i686-foolos-ld CFLAGS= CFLAGS+=-w CFLAGS+=-I../.. CFLAGS+=-gstabs -OBJECTS=sys.o syscalls.o crt0.o - -full: clean library_install crt_install header_install - -all: $(OBJECTS) - -crt0.o: crt0.S +install: crt_install header_install crt_install: crt0.o cp crt0.o $(SYSROOT)/usr/lib/ -header_install: - cp termios.h $(SYSROOT)/usr/include/sys/ - -libfool.a: sys.o syscalls.o - ar rcs libfool.a sys.o syscalls.o - -library_install: libfool.a - cp libfool.a $(SYSROOT)/usr/lib/ +crt0.o: crt.o sys.o syscalls.o + $(LD) -r $^ -o $@ +header_install: + cp *.h $(SYSROOT)/usr/include/ + cp sys/*.h $(SYSROOT)/usr/include/sys/ clean: -rm *.o *.a diff --git a/userspace/sys/crt.S b/userspace/sys/crt.S new file mode 100644 index 0000000..d09f8ca --- /dev/null +++ b/userspace/sys/crt.S @@ -0,0 +1,20 @@ +.global _start + +_start: + +pop %eax +mov %eax, environ + +pop %eax +#mov %eax, _impure_ptr + +call main + +push environ +push %eax +call _exit2 + +# this should never be reached anyway! +.wait: + hlt +jmp .wait diff --git a/userspace/sys/crt0.S b/userspace/sys/crt0.S deleted file mode 100644 index d09f8ca..0000000 --- a/userspace/sys/crt0.S +++ /dev/null @@ -1,20 +0,0 @@ -.global _start - -_start: - -pop %eax -mov %eax, environ - -pop %eax -#mov %eax, _impure_ptr - -call main - -push environ -push %eax -call _exit2 - -# this should never be reached anyway! -.wait: - hlt -jmp .wait diff --git a/userspace/sys/crt0.o b/userspace/sys/crt0.o deleted file mode 100644 index 1b71404..0000000 Binary files a/userspace/sys/crt0.o and /dev/null differ diff --git a/userspace/sys/libfool.a b/userspace/sys/libfool.a deleted file mode 100644 index 0823595..0000000 Binary files a/userspace/sys/libfool.a and /dev/null differ diff --git a/userspace/sys/linker.ld b/userspace/sys/linker.ld new file mode 100644 index 0000000..7c1c4bf --- /dev/null +++ b/userspace/sys/linker.ld @@ -0,0 +1,37 @@ +ENTRY(_start) + +SECTIONS +{ + . = 1M; + + kernel_start = .; + + .text BLOCK(4K) : ALIGN(4K) + { + *(.multiboot) + *(.text) + } + + /* Read-only data. */ + .rodata BLOCK(4K) : ALIGN(4K) + { + *(.rodata) + } + + /* Read-write data (initialized) */ + .data BLOCK(4K) : ALIGN(4K) + { + *(.data) + } + + /* Read-write data (uninitialized) and stack */ + .bss BLOCK(4K) : ALIGN(4K) + { + *(COMMON) + *(.bss) + *(.bootstrap_stack) + } + + kernel_end = .; + +} diff --git a/userspace/sys/sgtty.h b/userspace/sys/sgtty.h new file mode 100644 index 0000000..9e91b44 --- /dev/null +++ b/userspace/sys/sgtty.h @@ -0,0 +1,15 @@ +#define TIOCFLUSH 0x01 +#define RAW 0x02 +#define CBREAK 0x04 +#define XTABS 0x08 +#define CRMOD 0x10 +#define ECHO 0x20 + +struct sgttyb{ + int sg_ospeed; + int sg_erase; + int sg_kill; + int sg_flags; + + // TODO: same struct should be used for /terminal/terminal.h ? +}; diff --git a/userspace/sys/sys.o b/userspace/sys/sys.o deleted file mode 100644 index dc5a2e3..0000000 Binary files a/userspace/sys/sys.o and /dev/null differ diff --git a/userspace/sys/sys/ioctl.h b/userspace/sys/sys/ioctl.h new file mode 100644 index 0000000..e69de29 diff --git a/userspace/sys/sys/termios.h b/userspace/sys/sys/termios.h new file mode 100644 index 0000000..b6625be --- /dev/null +++ b/userspace/sys/sys/termios.h @@ -0,0 +1,20 @@ +typedef uint32_t speed_t; +typedef uint32_t DIR; + +#define B0 0000000 /* hang up */ +#define B50 0000001 +#define B75 0000002 +#define B110 0000003 +#define B134 0000004 +#define B150 0000005 +#define B200 0000006 +#define B300 0000007 +#define B600 0000010 +#define B1200 0000011 +#define B1800 0000012 +#define B2400 0000013 +#define B4800 0000014 +#define B9600 0000015 +#define B19200 0000016 +#define B38400 0000017 + diff --git a/userspace/sys/syscalls.o b/userspace/sys/syscalls.o deleted file mode 100644 index a0a4265..0000000 Binary files a/userspace/sys/syscalls.o and /dev/null differ diff --git a/userspace/sys/termios.h b/userspace/sys/termios.h deleted file mode 100644 index b6625be..0000000 --- a/userspace/sys/termios.h +++ /dev/null @@ -1,20 +0,0 @@ -typedef uint32_t speed_t; -typedef uint32_t DIR; - -#define B0 0000000 /* hang up */ -#define B50 0000001 -#define B75 0000002 -#define B110 0000003 -#define B134 0000004 -#define B150 0000005 -#define B200 0000006 -#define B300 0000007 -#define B600 0000010 -#define B1200 0000011 -#define B1800 0000012 -#define B2400 0000013 -#define B4800 0000014 -#define B9600 0000015 -#define B19200 0000016 -#define B38400 0000017 - -- cgit v1.2.3