hex2: fix free_pool bug.
r12 was not pointing towards begining of pool, hence we were not freeing allocated memory.
This commit is contained in:
parent
ce5f77ddc5
commit
e3ccc9b046
|
@ -9,6 +9,7 @@ DEFINE ADDI8_to_RDI 4883C7
|
|||
DEFINE ADDI8_to_RSI 4883C6
|
||||
DEFINE ADDI8_to_R12 4983C4
|
||||
DEFINE ADDI8_to_R13 4983C5
|
||||
DEFINE ADDI32_RAX 4805
|
||||
DEFINE ADDI32_RDX 4881C2
|
||||
DEFINE ADD_R14_to_RAX 4C01F0
|
||||
DEFINE CALLI32 E8
|
||||
|
@ -50,7 +51,6 @@ DEFINE JE32 0F84
|
|||
DEFINE JL32 0F8C
|
||||
DEFINE JMP32 E9
|
||||
DEFINE JNE32 0F85
|
||||
DEFINE LOADI8_DH B6
|
||||
DEFINE LOADI8_AL B0
|
||||
DEFINE LOADI32_RAX 48C7C0
|
||||
DEFINE LOADI32_RCX 48C7C1
|
||||
|
@ -136,12 +136,6 @@ DEFINE ZERO_EXTEND_BL 480FB6DB
|
|||
LOAD64_into_R14_from_Address_RDX_Immediate8 !96 # system->boot
|
||||
STORE64_rel_R14 %SystemBoot # save system->boot
|
||||
|
||||
# Allocate pool for scratch area
|
||||
XOR_EDX_EDX # zero rdx
|
||||
LOADI8_DH !0x8 # arg2 = 256 * 8 = 2048 = 0x800
|
||||
CALLI32 %allocate_pool
|
||||
STORE64_rel_RAX %scratch # save scratch
|
||||
|
||||
# Open Loaded Image protocol
|
||||
PUSH_RAX # allocate stack for image
|
||||
COPY_RSP_to_R8 # arg3 = &image
|
||||
|
@ -233,10 +227,12 @@ DEFINE ZERO_EXTEND_BL 480FB6DB
|
|||
CALL_RCX_Immediate8 !8 # rootdir->open()
|
||||
LOAD64_into_R10_from_Address_RSP_Immediate8 !40 # get fout
|
||||
|
||||
# Allocate pool for structs
|
||||
# Allocate ourselves 16 MiB of memory
|
||||
LOADI32_RDX %0x1000000 # allocate 16 MiB of memory
|
||||
CALLI32 %allocate_pool
|
||||
COPY_RAX_to_R12 # get structs
|
||||
STORE64_rel_RAX %scratch # Allocate space for scratch area
|
||||
ADDI32_RAX %0x800 # 2 KiB of scratch
|
||||
COPY_RAX_to_R12 # save structs pointer
|
||||
|
||||
CALLI32 %ClearScratch # Zero scratch
|
||||
LOADI32_R15 %-1 # Our flag for byte processing
|
||||
|
@ -729,9 +725,6 @@ DEFINE ZERO_EXTEND_BL 480FB6DB
|
|||
LOAD64_rel_RCX %scratch # arg1 = scratch
|
||||
CALL_R14_Immediate8 !72 # system->boot->free_pool(scratch)
|
||||
|
||||
COPY_R12_to_RCX # arg1 = structs
|
||||
CALL_R14_Immediate8 !72 # system->boot->free_pool(structs)
|
||||
|
||||
LOAD64_rel_RCX %fin # arg1 = fin
|
||||
CALL_RCX_Immediate8 !16 # fin->close(fin)
|
||||
POP_RAX # deallocate stack
|
||||
|
|
|
@ -132,9 +132,9 @@ F0 00 # SizeOfOptionalHeader
|
|||
# [0x148]
|
||||
# Start of section headers
|
||||
00 00 00 00 00 00 00 00 ; Name of the section (empty) but could set to ".text"
|
||||
5C 06 00 00 ; VirtualSize
|
||||
52 06 00 00 ; VirtualSize
|
||||
00 10 00 00 ; VirtualAddress
|
||||
5C 06 00 00 ; SizeOfRawData
|
||||
52 06 00 00 ; SizeOfRawData
|
||||
70 01 00 00 ; PointerToRawData
|
||||
00 00 00 00 ; PointerToRelocations
|
||||
00 00 00 00 ; PointerToLinenumbers
|
||||
|
@ -153,12 +153,6 @@ F0 00 # SizeOfOptionalHeader
|
|||
4C8B72 60 ; LOAD64_into_R14_from_Address_RDX_Immediate8 !96 # system->boot
|
||||
4C8935 %1 ; STORE64_rel_R14 %SystemBoot # save system->boot
|
||||
|
||||
# Allocate pool for scratch area
|
||||
31D2 ; XOR_EDX_EDX # zero rdx
|
||||
B6 08 ; LOADI8_DH !0x8 # arg2 = 256 * 8 = 2048 = 0x800
|
||||
E8 %U ; CALLI32 %allocate_pool
|
||||
488905 %0 ; STORE64_rel_RAX %scratch # save scratch
|
||||
|
||||
# Open Loaded Image protocol
|
||||
50 ; PUSH_RAX # allocate stack for image
|
||||
4989E0 ; COPY_RSP_to_R8 # arg3 = &image
|
||||
|
@ -250,10 +244,12 @@ F0 00 # SizeOfOptionalHeader
|
|||
FF51 08 ; CALL_RCX_Immediate8 !8 # rootdir->open()
|
||||
4C8B5424 28 ; LOAD64_into_R10_from_Address_RSP_Immediate8 !40 # get fout
|
||||
|
||||
# Allocate pool for structs
|
||||
# Allocate ourselves 16 MiB of memory
|
||||
48C7C2 00000001 ; LOADI32_RDX %0x1000000 # allocate 16 MiB of memory
|
||||
E8 %U ; CALLI32 %allocate_pool
|
||||
4989C4 ; COPY_RAX_to_R12 # get structs
|
||||
488905 %0 ; STORE64_rel_RAX %scratch # Allocate space for scratch area
|
||||
4805 00080000 ; ADDI32_RAX %0x800 # 2 KiB of scratch
|
||||
4989C4 ; COPY_RAX_to_R12 # save structs pointer
|
||||
|
||||
E8 %H ; CALLI32 %ClearScratch # Zero scratch
|
||||
49C7C7 FFFFFFFF ; LOADI32_R15 %-1 # Our flag for byte processing
|
||||
|
@ -746,9 +742,6 @@ F0 00 # SizeOfOptionalHeader
|
|||
488B0D %0 ; LOAD64_rel_RCX %scratch # arg1 = scratch
|
||||
41FF56 48 ; CALL_R14_Immediate8 !72 # system->boot->free_pool(scratch)
|
||||
|
||||
4C89E1 ; COPY_R12_to_RCX # arg1 = structs
|
||||
41FF56 48 ; CALL_R14_Immediate8 !72 # system->boot->free_pool(structs)
|
||||
|
||||
488B0D %Z ; LOAD64_rel_RCX %fin # arg1 = fin
|
||||
FF51 10 ; CALL_RCX_Immediate8 !16 # fin->close(fin)
|
||||
58 ; POP_RAX # deallocate stack
|
||||
|
|
Loading…
Reference in New Issue