SeaBIOS (version rel-1.12.0-0-ga698c8995f-prebuilt.qemu.org)
iPXE (http://ipxe.org) 00:03.0 C980 PCI2.10 PnP PMM+07F91250+07EF1250 C980
Booting from ROM..
kernel: формат файла elf32-i386
kernel
архитектура: i386, флаги 0x00000112:
EXEC_P, HAS_SYMS, D_PAGED
начальный адрес 0x00101030
Заголовок программы:
LOAD off 0x00001000 vaddr 0x00100000 paddr 0x00100000 align 2**12
filesz 0x000010bc memsz 0x00001314 flags rwx
Разделы:
Idx Name Size VMA LMA File off Algn
0 .boot 00000014 00100000 00100000 00001000 2**2
CONTENTS, ALLOC, LOAD, READONLY, DATA
1 .rdata 00000024 00101000 00101000 00002000 2**2
CONTENTS, ALLOC, LOAD, READONLY, DATA
2 .text 0000008c 00101030 00101030 00002030 2**4
CONTENTS, ALLOC, LOAD, READONLY, CODE
3 .bss 00000258 001010bc 001010bc 000020bc 2**2
ALLOC
SYMBOL TABLE:
0000000d l *ABS* 00000000 main.c
00101044 l .text 00000000 .text
00101314 l .bss 00000000 .bss
00101000 l .rdata 00000000 .rdata
00101010 l .rdata 00000000 .rdata$zzz
00000018 l *ABS* 00000000 ./loader.asm
1badb002 l *ABS* 00000000 MAGIC
00000002 l *ABS* 00000000 MEMINFO
00000001 l *ABS* 00000000 MBALIGN
00000003 l *ABS* 00000000 FLAGS
00000258 l *ABS* 00000000 STACK_SIZE
001010bc l .bss 00000000 stack_end
00101314 l .bss 00000000 stack_top
00100000 l .boot 00000000 grubBoot
00100014 l .boot 00000000 end_grubBoot
00100000 l d .boot 00000000 .boot
00101000 l d .rdata 00000000 .rdata
00101030 l d .text 00000000 .text
001010bc l d .bss 00000000 .bss
00101044 g F .text 00000000 _print_str
001010a5 g F .text 00000000 __kmain
00000000 g *ABS* 00000000 __dll_characteristics__
00001000 g *ABS* 00000000 __size_of_stack_commit__
00200000 g *ABS* 00000000 __size_of_stack_reserve__
00000004 g *ABS* 00000000 __major_subsystem_version__
00001000 g *ABS* 00000000 __size_of_heap_commit__
00000000 g *ABS* 00000000 __dll__
00000000 g *ABS* 00000000 __minor_os_version__
00400000 g *ABS* 00000000 __image_base__
00001000 g *ABS* 00000000 __section_alignment__
00000200 g *ABS* 00000000 __file_alignment__
00000004 g *ABS* 00000000 __major_os_version__
00100000 g *ABS* 00000000 __size_of_heap_reserve__
00400000 g *ABS* 00000000 ___ImageBase
00000003 g *ABS* 00000000 __subsystem__
00101030 g .text 00000000 _loadkernel
00000001 g *ABS* 00000000 __major_image_version__
00000000 g *ABS* 00000000 __loader_flags__
00000000 g *ABS* 00000000 __minor_subsystem_version__
00000000 g *ABS* 00000000 __minor_image_version__
Содержимое раздела .boot:
100000 02b0ad1b 03000000 fb4f52e4 14000000 .........OR.....
100010 e74f52e4 .OR.
Содержимое раздела .rdata:
101000 68656c6c 6f20776f 726c6421 00000000 hello world!....
101010 4743433a 2028474e 55292037 2e342e30 GCC: (GNU) 7.4.0
101020 00000000 ....
Содержимое раздела .text:
101030 9bdbe3bc 14131000 5350e866 000000fa ........SP.f....
101040 f4669090 5589e583 ec10c745 f800800b .f..U......E....
101050 00c745fc 00000000 eb358b45 fc8d1400 ..E......5.E....
101060 8b45f801 d00fb700 b00089c1 8b55fc8b .E...........U..
101070 450801d0 0fb60066 9809c189 ca8b45fc E......f......E.
101080 8d0c008b 45f801c8 66891083 45fc018b ....E...f...E...
101090 55fc8b45 0801d00f b6000fbe c03945fc U..E.........9E.
1010a0 7cb890c9 c35589e5 83ec04c7 04240010 |....U.......$..
1010b0 1000e88d ffffffeb fe909090 ............
Дизассемблирование раздела .text:
00101030 <_loadkernel>:
101030: 9b db e3 finit
101033: bc 14 13 10 00 mov $0x101314,%esp
101038: 53 push %ebx
101039: 50 push %eax
10103a: e8 66 00 00 00 call 1010a5 <__kmain>
10103f: fa cli
101040: f4 hlt
101041: 66 90 xchg %ax,%ax
101043: 90 nop
00101044 <_print_str>:
101044: 55 push %ebp
101045: 89 e5 mov %esp,%ebp
101047: 83 ec 10 sub $0x10,%esp
10104a: c7 45 f8 00 80 0b 00 movl $0xb8000,-0x8(%ebp)
101051: c7 45 fc 00 00 00 00 movl $0x0,-0x4(%ebp)
101058: eb 35 jmp 10108f <_print_str+0x4b>
10105a: 8b 45 fc mov -0x4(%ebp),%eax
10105d: 8d 14 00 lea (%eax,%eax,1),%edx
101060: 8b 45 f8 mov -0x8(%ebp),%eax
101063: 01 d0 add %edx,%eax
101065: 0f b7 00 movzwl (%eax),%eax
101068: b0 00 mov $0x0,%al
10106a: 89 c1 mov %eax,%ecx
10106c: 8b 55 fc mov -0x4(%ebp),%edx
10106f: 8b 45 08 mov 0x8(%ebp),%eax
101072: 01 d0 add %edx,%eax
101074: 0f b6 00 movzbl (%eax),%eax
101077: 66 98 cbtw
101079: 09 c1 or %eax,%ecx
10107b: 89 ca mov %ecx,%edx
10107d: 8b 45 fc mov -0x4(%ebp),%eax
101080: 8d 0c 00 lea (%eax,%eax,1),%ecx
101083: 8b 45 f8 mov -0x8(%ebp),%eax
101086: 01 c8 add %ecx,%eax
101088: 66 89 10 mov %dx,(%eax)
10108b: 83 45 fc 01 addl $0x1,-0x4(%ebp)
10108f: 8b 55 fc mov -0x4(%ebp),%edx
101092: 8b 45 08 mov 0x8(%ebp),%eax
101095: 01 d0 add %edx,%eax
101097: 0f b6 00 movzbl (%eax),%eax
10109a: 0f be c0 movsbl %al,%eax
10109d: 39 45 fc cmp %eax,-0x4(%ebp)
1010a0: 7c b8 jl 10105a <_print_str+0x16>
1010a2: 90 nop
1010a3: c9 leave
1010a4: c3 ret
001010a5 <__kmain>:
1010a5: 55 push %ebp
1010a6: 89 e5 mov %esp,%ebp
1010a8: 83 ec 04 sub $0x4,%esp
1010ab: c7 04 24 00 10 10 00 movl $0x101000,(%esp)
1010b2: e8 8d ff ff ff call 101044 <_print_str>
1010b7: eb fe jmp 1010b7 <__kmain+0x12>
1010b9: 90 nop
1010ba: 90 nop
1010bb: 90 nop
gcc -m32 -std=c11 -c ./main.c -ffreestanding -nostdlib -nostdinc -fno-pic
nasm -f elf32 ./loader.asm
mv *.o build/
ld -mi386pe --nmagic -Tlink.ld -o build/kernel.bin build/*.o
objcopy -O elf32-i386 build/kernel.bin kernel
qemu-system-i386 -nographic -kernel kernel
C:\Program Files\qemu\qemu-system-i386.exe: Error loading uncompressed kernel without PVH ELF Note
также
kmalloc, до вкл. кучи - pl_sbrk, после - маллок
но sbrk я пока, ещё не сделал