fix bug in the initializtion of the BSS section

- DO NOT LONGER USE the compiler flag "-fno-zero-initialized-in-bss"
This commit is contained in:
Stefan Lankes 2011-06-09 08:18:12 +02:00
parent 3b79af56a3
commit 393808e198
6 changed files with 20 additions and 9 deletions

View file

@ -26,9 +26,9 @@ MAKE = make
NASMFLAGS = -felf32 -g
INCLUDE = -I$(TOPDIR)/include -I$(TOPDIR)/arch/$(ARCH)/include -I$(TOPDIR)/lwip/src/include -I$(TOPDIR)/lwip/src/include/ipv4 -I$(TOPDIR)/drivers
# Compiler options for final code
CFLAGS = -g -m32 -march=i586 -Wall -O2 -fno-zero-initialized-in-bss -fno-builtin -fstrength-reduce -fomit-frame-pointer -finline-functions -nostdinc $(INCLUDE) -fno-stack-protector
CFLAGS = -g -m32 -march=i586 -Wall -O2 -fno-builtin -fstrength-reduce -fomit-frame-pointer -finline-functions -nostdinc $(INCLUDE) -fno-stack-protector
# Compiler options for debuuging
#CFLAGS = -g -O -m32 -march=i586 -Wall -fno-zero-initialized-in-bss -fno-builtin -DWITH_FRAME_POINTER -nostdinc $(INCLUDE) -fno-stack-protector
#CFLAGS = -g -O -m32 -march=i586 -Wall -fno-builtin -DWITH_FRAME_POINTER -nostdinc $(INCLUDE) -fno-stack-protector
ARFLAGS = rsv
RM = rm -rf
LDFLAGS = -T link.ld -z max-page-size=4096 --defsym __BUILD_DATE=$(shell date +'%Y%m%d') --defsym __BUILD_TIME=$(shell date +'%H%M%S')

View file

@ -73,7 +73,7 @@ stublet:
; clears the current pgd entry
xor eax, eax
mov cr3, eax
; disable SSE support (TODO)
; at this stage, we disable the SSE support
mov eax, cr4
and eax, 0xfffbf9ff
mov cr4, eax

View file

@ -28,10 +28,10 @@
gdt_ptr_t gp;
static tss_t task_state_segments[MAX_TASKS] __attribute__ ((aligned (PAGE_SIZE)));
static unsigned char kstacks[MAX_TASKS][KERNEL_STACK_SIZE] __attribute__ ((aligned (PAGE_SIZE)));
static unsigned char kstacks[MAX_TASKS][KERNEL_STACK_SIZE] __attribute__ ((aligned (PAGE_SIZE) section (".data")));
// currently, our kernel has full access to the ioports
static gdt_entry_t gdt[GDT_ENTRIES] = {[0 ... GDT_ENTRIES-1] = {0, 0, 0, 0, 0, 0}};
unsigned char* default_stack_pointer = kstacks[0] + KERNEL_STACK_SIZE - sizeof(size_t);
unsigned char* default_stack_pointer __attribute__ ((section (".data"))) = kstacks[0] + KERNEL_STACK_SIZE - sizeof(size_t);
/*
* This is in start.asm. We use this to properly reload

View file

@ -37,7 +37,7 @@
*/
/** Global multiboot information structure pointer */
multiboot_info_t* mb_info = NULL;
multiboot_info_t* mb_info __attribute__ ((section (".data"))) = NULL;
#endif
/** @brief initialization procedure for Multiboot information structure

View file

@ -43,10 +43,22 @@ void ping_init(void);
static volatile int done = 0;
/*
* Note that linker symbols are not variables, they have no memory allocated for
* maintaining a value, rather their address is their value.
*/
extern const void bss_start;
extern const void bss_end;
int lowlevel_init(void)
{
// initialize .bss section
memset((void*)&bss_start, 0x00, ((size_t) &bss_end - (size_t) &bss_start));
koutput_init();
//kprintf("Now, the BSS section (0x%x - 0x%x) is initialized.\n", (size_t) &bss_start, (size_t) &bss_end);
return 0;
}

View file

@ -13,9 +13,6 @@ SECTIONS
.text ALIGN(4096) : AT(ADDR(.text)) {
*(.text)
}
.rdata ALIGN(4096) : AT(ADDR(.rdata)) {
*(.rdata)
}
.rodata ALIGN(4096) : AT(ADDR(.rodata)) {
*(.rodata)
*(.rodata.*)
@ -23,8 +20,10 @@ SECTIONS
.data ALIGN(4096) : AT(ADDR(.data)) {
*(.data)
}
bss_start = .;
.bss ALIGN(4096) : AT(ADDR(.bss)) {
*(.bss)
}
bss_end = .;
kernel_end = .;
}