[elf] Fix argument passing
This commit is contained in:
parent
e273784242
commit
fe40c7bbf6
5
Makefile
5
Makefile
@ -14,7 +14,7 @@ ECHO = `which echo` -e
|
|||||||
MODULES = $(patsubst %.c,%.o,$(wildcard kernel/core/*.c))
|
MODULES = $(patsubst %.c,%.o,$(wildcard kernel/core/*.c))
|
||||||
FILESYSTEMS = $(patsubst %.c,%.o,$(wildcard kernel/core/fs/*.c))
|
FILESYSTEMS = $(patsubst %.c,%.o,$(wildcard kernel/core/fs/*.c))
|
||||||
VIDEODRIVERS = $(patsubst %.c,%.o,$(wildcard kernel/core/video/*.c))
|
VIDEODRIVERS = $(patsubst %.c,%.o,$(wildcard kernel/core/video/*.c))
|
||||||
BINARIES = initrd/bin/test
|
BINARIES = initrd/bin/test initrd/bin/echo
|
||||||
UTILITIES = util/bin/readelf
|
UTILITIES = util/bin/readelf
|
||||||
EMU = qemu
|
EMU = qemu
|
||||||
GENEXT = genext2fs
|
GENEXT = genext2fs
|
||||||
@ -112,11 +112,10 @@ loader/crtbegin.o: loader/crtbegin.s
|
|||||||
@${YASM} -f elf32 -o $@ $<
|
@${YASM} -f elf32 -o $@ $<
|
||||||
@${ECHO} "\r\033[32;1m yasm $<\033[0m"
|
@${ECHO} "\r\033[32;1m yasm $<\033[0m"
|
||||||
|
|
||||||
initrd/bin/test: loader/test.o loader/crtbegin.o
|
initrd/bin/%: loader/%.o loader/crtbegin.o
|
||||||
@${ECHO} -n "\033[32m LD $<\033[0m"
|
@${ECHO} -n "\033[32m LD $<\033[0m"
|
||||||
@${LD} -T loader/link.ld -o $@ $<
|
@${LD} -T loader/link.ld -o $@ $<
|
||||||
@${ECHO} "\r\033[32;1m LD $<\033[0m"
|
@${ECHO} "\r\033[32;1m LD $<\033[0m"
|
||||||
@${ECHO} "\033[34;1m -- Kernel is ready!\033[0m"
|
|
||||||
|
|
||||||
loader/%.o: loader/%.c
|
loader/%.o: loader/%.c
|
||||||
@${ECHO} -n "\033[32m CC $<\033[0m"
|
@${ECHO} -n "\033[32m CC $<\033[0m"
|
||||||
|
@ -2,8 +2,7 @@ BITS 32
|
|||||||
|
|
||||||
global _start
|
global _start
|
||||||
_start:
|
_start:
|
||||||
push 0 ; argc
|
pop eax
|
||||||
push 0 ; argv
|
|
||||||
extern main
|
extern main
|
||||||
call main
|
call main
|
||||||
mov ebx, eax ; return value from main
|
mov ebx, eax ; return value from main
|
||||||
|
16
loader/echo.c
Normal file
16
loader/echo.c
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
int syscall_print(const char * p1) {
|
||||||
|
int a = 0xA5ADFACE;
|
||||||
|
__asm__ __volatile__("int $0x7F" : "=a" (a) : "0" (1), "b" ((int)p1));
|
||||||
|
return a;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int argc, char ** argv) {
|
||||||
|
for (int i = 1; i < argc; ++i) {
|
||||||
|
syscall_print(argv[i]);
|
||||||
|
if (i != argc - 1) {
|
||||||
|
syscall_print(" ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
syscall_print("\n");
|
||||||
|
return 0;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user