Make resulting binary smaller.
This commit is contained in:
parent
a5b243bf82
commit
73611cde09
8
Makefile
8
Makefile
@ -1,12 +1,12 @@
|
|||||||
SRCS = boot.c
|
SRCS = boot.c
|
||||||
LDFLAGS = -melf_i386 -nostdlib --oformat binary -T linker.ld
|
LDFLAGS = -flto -T linker.ld -nostdlib
|
||||||
CFLAGS = -ffreestanding -fno-builtin -fno-pie -Wall -std=c2x -m16 -nostdlib -Os -nostartfiles
|
CFLAGS = -flto -ffreestanding -fno-builtin -fno-pie -Wall -std=c2x -m16 -nostdlib -Os -nostartfiles -r
|
||||||
|
|
||||||
%.o: %.c
|
%.o: %.c
|
||||||
$(CC) $(CFLAGS) $^ -c -o $@
|
$(CC) $^ -o $@ $(CFLAGS)
|
||||||
|
|
||||||
all: $(SRCS:.c=.o)
|
all: $(SRCS:.c=.o)
|
||||||
$(LD) $(LDFLAGS) -o bin $^
|
$(CC) $(LDFLAGS) -o bin $^
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
$(RM) $(SRCS:.c=.o) bin
|
$(RM) $(SRCS:.c=.o) bin
|
||||||
|
8
boot.c
8
boot.c
@ -1,5 +1,5 @@
|
|||||||
void putchar(char);
|
inline void putchar(char);
|
||||||
void write(char*);
|
inline void write(char*);
|
||||||
|
|
||||||
void _start(void) {
|
void _start(void) {
|
||||||
write("Hello World!\r\n\0");
|
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++)
|
for (char *i = out; *i != 0; i++)
|
||||||
putchar(*i);
|
putchar(*i);
|
||||||
}
|
}
|
||||||
|
|
||||||
void putchar(char out) {
|
inline void putchar(char out) {
|
||||||
__asm__ volatile (
|
__asm__ volatile (
|
||||||
"movb $0x0e, %%ah;"
|
"movb $0x0e, %%ah;"
|
||||||
"movb %0, %%al;"
|
"movb %0, %%al;"
|
||||||
|
Loading…
Reference in New Issue
Block a user