diff options
author | Marvin Borner | 2021-02-26 14:51:13 +0100 |
---|---|---|
committer | Marvin Borner | 2021-02-26 14:51:13 +0100 |
commit | 0f00932955521c3c2fb8140176ab72f22172c298 (patch) | |
tree | 99561c0254d14c0c3536f900ee83b0341a5c8a1b /boot | |
parent | dec16faf32e75d613e20cac175b8a0c2d3612b94 (diff) |
Started UBSan and stack-smashing check support
Diffstat (limited to 'boot')
-rw-r--r-- | boot/Makefile | 2 | ||||
-rw-r--r-- | boot/load.c | 17 |
2 files changed, 8 insertions, 11 deletions
diff --git a/boot/Makefile b/boot/Makefile index 6d38ce5..714ec22 100644 --- a/boot/Makefile +++ b/boot/Makefile @@ -5,7 +5,7 @@ LD = ccache ../cross/opt/bin/i686-elf-ld OC = ccache ../cross/opt/bin/i686-elf-objcopy AS = ccache nasm -CFLAGS = $(CFLAGS_DEFAULT) -ffreestanding +CFLAGS = $(CFLAGS_DEFAULT) -ffreestanding -fno-stack-protector -fno-sanitize=undefined ASFLAGS = -f elf32 diff --git a/boot/load.c b/boot/load.c index 69024c0..b243629 100644 --- a/boot/load.c +++ b/boot/load.c @@ -136,7 +136,8 @@ void serial_print(const char *data); int main(void *data) { serial_install(); - heap = 0xf000; + serial_print("Loaded bootloader!\n"); + heap = 0xf00000; void (*entry)(void *); *(void **)(&entry) = read_inode(get_inode(find_inode("kernel.bin", 2))); if (entry) { @@ -329,7 +330,7 @@ void *read_inode(struct inode *in) if (!in) return 0; - int num_blocks = in->blocks / (BLOCK_SIZE / SECTOR_SIZE); + u32 num_blocks = in->blocks / (BLOCK_SIZE / SECTOR_SIZE); //assert(num_blocks != 0); if (!num_blocks) @@ -341,24 +342,20 @@ void *read_inode(struct inode *in) int indirect; int blocknum; - char *data; - for (int i = 0; i < num_blocks; i++) { + for (u32 i = 0; i < num_blocks; i++) { if (i < 12) { blocknum = in->block[i]; - data = buffer_read(blocknum); - memcpy((u32 *)((u32)buf + i * BLOCK_SIZE), data, BLOCK_SIZE); } else if (i < BLOCK_COUNT + 12) { indirect = in->block[12]; blocknum = read_indirect(indirect, i - 12); - data = buffer_read(blocknum); - memcpy((u32 *)((u32)buf + i * BLOCK_SIZE), data, BLOCK_SIZE); } else { indirect = in->block[13]; blocknum = read_indirect(indirect, (i - (BLOCK_COUNT + 12)) / BLOCK_COUNT); blocknum = read_indirect(blocknum, (i - (BLOCK_COUNT + 12)) % BLOCK_COUNT); - data = buffer_read(blocknum); - memcpy((u32 *)((u32)buf + i * BLOCK_SIZE), data, BLOCK_SIZE); } + + char *data = buffer_read(blocknum); + memcpy((u32 *)((u32)buf + i * BLOCK_SIZE), data, BLOCK_SIZE); } return buf; |