diff --git a/Makefile b/Makefile index 250aad2..8338202 100644 --- a/Makefile +++ b/Makefile @@ -1,12 +1,12 @@ SRCS = boot.c -LDFLAGS = -melf_i386 -nostdlib --oformat binary -T linker.ld -CFLAGS = -ffreestanding -fno-builtin -fno-pie -Wall -std=c2x -m16 -nostdlib -Os -nostartfiles +LDFLAGS = -flto -T linker.ld -nostdlib +CFLAGS = -flto -ffreestanding -fno-builtin -fno-pie -Wall -std=c2x -m16 -nostdlib -Os -nostartfiles -r %.o: %.c - $(CC) $(CFLAGS) $^ -c -o $@ + $(CC) $^ -o $@ $(CFLAGS) all: $(SRCS:.c=.o) - $(LD) $(LDFLAGS) -o bin $^ + $(CC) $(LDFLAGS) -o bin $^ clean: $(RM) $(SRCS:.c=.o) bin diff --git a/boot.c b/boot.c index 7e98b4f..6de7330 100644 --- a/boot.c +++ b/boot.c @@ -1,5 +1,5 @@ -void putchar(char); -void write(char*); +inline void putchar(char); +inline void write(char*); void _start(void) { write("Hello World!\r\n\0"); @@ -7,12 +7,12 @@ void _start(void) { ; } -void write(char *out) { +inline void write(char *out) { for (char *i = out; *i != 0; i++) putchar(*i); } -void putchar(char out) { +inline void putchar(char out) { __asm__ volatile ( "movb $0x0e, %%ah;" "movb %0, %%al;" diff --git a/linker.ld b/linker.ld index dc98d93..c23f8b9 100644 --- a/linker.ld +++ b/linker.ld @@ -1,5 +1,6 @@ ENTRY (_start) OUTPUT_FORMAT (binary) +OUTPUT_ARCH(i386) SECTIONS { . = 0x7c00;