我已经在Linux内核4.14.41中添加了c++支持(libsupc++库),并成功编译了内核。内核以32位配置启动,但对于64位配置,黑屏将停止,并出现以下错误:

early console in extract_kernel
input data: 0x0000000002123276
input_len: 0x00000000000778406
output: 0x0000000001000000
output_len: 0x000000000178b368
kernel_total_size: 0x00000000018ca000
booted via startup_32()
Physical KASLR using RDTSC...
Virtual KASLR using RDTSC...

Decompressing Linux... Parsing ELF...

Alignment of LOAD segment isn't a multiple of 2MB

--System halted

谷歌搜索错误,但找不到太多帮助。我认为问题出在启动程序上。64位配置是否有启动程序?错误的可能原因是什么,或者如何调试这样的错误?
readelf-l vmlinux:
Elf file type is EXEC (Executable file)
Entry point 0x1000000
There are 5 program headers, starting at offset 64

Program Headers:
  Type           Offset             VirtAddr           PhysAddr
                 FileSiz            MemSiz              Flags  Align
  LOAD           0x0000000000001000 0xffffffff81000000 0x0000000001000000
                 0x00000000010f2000 0x00000000010f2000  R E    1000
  LOAD           0x00000000010f4000 0xffffffff82200000 0x0000000002200000
                 0x00000000004a4000 0x00000000004a4000  RW     2000
  LOAD           0x0000000001598000 0x0000000000000000 0x00000000026a4000
                 0x0000000000021998 0x0000000000021998  RW     1000
  LOAD           0x00000000015ba000 0xffffffff826c6000 0x00000000026c6000
                 0x0000000000121000 0x0000000000204000  RWE    2000
  NOTE           0x0000000000c0423c 0xffffffff81c0323c 0x0000000001c0323c
                 0x0000000000000024 0x0000000000000024         4

 Section to Segment mapping:
  Segment Sections...
   00     .text .discard.text .text._Z6abort3v .text._ZNK10__cxxabiv117__pbase_type_info15__pointer_catchEPKS0_PPvj .notes __ex_table .rodata .eh_frame .gcc_except_table .pci_fixup .tracedata __ksymtab __ksymtab_gpl __ksymtab_strings __param __modver
   01     .data .exitcall.exit .discard.func_stack_frame_non_standard .jcr __bug_table .orc_unwind_ip .orc_unwind .orc_lookup .vvar
   02     .data..percpu
   03     .init.text .init.data .x86_cpu_dev.init .altinstructions .altinstr_replacement .iommu_table .apicdrivers .exit.text .exit.data .smp_locks .data_nosave .bss .brk
   04     .notes

readelf-S vmlinux:
There are 97 section headers, starting at offset 0x2c1d430:

Section Headers:
  [Nr] Name              Type             Address           Offset
       Size              EntSize          Flags  Link  Info  Align
  [ 0]                   NULL             0000000000000000  00000000
       0000000000000000  0000000000000000           0     0     0
  [ 1] .text             PROGBITS         ffffffff81000000  00001000
       0000000000c031d1  0000000000000000  AX       0     0     4096
  [ 2] .rela.text        RELA             0000000000000000  01b52460
       000000000053c8f8  0000000000000018   I      95     1     8
  [ 3] .discard.text     PROGBITS         ffffffff81c031e0  00c041e0
       0000000000000011  0000000000000000  AX       0     0     16
  [ 4] .text._Z6abort3v  PROGBITS         ffffffff81c03200  00c04200
       0000000000000016  0000000000000000  AX       0     0     16
  [ 5] .rela.text._Z6abo RELA             0000000000000000  0208ed58
       0000000000000030  0000000000000018   I      95     4     8
  [ 6] .text._ZNK10__cxx PROGBITS         ffffffff81c03220  00c04220
       000000000000001c  0000000000000000  AX       0     0     16
  [ 7] .notes            NOTE             ffffffff81c0323c  00c0423c
       0000000000000024  0000000000000000   A       0     0     4
  [ 8] __ex_table        PROGBITS         ffffffff81c03260  00c04260
       0000000000006f60  0000000000000000   A       0     0     4
  [ 9] .rela__ex_table   RELA             0000000000000000  0208ed88
       0000000000029c40  0000000000000018   I      95     8     8
  [10] .rodata           PROGBITS         ffffffff81e00000  00e01000
       0000000000290c32  0000000000000000  WA       0     0     4096
  [11] .rela.rodata      RELA             0000000000000000  020b89c8
       00000000000dd6e8  0000000000000018   I      95    10     8
  [12] .eh_frame         PROGBITS         ffffffff82090c38  01091c38
       0000000000001578  0000000000000000  WA       0     0     8
  [13] .rela.eh_frame    RELA             0000000000000000  021960b0
       00000000000014a0  0000000000000018   I      95    12     8
  [14] .gcc_except_table PROGBITS         ffffffff820921b0  010931b0
       0000000000000268  0000000000000000   A       0     0     8
  [15] .rela.gcc_except_ RELA             0000000000000000  02197550
       0000000000000048  0000000000000018   I      95    14     8
  [16] .pci_fixup        PROGBITS         ffffffff82092418  01093418
       0000000000003ba0  0000000000000000   A       0     0     8
  [17] .rela.pci_fixup   RELA             0000000000000000  02197598
       0000000000003ba0  0000000000000018   I      95    16     8
  [18] .tracedata        PROGBITS         ffffffff82095fb8  01096fb8
       0000000000000078  0000000000000000   A       0     0     1
  [19] .rela.tracedata   RELA             0000000000000000  0219b138
       0000000000000120  0000000000000018   I      95    18     8
  [20] __ksymtab         PROGBITS         ffffffff82096030  01097030
       0000000000015940  0000000000000000   A       0     0     16
  [21] .rela__ksymtab    RELA             0000000000000000  0219b258
       0000000000040bc0  0000000000000018   I      95    20     8
  [22] __ksymtab_gpl     PROGBITS         ffffffff820ab970  010ac970
       0000000000011240  0000000000000000   A       0     0     16
  [23] .rela__ksymtab_gp RELA             0000000000000000  021dbe18
       00000000000336c0  0000000000000018   I      95    22     8
  [24] __ksymtab_strings PROGBITS         ffffffff820bcbb0  010bdbb0
       000000000002fd25  0000000000000000   A       0     0     1
  [25] __param           PROGBITS         ffffffff820ec8d8  010ed8d8
       0000000000004808  0000000000000000   A       0     0     8
  [26] .rela__param      RELA             0000000000000000  0220f4d8
       0000000000008118  0000000000000018   I      95    25     8
  [27] __modver          PROGBITS         ffffffff820f10e0  010f20e0
       0000000000000f20  0000000000000000   A       0     0     8
  [28] .rela__modver     RELA             0000000000000000  022175f0
       00000000000001c8  0000000000000018   I      95    27     8
  [29] .data             PROGBITS         ffffffff82200000  010f4000
       000000000013c800  0000000000000000  WA       0     0     8192
  [30] .rela.data        RELA             0000000000000000  022177b8
       00000000000a7688  0000000000000018   I      95    29     8
  [31] .exitcall.exit    PROGBITS         ffffffff8233c800  01230800
       0000000000000b38  0000000000000000  WA       0     0     8
  [32] .rela.exitcall.ex RELA             0000000000000000  022bee40
       00000000000021a8  0000000000000018   I      95    31     8
  [33] .discard.func_sta PROGBITS         ffffffff8233d338  01231338
       0000000000000028  0000000000000000  WA       0     0     8
  [34] .rela.discard.fun RELA             0000000000000000  022c0fe8
       0000000000000078  0000000000000018   I      95    33     8
  [35] .jcr              PROGBITS         ffffffff8233d360  01231360
       0000000000000000  0000000000000000  WA       0     0     8
  [36] __bug_table       PROGBITS         ffffffff8233d360  01231360
       0000000000015f60  0000000000000000  WA       0     0     1
  [37] .rela__bug_table  RELA             0000000000000000  022c1060
       0000000000057d80  0000000000000018   I      95    36     8
  [38] .orc_unwind_ip    PROGBITS         ffffffff823532c0  012472c0
       000000000013f9b4  0000000000000000   A       0     0     1
  [39] .rela.orc_unwind_ RELA             0000000000000000  02318de0
       000000000077da38  0000000000000018   I      95    38     8
  [40] .orc_unwind       PROGBITS         ffffffff82492c74  01386c74
       00000000001df68e  0000000000000000   A       0     0     1
  [41] .orc_lookup       NOBITS           ffffffff82672304  01566302
       00000000000300cc  0000000000000000  WA       0     0     1
  [42] .vvar             PROGBITS         ffffffff826a3000  01597000
       0000000000001000  0000000000000000  WA       0     0     16
  [43] .data..percpu     PROGBITS         0000000000000000  01598000
       0000000000021998  0000000000000000  WA       0     0     4096
  [44] .rela.data..percp RELA             0000000000000000  02a96818
       00000000000000f0  0000000000000018   I      95    43     8
  [45] .init.text        PROGBITS         ffffffff826c6000  015ba000
       000000000007845e  0000000000000000  AX       0     0     16
  [46] .rela.init.text   RELA             0000000000000000  02a96908
       00000000000b89c8  0000000000000018   I      95    45     8
  [47] .init.data        PROGBITS         ffffffff82740000  01634000
       0000000000093288  0000000000000000  WA       0     0     8192
  [48] .rela.init.data   RELA             0000000000000000  02b4f2d0
       000000000001a4c0  0000000000000018   I      95    47     8
  [49] .x86_cpu_dev.init PROGBITS         ffffffff827d3288  016c7288
       0000000000000018  0000000000000000   A       0     0     8
  [50] .rela.x86_cpu_dev RELA             0000000000000000  02b69790
       0000000000000048  0000000000000018   I      95    49     8
  [51] .altinstructions  PROGBITS         ffffffff827d32a0  016c72a0
       00000000000053e4  0000000000000000   A       0     0     1
  [52] .rela.altinstruct RELA             0000000000000000  02b697d8
       00000000000135c0  0000000000000018   I      95    51     8
  [53] .altinstr_replace PROGBITS         ffffffff827d8684  016cc684
       0000000000001a05  0000000000000000  AX       0     0     1
  [54] .rela.altinstr_re RELA             0000000000000000  02b7cd98
       0000000000001890  0000000000000018   I      95    53     8
  [55] .iommu_table      PROGBITS         ffffffff827da090  016ce090
       00000000000000c8  0000000000000000   A       0     0     8
  [56] .rela.iommu_table RELA             0000000000000000  02b7e628
       0000000000000150  0000000000000018   I      95    55     8
  [57] .apicdrivers      PROGBITS         ffffffff827da158  016ce158
       0000000000000010  0000000000000000  WA       0     0     8
  [58] .rela.apicdrivers RELA             0000000000000000  02b7e778
       0000000000000030  0000000000000018   I      95    57     8
  [59] .exit.text        PROGBITS         ffffffff827da168  016ce168
       0000000000002888  0000000000000000  AX       0     0     1
  [60] .rela.exit.text   RELA             0000000000000000  02b7e7a8
       00000000000072a8  0000000000000018   I      95    59     8
  [61] .exit.data        PROGBITS         ffffffff827dc9f0  016d09f0
       0000000000000010  0000000000000000  WA       0     0     8
  [62] .smp_locks        PROGBITS         ffffffff827dd000  016d1000
       0000000000009000  0000000000000000   A       0     0     4
  [63] .rela.smp_locks   RELA             0000000000000000  02b85a50
       00000000000324a8  0000000000000018   I      95    62     8
  [64] .data_nosave      PROGBITS         ffffffff827e6000  016da000
       0000000000001000  0000000000000000  WA       0     0     4
  [65] .bss              NOBITS           ffffffff827e7000  016db000
       00000000000b7000  0000000000000000  WA       0     0     4096
  [66] .brk              NOBITS           ffffffff8289e000  016db000
       000000000002c000  0000000000000000  WA       0     0     1
  [67] .comment          PROGBITS         0000000000000000  016db000
       0000000000000011  0000000000000001  MS       0     0     1
  [68] .discard.unwind_h PROGBITS         0000000000000000  016db011
       0000000000000d18  0000000000000000           0     0     1
  [69] .rela.discard.unw RELA             0000000000000000  02bb7ef8
       0000000000002748  0000000000000018   I      95    68     8
  [70] .discard.retpolin PROGBITS         0000000000000000  016dbd29
       0000000000000118  0000000000000000           0     0     1
  [71] .rela.discard.ret RELA             0000000000000000  02bba640
       0000000000000348  0000000000000018   I      95    70     8
  [72] .discard.reachabl PROGBITS         0000000000000000  016dbe41
       000000000000752c  0000000000000000           0     0     1
  [73] .rela.discard.rea RELA             0000000000000000  02bba988
       000000000002bf08  0000000000000018   I      95    72     8
  [74] .discard.nospec   PROGBITS         0000000000000000  016e336d
       0000000000000048  0000000000000000           0     0     1
  [75] .rela.discard.nos RELA             0000000000000000  02be6890
       00000000000001b0  0000000000000018   I      95    74     8
  [76] .discard.unreacha PROGBITS         0000000000000000  016e33b5
       0000000000001368  0000000000000000           0     0     1
  [77] .rela.discard.unr RELA             0000000000000000  02be6a40
       0000000000007470  0000000000000018   I      95    76     8
  [78] .debug_aranges    PROGBITS         0000000000000000  016e471d
       0000000000000490  0000000000000000           0     0     1
  [79] .rela.debug_arang RELA             0000000000000000  02bedeb0
       0000000000000498  0000000000000018   I      95    78     8
  [80] .debug_pubnames   PROGBITS         0000000000000000  016e4bad
       000000000000159b  0000000000000000           0     0     1
  [81] .rela.debug_pubna RELA             0000000000000000  02bee348
       0000000000000258  0000000000000018   I      95    80     8
  [82] .debug_info       PROGBITS         0000000000000000  016e6148
       000000000001e582  0000000000000000           0     0     1
  [83] .rela.debug_info  RELA             0000000000000000  02bee5a0
       000000000002c958  0000000000000018   I      95    82     8
  [84] .debug_abbrev     PROGBITS         0000000000000000  017046ca
       0000000000003b4f  0000000000000000           0     0     1
  [85] .debug_line       PROGBITS         0000000000000000  01708219
       0000000000004109  0000000000000000           0     0     1
  [86] .rela.debug_line  RELA             0000000000000000  02c1aef8
       0000000000000258  0000000000000018   I      95    85     8
  [87] .debug_frame      PROGBITS         0000000000000000  0170c328
       0000000000000180  0000000000000000           0     0     8
  [88] .rela.debug_frame RELA             0000000000000000  02c1b150
       00000000000002d0  0000000000000018   I      95    87     8
  [89] .debug_str        PROGBITS         0000000000000000  0170c4a8
       0000000000004c1a  0000000000000001  MS       0     0     1
  [90] .debug_loc        PROGBITS         0000000000000000  017110c2
       0000000000006fab  0000000000000000           0     0     1
  [91] .rela.debug_loc   RELA             0000000000000000  02c1b420
       00000000000016e0  0000000000000018   I      95    90     8
  [92] .debug_ranges     PROGBITS         0000000000000000  0171806d
       0000000000001970  0000000000000000           0     0     1
  [93] .rela.debug_range RELA             0000000000000000  02c1cb00
       0000000000000930  0000000000000018   I      95    92     8
  [94] .shstrtab         STRTAB           0000000000000000  017199dd
       00000000000003dd  0000000000000000           0     0     1
  [95] .symtab           SYMTAB           0000000000000000  01719dc0
       0000000000230f28  0000000000000018          96   71830     8
  [96] .strtab           STRTAB           0000000000000000  0194ace8
       0000000000207772  0000000000000000           0     0     1
Key to Flags:
  W (write), A (alloc), X (execute), M (merge), S (strings), l (large)
  I (info), L (link order), G (group), T (TLS), E (exclude), x (unknown)
  O (extra OS processing required) o (OS specific), p (processor specific)

最佳答案

失调是因为我传递给链接器的错误标志。实际上ld选项被传递到源树的-z max-page-size=0x200000中的链接器,以强制链接使用2MB的页面大小。但在顶层,我将链接器用作nodefaultlibsarch/x86/MakefilenostartfilesMakefile

关于linux - LOAD段的对齐不是2MB的倍数,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/50978426/

10-11 09:31