grub 似乎没有正确加载我的内核



我使用grub加载内核。尽管我具体说明了=0x100 0000在链接器脚本中,我只能在0x10 0000处找到有效的MultiBoot2标头。经过一个接一个的比较,我发现它不是我的内核。并用gdb调试发现qemu的RIP在0x10 06a7 处死锁

这些是我的make文件、链接器脚本和内核程序我现在不知道如何调试,我会一直等待

OUTPUT_FORMAT("elf64-x86-64")
OUTPUT_ARCH(i386:x86-64)
ENTRY(kmain)
SECTIONS
{
. = 16M;
.text ALIGN(8):
{
*(.mbt2std)
*(.text)
}
.rodata :
{
*(.data)
}
.data :
{
*(.data)
}
.bss :
{
*(.bss)
}
}
.section .mbt2std
tag_start:
.long 0xE85250D6
.long 0
.long tag_end-tag_start
.long -1*(tag_end-tag_start + 0 +  0xE85250D6)
.vbe:
.short 5
.short 0
.long 20
.long 1024
.long 768
.long 32
.vbe_e:
.long 0
.efi:
.short 9
.short 0
.long 12
.long 0x1000000
.efi_e:
.long 0
.short 0
.short 0
.long 8
tag_end:
.long 0xffffffffffffffff
/* Copyright (C) 2020 LithiumOS-Team
This file is part of the Lithium Kernel.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program.  If not, see <https://www.gnu.org/licenses/>.
*/
#include <multiboot.h>
#include <gccm.h>
#include <sys/types.h>
#include <sys/ioport.h>
#include <sys/sysop.h>
#include <sys/video.h>
int kmain()
{
while (1)
;

}

此转储

gdb) x/64x 0x100000
0x100000:   0xe85250d6  0x00000000  0x00000030  0x17adaefa
0x100010:   0x00000005  0x00000014  0x00000400  0x00000300
0x100020:   0x00000020  0x00000000  0x00000000  0x00000008
0x100030:   0xe5894855  0x10ec8348  0xf87d8948  0x458b4890
0x100040:   0xc08348f8  0x00b60f07  0x89c0b60f  0xcab848c7
0x100050:   0x00001005  0xff000000  0x06e8c0d0  0xdd74013c
0x100060:   0x55c3c990  0x48e58948  0x4830ec83  0x48e87d89
0x100070:   0x48e07589  0x48d85589  0xffffffb8  0x00ffffff
0x100080:   0x45394800  0x480c76e0  0xffffc0c7  0x6fe9ffff
0x100090:   0x48000002  0x48e8458b  0xb848c789  0x00100030
0x1000a0:   0x00000000  0x8b48d0ff  0x8348e845  0xb60f01c0
0x1000b0:   0xc0b60f00  0x000000be  0x48c78900  0x100605b8
0x1000c0:   0x00000000  0x48d0ff00  0x48e8458b  0x0f02c083
0x1000d0:   0xb60f00b6  0x0000bec0  0xc7890000  0x0605b848
0x1000e0:   0x00000010  0xd0ff0000  0xe0458b48  0x10e0c148
0x1000f0:   0x28e8c148  0x48d0b60f  0x48e8458b  0x0f03c083
(gdb) x/64x 0x1000000
0x1000000:  0x00000000  0x00000000  0x00000000  0x00000000
0x1000010:  0x00000000  0x00000000  0x00000000  0x00000000
0x1000020:  0x00000000  0x00000000  0x00000000  0x00000000
0x1000030:  0x00000000  0x00000000  0x00000000  0x00000000
0x1000040:  0x00000000  0x00000000  0x00000000  0x00000000
0x1000050:  0x00000000  0x00000000  0x00000000  0x00000000
0x1000060:  0x00000000  0x00000000  0x00000000  0x00000000
0x1000070:  0x00000000  0x00000000  0x00000000  0x00000000
0x1000080:  0x00000000  0x00000000  0x00000000  0x00000000
0x1000090:  0x00000000  0x00000000  0x00000000  0x00000000
0x10000a0:  0x00000000  0x00000000  0x00000000  0x00000000
0x10000b0:  0x00000000  0x00000000  0x00000000  0x00000000
0x10000c0:  0x00000000  0x00000000  0x00000000  0x00000000
0x10000d0:  0x00000000  0x00000000  0x00000000  0x00000000
0x10000e0:  0x00000000  0x00000000  0x00000000  0x00000000
0x10000f0:  0x00000000  0x00000000  0x00000000  0x00000000
alan@alan-virtual-machine:~/git/Lithium-OS/src$ make dmp
objdump -s ../build/lithium.elf
../build/lithium.elf:     文件格式 elf64-x86-64
Contents of section .text:
1000000 d65052e8 00000000 40000000 eaaead17  .PR.....@.......
1000010 05000000 14000000 00040000 00030000  ................
1000020 20000000 00000000 09000000 0c000000   ...............
1000030 00000001 00000000 00000000 08000000  ................
1000040 ffffffff 554889e5 4883ec10 48897df8  ....UH..H...H.}.
1000050 90488b45 f84883c0 070fb600 0fb6c089  .H.E.H..........
1000060 c748b8de 05000100 000000ff d0c0e806  .H..............
1000070 3c0174dd 90c9c355 4889e548 83ec3048  <.t....UH..H..0H
1000080 897de848 8975e048 8955d848 b8ffffff  .}.H.u.H.U.H....
1000090 ffffff00 00483945 e0760c48 c7c0ffff  .....H9E.v.H....
10000a0 ffffe96f 02000048 8b45e848 89c748b8  ...o...H.E.H..H.
10000b0 44000001 00000000 ffd0488b 45e84883  D.........H.E.H.
10000c0 c0010fb6 000fb6c0 be000000 0089c748  ...............H
10000d0 b8190600 01000000 00ffd048 8b45e848  ...........H.E.H
10000e0 83c0020f b6000fb6 c0be0000 000089c7  ................
10000f0 48b81906 00010000 0000ffd0 488b45e0  H...........H.E.
1000100 48c1e010 48c1e828 0fb6d048 8b45e848  H...H..(...H.E.H
1000110 83c0030f b6000fb6 c089d689 c748b819  .............H..
1000120 06000100 000000ff d0488b45 e048c1e0  .........H.E.H..
1000130 0848c1e8 280fb6d0 488b45e8 4883c004  .H..(...H.E.H...
1000140 0fb6000f b6c089d6 89c748b8 19060001  ..........H.....
1000150 00000000 ffd0488b 45e048c1 e8280fb6  ......H.E.H..(..
1000160 d0488b45 e84883c0 050fb600 0fb6c089  .H.E.H..........
1000170 d689c748 b8190600 01000000 00ffd048  ...H...........H
1000180 8b45e848 83c0010f b6000fb6 c0be0000  .E.H............
1000190 000089c7 48b81906 00010000 0000ffd0  ....H...........
10001a0 488b45e8 4883c002 0fb6000f b6c0be01  H.E.H...........
10001b0 00000089 c748b819 06000100 000000ff  .....H..........
10001c0 d0488b45 e00fb6d0 488b45e8 4883c003  .H.E....H.E.H...
10001d0 0fb6000f b6c089d6 89c748b8 19060001  ..........H.....
10001e0 00000000 ffd0488b 45e048c1 e02048c1  ......H.E.H.. H.
10001f0 e8280fb6 d0488b45 e84883c0 040fb600  .(...H.E.H......
1000200 0fb6c089 d689c748 b8190600 01000000  .......H........
1000210 00ffd048 8b45e048 c1e01848 c1e8280f  ...H.E.H...H..(.
1000220 b6d0488b 45e84883 c0050fb6 000fb6c0  ..H.E.H.........
1000230 89d689c7 48b81906 00010000 0000ffd0  ....H...........
1000240 488b45e8 4883c008 0fb6000f b6d0488b  H.E.H.........H.
1000250 45e84883 c0060fb6 000fb6c0 89d689c7  E.H.............
1000260 48b81906 00010000 0000ffd0 488b45e8  H...........H.E.
1000270 4889c748 b8440000 01000000 00ffd048  H..H.D.........H
1000280 8b45e848 83c0070f b6000fb6 c0be2400  .E.H..........$.
1000290 000089c7 48b81906 00010000 0000ffd0  ....H...........
10002a0 488b45e8 4889c748 b8440000 01000000  H.E.H..H.D......
10002b0 00ffd048 8b45d848 8945f8eb 2a488b45  ...H.E.H.E..*H.E
10002c0 e84883c0 010fb600 0fb6c089 c748b8bc  .H...........H..
10002d0 05000100 000000ff d089c248 8b45f866  ...........H.E.f
10002e0 89104883 45f80248 8b45e848 83c0070f  ..H.E..H.E.H....
10002f0 b6000fb6 c089c748 b8de0500 01000000  .......H........
1000300 00ffd00f b6c0c1e0 04c1f807 83f80174  ...............t
1000310 acb80000 0000c9c3 554889e5 4883ec30  ........UH..H..0
1000320 48897de8 488975e0 488955d8 48b8ffff  H.}.H.u.H.U.H...
1000330 ffffffff 00004839 45d8760c 48c7c0ff  ......H9E.v.H...
1000340 ffffffe9 72020000 488b45e8 4889c748  ....r...H.E.H..H
1000350 b8440000 01000000 00ffd048 8b45e848  .D.........H.E.H
1000360 83c0010f b6000fb6 c0be0000 000089c7  ................
1000370 48b81906 00010000 0000ffd0 488b45e8  H...........H.E.
1000380 4883c002 0fb6000f b6c0be00 00000089  H...............
1000390 c748b819 06000100 000000ff d0488b45  .H...........H.E
10003a0 d848c1e0 1048c1e8 280fb6d0 488b45e8  .H...H..(...H.E.
10003b0 4883c003 0fb6000f b6c089d6 89c748b8  H.............H.
10003c0 19060001 00000000 ffd0488b 45d848c1  ..........H.E.H.
10003d0 e00848c1 e8280fb6 d0488b45 e84883c0  ..H..(...H.E.H..
10003e0 040fb600 0fb6c089 d689c748 b8190600  ...........H....
10003f0 01000000 00ffd048 8b45d848 c1e8280f  .......H.E.H..(.
1000400 b6d0488b 45e84883 c0050fb6 000fb6c0  ..H.E.H.........
1000410 89d689c7 48b81906 00010000 0000ffd0  ....H...........
1000420 488b45e8 4883c001 0fb6000f b6c0be00  H.E.H...........
1000430 00000089 c748b819 06000100 000000ff  .....H..........
1000440 d0488b45 e84883c0 020fb600 0fb6c0be  .H.E.H..........
1000450 01000000 89c748b8 19060001 00000000  ......H.........
1000460 ffd0488b 45d80fb6 d0488b45 e84883c0  ..H.E....H.E.H..
1000470 030fb600 0fb6c089 d689c748 b8190600  ...........H....
1000480 01000000 00ffd048 8b45d848 c1e02048  .......H.E.H.. H
1000490 c1e8280f b6d0488b 45e84883 c0040fb6  ..(...H.E.H.....
10004a0 000fb6c0 89d689c7 48b81906 00010000  ........H.......
10004b0 0000ffd0 488b45d8 48c1e018 48c1e828  ....H.E.H...H..(
10004c0 0fb6d048 8b45e848 83c0050f b6000fb6  ...H.E.H........
10004d0 c089d689 c748b819 06000100 000000ff  .....H..........
10004e0 d0488b45 e84883c0 080fb600 0fb6d048  .H.E.H.........H
10004f0 8b45e848 83c0060f b6000fb6 c089d689  .E.H............
1000500 c748b819 06000100 000000ff d0488b45  .H...........H.E
1000510 e84889c7 48b84400 00010000 0000ffd0  .H..H.D.........
1000520 488b45e8 4883c007 0fb6000f b6c0be34  H.E.H..........4
1000530 00000089 c748b819 06000100 000000ff  .....H..........
1000540 d0488b45 e84889c7 48b84400 00010000  .H.E.H..H.D.....
1000550 0000ffd0 488b45e0 488945f8 eb2d488b  ....H.E.H.E..-H.
1000560 45f80fb7 000fb7d0 488b45e8 4883c001  E.......H.E.H...
1000570 0fb6000f b6c089d6 89c748b8 fc050001  ..........H.....
1000580 00000000 ffd04883 45f80248 8b45e848  ......H.E..H.E.H
1000590 83c0070f b6000fb6 c089c748 b8de0500  ...........H....
10005a0 01000000 00ffd00f b6c0c1e0 04c1f807  ................
10005b0 83f80174 a9b80000 0000c9c3 554889e5  ...t........UH..
10005c0 89f86689 45ec66c7 45fe0000 0fb745ec  ..f.E.f.E.....E.
10005d0 89c266ed 668945fe 0fb745fe 5dc35548  ..f.f.E...E.].UH
10005e0 89e589f8 668945ec c645ff00 0fb745ec  ....f.E..E....E.
10005f0 89c2ec88 45ff0fb6 45ff5dc3 554889e5  ....E...E.].UH..
1000600 89fa89f0 668955fc 668945f8 0fb755fc  ....f.U.f.E...U.
1000610 0fb745f8 66ef905d c3554889 e589fa89  ..E.f..].UH.....
1000620 f0668955 fc8845f8 0fb755fc 0fb645f8  .f.U..E...U...E.
1000630 ee905dc3 554889e5 ebfe5548 89e59048  ..].UH....UH...H
1000640 8945f848 8b45f85d c3554889 e5539048  .E.H.E.].UH..S.H
1000650 89d84889 45f0488b 45f05b5d c3554889  ..H.E.H.E.[].UH.
1000660 e5904889 c8488945 f8488b45 f85dc355  ..H..H.E.H.E.].U
1000670 4889e590 4889d048 8945f848 8b45f85d  H...H..H.E.H.E.]
1000680 c3554889 e5904889 f0488945 f8488b45  .UH...H..H.E.H.E
1000690 f85dc355 4889e590 4889f848 8945f848  .].UH...H..H.E.H
10006a0 8b45f85d c3554889 e548897d f8488b45  .E.].UH..H.}.H.E
10006b0 f890905d c3554889 e5534889 7df0488b  ...].UH..SH.}.H.
10006c0 45f04889 c390905b 5dc35548 89e54889  E.H....[].UH..H.
10006d0 7df8488b 45f84889 c190905d c3554889  }.H.E.H....].UH.
10006e0 e548897d f8488b45 f84889c2 90905dc3  .H.}.H.E.H....].
10006f0 554889e5 48897df8 488b45f8 4889c690  UH..H.}.H.E.H...
1000700 905dc355 4889e548 897df848 8b45f848  .].UH..H.}.H.E.H
1000710 89c79090 5dc35548 89e5f490 5dc35548  ....].UH....].UH
1000720 89e548b8 600e0001 00000000 488b4020  ..H.`.......H.@ 
1000730 4883f806 740c48c7 c0ffff00 ffe92d01  H...t.H.......-.
1000740 000048b8 600e0001 00000000 488b0048  ..H.`.......H..H
1000750 8945f848 c745f000 000000eb 4c48c745  .E.H.E......LH.E
1000760 e8000000 00eb2948 8b45f8c6 00ff488b  ......)H.E....H.
1000770 45f8c640 0100488b 45f8c640 0200488b  E..@..H.E..@..H.
1000780 45f8c640 03004883 45f80448 8345e801  E..@..H.E..H.E..
1000790 48b8600e 00010000 0000488b 4008483b  H.`.......H.@.H;
10007a0 45e877c3 488345f0 0148837d f01876ad  E.w.H.E..H.}..v.
10007b0 48c745e0 00000000 eb4c48c7 45d80000  H.E......LH.E...
10007c0 0000eb29 488b45f8 c6000048 8b45f8c6  ...)H.E....H.E..
10007d0 4001ff48 8b45f8c6 40020048 8b45f8c6  @..H.E..@..H.E..
10007e0 40030048 8345f804 488345d8 0148b860  @..H.E..H.E..H.`
10007f0 0e000100 00000048 8b400848 3b45d877  .......H.@.H;E.w
1000800 c3488345 e0014883 7de01876 ad48c745  .H.E..H.}..v.H.E
1000810 d0000000 00eb4c48 c745c800 000000eb  ......LH.E......
1000820 29488b45 f8c60000 488b45f8 c6400100  )H.E....H.E..@..
1000830 488b45f8 c64002ff 488b45f8 c6400300  H.E..@..H.E..@..
1000840 488345f8 04488345 c80148b8 600e0001  H.E..H.E..H.`...
1000850 00000000 488b4008 483b45c8 77c34883  ....H.@.H;E.w.H.
1000860 45d00148 837dd018 76adb800 0000005d  E..H.}..v......]
1000870 c3554889 e548897d f8488975 f0488b45  .UH..H.}.H.u.H.E
1000880 f80fb600 3c56753a 488b45f8 4883c001  ....<Vu:H.E.H...
1000890 0fb6003c 45752b48 8b45f848 83c0020f  ...<Eu+H.E.H....
10008a0 b6003c53 751c488b 45f84883 c0030fb6  ..<Su.H.E.H.....
10008b0 003c4175 0d488b45 f04883c0 50488b00  .<Au.H.E.H..PH..
10008c0 eb05b800 0000005d c3554889 e548897d  .......].UH..H.}
10008d0 f8488975 f0488b45 f80fb600 3c56753d  .H.u.H.E....<Vu=
10008e0 488b45f8 4883c001 0fb6003c 45752e48  H.E.H......<Eu.H
10008f0 8b45f848 83c0020f b6003c53 751f488b  .E.H......<Su.H.
1000900 45f84883 c0030fb6 003c4175 10488b45  E.H......<Au.H.E
1000910 f04883c0 120fb700 0fb7c0eb 05b80000  .H..............
1000920 00005dc3 554889e5 48897df8 488975f0  ..].UH..H.}.H.u.
1000930 488b45f8 0fb6003c 56753d48 8b45f848  H.E....<Vu=H.E.H
1000940 83c0010f b6003c45 752e488b 45f84883  ......<Eu.H.E.H.
1000950 c0020fb6 003c5375 1f488b45 f84883c0  .....<Su.H.E.H..
1000960 030fb600 3c417510 488b45f0 4883c014  ....<Au.H.E.H...
1000970 0fb7000f b7c0eb05 b8000000 005dc355  .............].U
1000980 4889e548 897df848 8975f048 8b45f80f  H..H.}.H.u.H.E..
1000990 b6003c56 753e488b 45f84883 c0010fb6  ..<Vu>H.E.H.....
10009a0 003c4575 2f488b45 f84883c0 020fb600  .<Eu/H.E.H......
10009b0 3c537520 488b45f8 4883c003 0fb6003c  <Su H.E.H......<
10009c0 41751148 8b45f048 83c0190f b600480f  Au.H.E.H......H.
10009d0 bec0eb05 b8000000 005dc355 4889e548  .........].UH..H
10009e0 83ec1048 897df848 8975f048 8b55f048  ...H.}.H.u.H.U.H
10009f0 8b45f848 89d64889 c748b871 08000100  .E.H..H..H.q....
1000a00 000000ff d04889c2 48b8600e 00010000  .....H..H.`.....
1000a10 00004889 10488b55 f0488b45 f84889d6  ..H..H.U.H.E.H..
1000a20 4889c748 b8c90800 01000000 00ffd048  H..H...........H
1000a30 89c248b8 600e0001 00000000 48895008  ..H.`.......H.P.
1000a40 488b55f0 488b45f8 4889d648 89c748b8  H.U.H.E.H..H..H.
1000a50 24090001 00000000 ffd04889 c248b860  $.........H..H.`
1000a60 0e000100 00000048 89501048 8b55f048  .......H.P.H.U.H
1000a70 8b45f848 89d64889 c748b87f 09000100  .E.H..H..H......
1000a80 000000ff d04889c2 48b8600e 00010000  .....H..H.`.....
1000a90 00004889 10488b45 f84883c0 1b0fb600  ..H..H.E.H......
1000aa0 480fbed0 48b8600e 00010000 00004889  H...H.`.......H.
1000ab0 5020b800 000000c9 c3                 P .......       
Contents of section .rodata:
1000ac0 f001f101 f201f301 f401f501 f601f701  ................
1000ad0 1000  

1.尝试将OUTPUT_FORMAT更改为elf32-i3862.将qemu内存限制更改为更高3.在进入长模式之前,不要使用x64代码

相关内容

  • 没有找到相关文章