Fix some warnings in the decompressor and do not use special symbol main() for entry points
This commit is contained in:
parent
8410abb3d9
commit
6591a9c32f
|
@ -5,7 +5,7 @@ OBJCOPY = i386-elf-objcopy
|
||||||
CFLAGS = -flto -Os -pipe -Wall -Wextra
|
CFLAGS = -flto -Os -pipe -Wall -Wextra
|
||||||
|
|
||||||
INTERNAL_CFLAGS = \
|
INTERNAL_CFLAGS = \
|
||||||
-std=gnu99 \
|
-std=gnu11 \
|
||||||
-ffreestanding \
|
-ffreestanding \
|
||||||
-fno-stack-protector \
|
-fno-stack-protector \
|
||||||
-fno-pic \
|
-fno-pic \
|
||||||
|
@ -32,7 +32,8 @@ INTERNAL_LDFLAGS = \
|
||||||
.PHONY: all clean
|
.PHONY: all clean
|
||||||
|
|
||||||
C_FILES := $(shell find ./ -type f -name '*.c' | sort)
|
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
|
all: decompressor.bin
|
||||||
|
|
||||||
|
@ -43,5 +44,8 @@ decompressor.bin: $(OBJ)
|
||||||
%.o: %.c
|
%.o: %.c
|
||||||
$(CC) $(CFLAGS) $(INTERNAL_CFLAGS) -c $< -o $@
|
$(CC) $(CFLAGS) $(INTERNAL_CFLAGS) -c $< -o $@
|
||||||
|
|
||||||
|
%.o: %.asm
|
||||||
|
nasm $< -f elf32 -o $@
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f decompressor.bin decompressor.elf $(OBJ)
|
rm -f decompressor.bin decompressor.elf $(OBJ)
|
||||||
|
|
|
@ -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
|
|
@ -1,5 +1,5 @@
|
||||||
OUTPUT_FORMAT(elf32-i386)
|
OUTPUT_FORMAT(elf32-i386)
|
||||||
ENTRY(main)
|
ENTRY(_start)
|
||||||
|
|
||||||
SECTIONS
|
SECTIONS
|
||||||
{
|
{
|
||||||
|
|
|
@ -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 <stdint.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <gzip/tinf.h>
|
#include <gzip/tinf.h>
|
||||||
|
|
||||||
__attribute__((noreturn))
|
__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.
|
// 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);
|
tinf_gzip_uncompress(dest, compressed_stage2, stage2_size);
|
||||||
|
|
||||||
|
|
BIN
limine.bin
BIN
limine.bin
Binary file not shown.
|
@ -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
|
|
@ -1,5 +1,5 @@
|
||||||
OUTPUT_FORMAT(elf32-i386)
|
OUTPUT_FORMAT(elf32-i386)
|
||||||
ENTRY(main)
|
ENTRY(_start)
|
||||||
|
|
||||||
SECTIONS
|
SECTIONS
|
||||||
{
|
{
|
||||||
|
|
|
@ -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 <limine.h>
|
||||||
#include <lib/term.h>
|
#include <lib/term.h>
|
||||||
#include <lib/real.h>
|
#include <lib/real.h>
|
||||||
|
@ -31,7 +16,7 @@ asm (
|
||||||
#include <protos/chainload.h>
|
#include <protos/chainload.h>
|
||||||
#include <menu.h>
|
#include <menu.h>
|
||||||
|
|
||||||
void main(int boot_drive) {
|
void entry(int boot_drive) {
|
||||||
term_textmode();
|
term_textmode();
|
||||||
|
|
||||||
print("Limine " LIMINE_VERSION "\n\n");
|
print("Limine " LIMINE_VERSION "\n\n");
|
||||||
|
|
Loading…
Reference in New Issue