Fixes bug: .dtors must be .fini_array.

This commit is contained in:
Felix Queissner 2015-10-14 21:09:34 +02:00
parent f1a85fac20
commit 6599c6c306
7 changed files with 62 additions and 43 deletions

View file

@ -18,11 +18,11 @@ YACC=bison
#TEMPLE=mono /home/felix/projects/temple/bin/Debug/temple.exe #TEMPLE=mono /home/felix/projects/temple/bin/Debug/temple.exe
# Flags # Flags
FLAGS=-m32 -DCIRCUIT_OS -Dnullptr=0 -D__cdecl="__attribute__((cdecl))" -mno-sse -mno-sse2 -mno-mmx -I/home/felix/projects/Electronics/Electronics/Conductance -I/home/felix/projects/Electronics/Electronics/Tools FLAGS=-g -Wall -Wextra -m32 -DCIRCUIT_OS -Dnullptr=0 -D__cdecl="__attribute__((cdecl))" -mno-sse -mno-sse2 -mno-mmx -I/home/felix/projects/Electronics/Electronics/Conductance -I/home/felix/projects/Electronics/Electronics/Tools
ASFLAGS=-masm=intel ASFLAGS=-masm=intel
CCFLAGS=-g -std=c11 -Dnullptr=0 -Wall -g -fno-stack-protector -ffreestanding -Iinclude CCFLAGS=-std=c11 -Dnullptr=0 -fno-stack-protector -ffreestanding -Iinclude
CXXFLAGS=-g -std=c++11 -Wall -g -fno-stack-protector -fno-use-cxa-atexit -nostdlib -fno-builtin -fno-rtti -fno-exceptions -fno-leading-underscore -Wall -Wextra -ffreestanding -Wno-unused-function -Iinclude CXXFLAGS=-std=c++11 -fno-stack-protector -fno-use-cxa-atexit -nostdlib -fno-builtin -fno-rtti -fno-exceptions -fno-leading-underscore -ffreestanding -Wno-unused-function -Iinclude
LDFLAGS=-g -m32 -nostdlib -fno-builtin -Tkernel.ld LDFLAGS=-nostdlib -fno-builtin -Tkernel.ld
-- --

View file

@ -17,11 +17,11 @@ SRCS_CXX = src/cplusplus.cpp src/vm.cpp csl/casts.cpp csl/cpustatetype.cpp csl/i
OBJS = obj/dynamic.o obj/intr_common_handler.o obj/multiboot.o obj/start.o obj/console.o obj/init.o obj/interrupts.o obj/malloc.o obj/pmm.o obj/serial.o obj/stdlib.o obj/timer.o obj/vmm.o obj/cplusplus.o obj/vm.o obj/casts.o obj/cpustatetype.o obj/io.o obj/main.o OBJS = obj/dynamic.o obj/intr_common_handler.o obj/multiboot.o obj/start.o obj/console.o obj/init.o obj/interrupts.o obj/malloc.o obj/pmm.o obj/serial.o obj/stdlib.o obj/timer.o obj/vmm.o obj/cplusplus.o obj/vm.o obj/casts.o obj/cpustatetype.o obj/io.o obj/main.o
# Flags # Flags
FLAGS = -m32 -DCIRCUIT_OS -Dnullptr=0 -D__cdecl="__attribute__((cdecl))" -mno-sse -mno-sse2 -mno-mmx -I/home/felix/projects/Electronics/Electronics/Conductance -I/home/felix/projects/Electronics/Electronics/Tools FLAGS = -g -Wall -Wextra -m32 -DCIRCUIT_OS -Dnullptr=0 -D__cdecl="__attribute__((cdecl))" -mno-sse -mno-sse2 -mno-mmx -I/home/felix/projects/Electronics/Electronics/Conductance -I/home/felix/projects/Electronics/Electronics/Tools
ASFLAGS = -masm=intel ASFLAGS = -masm=intel
CCFLAGS = -g -std=c11 -Dnullptr=0 -Wall -g -fno-stack-protector -ffreestanding -Iinclude CCFLAGS = -std=c11 -Dnullptr=0 -fno-stack-protector -ffreestanding -Iinclude
CXXFLAGS = -g -std=c++11 -Wall -g -fno-stack-protector -fno-use-cxa-atexit -nostdlib -fno-builtin -fno-rtti -fno-exceptions -fno-leading-underscore -Wall -Wextra -ffreestanding -Wno-unused-function -Iinclude CXXFLAGS = -std=c++11 -fno-stack-protector -fno-use-cxa-atexit -nostdlib -fno-builtin -fno-rtti -fno-exceptions -fno-leading-underscore -ffreestanding -Wno-unused-function -Iinclude
LDFLAGS = -g -m32 -nostdlib -fno-builtin -Tkernel.ld LDFLAGS = -nostdlib -fno-builtin -Tkernel.ld
# Targets # Targets
all: kernel all: kernel

View file

@ -32,7 +32,7 @@ SECTIONS
end_ctors = .; end_ctors = .;
start_dtors = .; start_dtors = .;
*(.dtors) KEEP(*( .fini_array ));
end_dtors = .; end_dtors = .;
*(.data) *(.data)

View file

@ -55,7 +55,7 @@ BEGIN
initKeyboard(); initKeyboard();
print("Hello World!\n"); print("Hello World!\n");
1 → i; 1 → i;
WHILE i <= 5 DO WHILE i <= 5 DO
print(i, "\n"); print(i, "\n");
(i + 1) → i; (i + 1) → i;
@ -92,6 +92,11 @@ BEGIN
(scancode & 127u8) → scancode; (scancode & 127u8) → scancode;
END END
IF scancode = 0x01u8 THEN
shutdown();
RETURN;
END
# print("[scancode=", scancode, ",breakcode=", breakcode, "]"); # print("[scancode=", scancode, ",breakcode=", breakcode, "]");
IF e0Code THEN IF e0Code THEN

View file

@ -1,6 +1,6 @@
; ============================================= ; =============================================
; compiled with Copper 1.0 ; compiled with Copper 1.0
; 2015-10-13 17:50:36 ; 2015-10-14 21:08:00
; ============================================= ; =============================================
; native method: print(…) ; native method: print(…)
@ -211,8 +211,18 @@ handleKeyboardIRQ:
_private_9: _private_9:
loadg e0Code load 1
pushi 3 1
op2 5
jmp_if_not _private_10 jmp_if_not _private_10
calln shutdown 0
ret
_private_10:
loadg e0Code
jmp_if_not _private_11
load 1 load 1
pushi 3 42 pushi 3 42
op2 5 op2 5
@ -220,13 +230,13 @@ _private_9:
pushi 3 54 pushi 3 54
op2 5 op2 5
op2 11 op2 11
jmp_if_not _private_12 jmp_if_not _private_13
pushi 6 0 pushi 6 0
storeg e0Code storeg e0Code
ret ret
_private_12: _private_13:
load 1 load 1
callnr toInt32 1 callnr toInt32 1
@ -237,12 +247,12 @@ _private_12:
pushi 6 0 pushi 6 0
storeg e0Code storeg e0Code
jmp _private_11 jmp _private_12
_private_10: _private_11:
loadg e1Code loadg e1Code
pushi 2 2 pushi 2 2
op2 5 op2 5
jmp_if_not _private_13 jmp_if_not _private_14
loadg e1Prev loadg e1Prev
load 1 load 1
pushi 3 256 pushi 3 256
@ -260,12 +270,12 @@ _private_10:
pushi 2 0 pushi 2 0
storeg e1Code storeg e1Code
jmp _private_14 jmp _private_15
_private_13: _private_14:
loadg e1Code loadg e1Code
pushi 2 1 pushi 2 1
op2 5 op2 5
jmp_if_not _private_15 jmp_if_not _private_16
load 1 load 1
callnr toUInt16 1 callnr toUInt16 1
storeg e1Prev storeg e1Prev
@ -273,51 +283,51 @@ _private_13:
pushi 2 2 pushi 2 2
storeg e1Code storeg e1Code
jmp _private_16 jmp _private_17
_private_15: _private_16:
load 1 load 1
pushi 3 224 pushi 3 224
op2 5 op2 5
jmp_if_not _private_17 jmp_if_not _private_18
pushi 6 1 pushi 6 1
storeg e0Code storeg e0Code
jmp _private_18 jmp _private_19
_private_17: _private_18:
load 1 load 1
pushi 3 225 pushi 3 225
op2 5 op2 5
jmp_if_not _private_19 jmp_if_not _private_20
pushi 2 1 pushi 2 1
storeg e1Code storeg e1Code
jmp _private_20 jmp _private_21
_private_19: _private_20:
load 1 load 1
callnr toInt32 1 callnr toInt32 1
pushi 2 0 pushi 2 0
callr translateKeyCode 2 callr translateKeyCode 2
store 2 store 2
_private_20: _private_21:
_private_18: _private_19:
_private_16: _private_17:
_private_14: _private_15:
_private_11: _private_12:
load 2 load 2
pushi 2 0 pushi 2 0
op2 6 op2 6
jmp_if_not _private_21 jmp_if_not _private_22
load 3 load 3
load 2 load 2
call handleKeyPress 2 call handleKeyPress 2
_private_21: _private_22:
ret ret
; end of handleKeyboardIRQ ; end of handleKeyboardIRQ
@ -329,10 +339,10 @@ irq:
load -1 load -1
pushi 2 33 pushi 2 33
op2 5 op2 5
jmp_if_not _private_22 jmp_if_not _private_23
call handleKeyboardIRQ 0 call handleKeyboardIRQ 0
_private_22: _private_23:
load -2 load -2
destruct destruct

View file

@ -72,8 +72,6 @@ extern "C" void cpp_init()
initialiseConstructors(); initialiseConstructors();
} }
typedef void (*destructor)(); typedef void (*destructor)();
// Im Linkerskript definiert // Im Linkerskript definiert
@ -85,7 +83,9 @@ extern CompoundType type;
extern "C" void cpp_exit() extern "C" void cpp_exit()
{ {
for (destructor* i = &start_dtors; i != &end_dtors;++i) for (destructor* i = &start_dtors; i != &end_dtors;++i) {
kprintf("[dtor:%x]", *i);
(*i)(); (*i)();
}
type.~CompoundType(); // TODO: Remove this. This is dirty. Get the destructor to make a clean exit. type.~CompoundType(); // TODO: Remove this. This is dirty. Get the destructor to make a clean exit.
} }

View file

@ -264,15 +264,19 @@ void free(void *ptr)
freeCount++; freeCount++;
List *entry = (List*)((char*)ptr - sizeof(List)); List *entry = (List*)((char*)ptr - sizeof(List));
if(entry->used == 0) {
die_extra("free.InvalidBlock", itoa((int)ptr, nullptr, 16));
}
#if defined(USE_MAGIC_SECURED_MALLOC) #if defined(USE_MAGIC_SECURED_MALLOC)
if(isValid(entry) == 0) { if(isValid(entry) == 0) {
die_extra("free.InvalidBlockMagic: ", itoa(entry->hash, nullptr, 16)); die_extra("free.InvalidBlockMagic: ", itoa(entry->hash, nullptr, 16));
} }
#endif #endif
if(entry->used == 0) {
static char buffer[16];
itoa((int)ptr, buffer, 16);
die_extra("free.InvalidBlock", buffer);
}
if(entry->length > 0x5000) { if(entry->length > 0x5000) {
die_extra("free.InvalidSizedBlock: ", itoa(entry->length, nullptr, 10)); die_extra("free.InvalidSizedBlock: ", itoa(entry->length, nullptr, 10));
} }