Fix some warnings in the decompressor and do not use special symbol main() for entry points
diff --git a/decompressor/Makefile b/decompressor/Makefile
index 4fd006c5..1f78f0d3 100644
--- a/decompressor/Makefile
+++ b/decompressor/Makefile
@@ -5,7 +5,7 @@ OBJCOPY = i386-elf-objcopy
CFLAGS = -flto -Os -pipe -Wall -Wextra
INTERNAL_CFLAGS = \
- -std=gnu99 \
+ -std=gnu11 \
-ffreestanding \
-fno-stack-protector \
-fno-pic \
@@ -32,7 +32,8 @@ INTERNAL_LDFLAGS = \
.PHONY: all clean
C_FILES := $(shell find ./ -type f -name '*.c' | sort)
-OBJ := $(C_FILES:.c=.o)
+ASM_FILES := $(shell find ./ -type f -name '*.asm' | sort)
+OBJ := $(ASM_FILES:.asm=.o) $(C_FILES:.c=.o)
all: decompressor.bin
@@ -43,5 +44,8 @@ decompressor.bin: $(OBJ)
%.o: %.c
$(CC) $(CFLAGS) $(INTERNAL_CFLAGS) -c $< -o $@
+%.o: %.asm
+ nasm $< -f elf32 -o $@
+
clean:
rm -f decompressor.bin decompressor.elf $(OBJ)
diff --git a/decompressor/entry.asm b/decompressor/entry.asm
new file mode 100644
index 00000000..c2b94a97
--- /dev/null
+++ b/decompressor/entry.asm
@@ -0,0 +1,18 @@
+extern bss_begin
+extern bss_end
+extern entry
+
+section .entry
+
+global _start
+_start:
+ cld
+
+ ; Zero out .bss
+ xor al, al
+ mov edi, bss_begin
+ mov ecx, bss_end
+ sub ecx, bss_begin
+ rep stosb
+
+ jmp entry
diff --git a/decompressor/linker.ld b/decompressor/linker.ld
index 12b58ef4..a5bae43a 100644
--- a/decompressor/linker.ld
+++ b/decompressor/linker.ld
@@ -1,5 +1,5 @@
OUTPUT_FORMAT(elf32-i386)
-ENTRY(main)
+ENTRY(_start)
SECTIONS
{
diff --git a/decompressor/main.c b/decompressor/main.c
index b1c9ffa2..68cd0a67 100644
--- a/decompressor/main.c
+++ b/decompressor/main.c
@@ -1,27 +1,11 @@
-asm (
- ".section .entry\n\t"
-
- "cld\n\t"
-
- // Zero out .bss
- "xor al, al\n\t"
- "mov edi, OFFSET bss_begin\n\t"
- "mov ecx, OFFSET bss_end\n\t"
- "sub ecx, OFFSET bss_begin\n\t"
- "rep stosb\n\t"
-
- "mov ebx, OFFSET main\n\t"
- "jmp ebx\n\t"
-);
-
#include <stdint.h>
#include <stddef.h>
#include <gzip/tinf.h>
__attribute__((noreturn))
-void main(uint8_t *compressed_stage2, size_t stage2_size, uint8_t boot_drive) {
+void entry(uint8_t *compressed_stage2, size_t stage2_size, uint8_t boot_drive) {
// The decompressor should decompress compressed_stage2 to address 0x4000.
- volatile uint8_t *dest = (volatile uint8_t *)0x4000;
+ uint8_t *dest = (uint8_t *)0x4000;
tinf_gzip_uncompress(dest, compressed_stage2, stage2_size);
diff --git a/limine.bin b/limine.bin
index 36f13670..8ae96e1c 100644
Binary files a/limine.bin and b/limine.bin differ
diff --git a/stage2/entry.asm b/stage2/entry.asm
new file mode 100644
index 00000000..c2b94a97
--- /dev/null
+++ b/stage2/entry.asm
@@ -0,0 +1,18 @@
+extern bss_begin
+extern bss_end
+extern entry
+
+section .entry
+
+global _start
+_start:
+ cld
+
+ ; Zero out .bss
+ xor al, al
+ mov edi, bss_begin
+ mov ecx, bss_end
+ sub ecx, bss_begin
+ rep stosb
+
+ jmp entry
diff --git a/stage2/linker.ld b/stage2/linker.ld
index 7f7ddf0d..3f0d47c1 100644
--- a/stage2/linker.ld
+++ b/stage2/linker.ld
@@ -1,5 +1,5 @@
OUTPUT_FORMAT(elf32-i386)
-ENTRY(main)
+ENTRY(_start)
SECTIONS
{
diff --git a/stage2/main.c b/stage2/main.c
index 10fbad1f..47e54ee4 100644
--- a/stage2/main.c
+++ b/stage2/main.c
@@ -1,18 +1,3 @@
-asm (
- ".section .entry\n\t"
-
- "cld\n\t"
-
- // Zero out .bss
- "xor al, al\n\t"
- "mov edi, OFFSET bss_begin\n\t"
- "mov ecx, OFFSET bss_end\n\t"
- "sub ecx, OFFSET bss_begin\n\t"
- "rep stosb\n\t"
-
- "jmp main\n\t"
-);
-
#include <limine.h>
#include <lib/term.h>
#include <lib/real.h>
@@ -31,7 +16,7 @@ asm (
#include <protos/chainload.h>
#include <menu.h>
-void main(int boot_drive) {
+void entry(int boot_drive) {
term_textmode();
print("Limine " LIMINE_VERSION "\n\n");
