I've read numerous amounts of the other questions related to the issue, none of them have resolved my issue.
For extra code see the repo.
I'm contributing to a relatively mildly developed operating system, it has IDT, GDT, paging, VGA driver, etc. We use GRUB for our bootloader, however. I was recently assigned to the task of actually fixing a critical bug (see title), and I've been working on it for weeks with no luck. Here is my boot ASM (GNU ASM) and linkerscript, respectively.
# Multiboot header constants
.set ALIGN, 1<<0 # load modules on page boundaries
.set MEMINFO, 1<<1 # memory map
.set FLAGS, ALIGN | MEMINFO # multiboot flags
.set MAGIC, 0x1BADB002 # magic number
.set CHECKSUM, -(MAGIC + FLAGS) # header checksum
# Multiboot Header
.section .multiboot
.align 4
.long MAGIC
.long FLAGS
.long CHECKSUM
# Memory for initial thread
.section .bss
.align 16
stack_bottom:
.skip 16384 # 16 kib
stack_top:
/* the linker script specifies _start as the entry
point for the kernel */
.section .text
.global _start
.type _start, @function
_start:
/* stack */
mov $stack_top, %esp
cli
call loadGDT
mov %cr0, %eax
or 1, %al
mov %eax, %cr0
call loadIDT
sti
jmp $0x8, $protectedModeMain
protectedModeMain:
/* here we call kernel_main */
call kernel_main
/* if the system has nothing else to do, put the pc
into an infinite loop */
1: hlt
jmp 1b
;
;/* set thie size of the _start symbol to the current location */
;.size _start, . - _start
;
ENTRY(_start)
SECTIONS
{
VGA_POINTER = 0xb8000;
. = 0xb8000;
. += 80 * 25 * 2;
. = 1M;
.text ALIGN(4K) :
{
*(.multiboot)
*(.text .text.*)
. = ALIGN(4K);
}
.rodata :
{
*(.rodata .rodata.*)
. = ALIGN(4K);
}
.data :
{
*(.data.rel.ro.local*) *(.data.rel.ro .data.rel.ro.*) *(.data.*)
. = ALIGN(4K);
}
.gdt :
{
*(.gdt)
. = ALIGN(4K);
}
.bss :
{
*(.bss .bss.*);
. = ALIGN(4K);
}
}
For a few more details refer to this issue on the GitHub repo.
EDIT: output of objdump:
NovaVita.kernel: file format elf32-i386
NovaVita.kernel
architecture: i386, flags 0x00000150:
HAS_SYMS, DYNAMIC, D_PAGED
start address 0x00001278
Program Header:
PHDR off 0x00000034 vaddr 0x00000034 paddr 0x00000034 align 2**2
filesz 0x00000160 memsz 0x00000160 flags r--
INTERP off 0x00000194 vaddr 0x00000194 paddr 0x00000194 align 2**0
filesz 0x00000013 memsz 0x00000013 flags r--
LOAD off 0x00000000 vaddr 0x00000000 paddr 0x00000000 align 2**12
filesz 0x000003b8 memsz 0x000003b8 flags r--
LOAD off 0x00001000 vaddr 0x00001000 paddr 0x00001000 align 2**12
filesz 0x00002000 memsz 0x00002000 flags r-x
LOAD off 0x00003000 vaddr 0x00003000 paddr 0x00003000 align 2**12
filesz 0x0000115c memsz 0x0000115c flags r--
LOAD off 0x00004edc vaddr 0x00005edc paddr 0x00005edc align 2**12
filesz 0x00001124 memsz 0x00009124 flags rw-
DYNAMIC off 0x00004edc vaddr 0x00005edc paddr 0x00005edc align 2**2
filesz 0x00000088 memsz 0x00000088 flags rw-
NOTE off 0x000001a8 vaddr 0x000001a8 paddr 0x000001a8 align 2**2
filesz 0x00000024 memsz 0x00000024 flags r--
EH_FRAME off 0x00004000 vaddr 0x00004000 paddr 0x00004000 align 2**2
filesz 0x00000044 memsz 0x00000044 flags r--
STACK off 0x00000000 vaddr 0x00000000 paddr 0x00000000 align 2**4
filesz 0x00000000 memsz 0x00000000 flags rwx
RELRO off 0x00004edc vaddr 0x00005edc paddr 0x00005edc align 2**0
filesz 0x00000124 memsz 0x00000124 flags r--
Dynamic Section:
GNU_HASH 0x000001cc
STRTAB 0x000001f4
SYMTAB 0x000001e4
STRSZ 0x00000001
SYMENT 0x00000010
DEBUG 0x00000000
REL 0x000001f8
RELSZ 0x000001c0
RELENT 0x00000008
TEXTREL 0x00000000
FLAGS_1 0x08000000
RELCOUNT 0x00000038
Sections:
Idx Name Size VMA LMA File off Algn
0 .interp 00000013 00000194 00000194 00000194 2**0
CONTENTS, ALLOC, LOAD, READONLY, DATA
1 .note.gnu.build-id 00000024 000001a8 000001a8 000001a8 2**2
CONTENTS, ALLOC, LOAD, READONLY, DATA
2 .gnu.hash 00000018 000001cc 000001cc 000001cc 2**2
CONTENTS, ALLOC, LOAD, READONLY, DATA
3 .dynsym 00000010 000001e4 000001e4 000001e4 2**2
CONTENTS, ALLOC, LOAD, READONLY, DATA
4 .dynstr 00000001 000001f4 000001f4 000001f4 2**0
CONTENTS, ALLOC, LOAD, READONLY, DATA
5 .rel.dyn 000001c0 000001f8 000001f8 000001f8 2**2
CONTENTS, ALLOC, LOAD, READONLY, DATA
6 .text 00002000 00001000 00001000 00001000 2**4
CONTENTS, ALLOC, LOAD, READONLY, CODE
7 .rodata 00001000 00003000 00003000 00003000 2**2
CONTENTS, ALLOC, LOAD, READONLY, DATA
8 .eh_frame_hdr 00000044 00004000 00004000 00004000 2**2
CONTENTS, ALLOC, LOAD, READONLY, DATA
9 .eh_frame 00000118 00004044 00004044 00004044 2**2
CONTENTS, ALLOC, LOAD, READONLY, DATA
10 .dynamic 00000088 00005edc 00005edc 00004edc 2**2
CONTENTS, ALLOC, LOAD, DATA
11 .got 0000009c 00005f64 00005f64 00004f64 2**2
CONTENTS, ALLOC, LOAD, DATA
12 .got.plt 0000000c 00006000 00006000 00005000 2**2
CONTENTS, ALLOC, LOAD, DATA
13 .data 00000ff4 0000600c 0000600c 0000500c 2**2
CONTENTS, ALLOC, LOAD, DATA
14 .bss 00008000 00007000 00007000 00006000 2**12
ALLOC
15 .comment 00000016 00000000 00000000 00006000 2**0
CONTENTS, READONLY
16 .debug_aranges 00000020 00000000 00000000 00006016 2**0
CONTENTS, READONLY, DEBUGGING, OCTETS
17 .debug_info 00002032 00000000 00000000 00006036 2**0
CONTENTS, READONLY, DEBUGGING, OCTETS
18 .debug_abbrev 0000076c 00000000 00000000 00008068 2**0
CONTENTS, READONLY, DEBUGGING, OCTETS
19 .debug_line 00000bbd 00000000 00000000 000087d4 2**0
CONTENTS, READONLY, DEBUGGING, OCTETS
20 .debug_frame 000001b4 00000000 00000000 00009394 2**2
CONTENTS, READONLY, DEBUGGING, OCTETS
21 .debug_str 000007f3 00000000 00000000 00009548 2**0
CONTENTS, READONLY, DEBUGGING, OCTETS
22 .debug_loc 0000182d 00000000 00000000 00009d3b 2**0
CONTENTS, READONLY, DEBUGGING, OCTETS
23 .debug_ranges 00000100 00000000 00000000 0000b568 2**0
CONTENTS, READONLY, DEBUGGING, OCTETS
24 .gdt 00000000 00100000 00100000 0000b668 2**0
CONTENTS
SYMBOL TABLE:
00000194 l d .interp 00000000 .interp
000001a8 l d .note.gnu.build-id 00000000 .note.gnu.build-id
000001cc l d .gnu.hash 00000000 .gnu.hash
000001e4 l d .dynsym 00000000 .dynsym
000001f4 l d .dynstr 00000000 .dynstr
000001f8 l d .rel.dyn 00000000 .rel.dyn
00001000 l d .text 00000000 .text
00003000 l d .rodata 00000000 .rodata
00004000 l d .eh_frame_hdr 00000000 .eh_frame_hdr
00004044 l d .eh_frame 00000000 .eh_frame
00005edc l d .dynamic 00000000 .dynamic
00005f64 l d .got 00000000 .got
00006000 l d .got.plt 00000000 .got.plt
0000600c l d .data 00000000 .data
00007000 l d .bss 00000000 .bss
00000000 l d .comment 00000000 .comment
00000000 l d .debug_aranges 00000000 .debug_aranges
00000000 l d .debug_info 00000000 .debug_info
00000000 l d .debug_abbrev 00000000 .debug_abbrev
00000000 l d .debug_line 00000000 .debug_line
00000000 l d .debug_frame 00000000 .debug_frame
00000000 l d .debug_str 00000000 .debug_str
00000000 l d .debug_loc 00000000 .debug_loc
00000000 l d .debug_ranges 00000000 .debug_ranges
00100000 l d .gdt 00000000 .gdt
00000000 l df *ABS* 00000000 Kernel.cpp
00000000 l .debug_str 00000000
00000016 l .debug_str 00000000
00000033 l .debug_str 00000000
00000130 l .debug_str 00000000
00000482 l .debug_str 00000000
00000053 l .debug_str 00000000
0000006c l .debug_str 00000000
00000085 l .debug_str 00000000
0000008f l .debug_str 00000000
0000009c l .debug_str 00000000
000000a3 l .debug_str 00000000
000000ae l .debug_str 00000000
000000b2 l .debug_str 00000000
000000b9 l .debug_str 00000000
000000c0 l .debug_str 00000000
000000cf l .debug_str 00000000
000000d8 l .debug_str 00000000
000000e1 l .debug_str 00000000
000000e8 l .debug_str 00000000
000000ed l .debug_str 00000000
000000f1 l .debug_str 00000000
000000fa l .debug_str 00000000
0000011a l .debug_str 00000000
00000127 l .debug_str 00000000
00000135 l .debug_str 00000000
0000013d l .debug_str 00000000
00000156 l .debug_str 00000000
0000015f l .debug_str 00000000
00000177 l .debug_str 00000000
0000017d l .debug_str 00000000
00000194 l .debug_str 00000000
00000098 l .debug_str 00000000
000001a9 l .debug_str 00000000
000001c2 l .debug_str 00000000
000001ca l .debug_str 00000000
000001df l .debug_str 00000000
000001e5 l .debug_str 00000000
000001f6 l .debug_str 00000000
0000021b l .debug_str 00000000
00000227 l .debug_str 00000000
0000022c l .debug_str 00000000
00000234 l .debug_str 00000000
0000023b l .debug_str 00000000
00000248 l .debug_str 00000000
0000024d l .debug_str 00000000
00000252 l .debug_str 00000000
0000025e l .debug_str 00000000
00000000 l df *ABS* 00000000 ../NovaCor/HardwareAbstractionLayer/Architectures/i686/GDT.asm
000010fc l .text 00000000 flushGDT.flush
00000000 l df *ABS* 00000000 ../NovaCor/HardwareAbstractionLayer/Architectures/i686/IDT.asm
00000000 l df *ABS* 00000000 ../NovaCor/HardwareAbstractionLayer/Architectures/i686/ISR.asm
0000120b l .text 00000000 CommonISRStub
00000000 l df *ABS* 00000000 ../NovaCor/HardwareAbstractionLayer/Architectures/i686/MemSet.asm
00000000 l df *ABS* 00000000 ../NovaCor/HardwareAbstractionLayer/Architectures/i686/Paging.asm
00000000 l df *ABS* 00000000 NovaCor/HardwareAbstractionLayer/Architectures/i686/libhal.a.p/Boot.S.o
00000001 l *ABS* 00000000 ALIGN
e4524ffb l *ABS* 00000000 CHECKSUM
00000003 l *ABS* 00000000 FLAGS
1badb002 l *ABS* 00000000 MAGIC
00000002 l *ABS* 00000000 MEMINFO
0000129c l .text 00000000 protectedModeMain
00007000 l .bss 00000000 stack_bottom
0000b000 l .bss 00000000 stack_top
00000000 l df *ABS* 00000000 GDT.cpp
00000000 l .debug_str 00000000
00000267 l .debug_str 00000000
00000033 l .debug_str 00000000
000002a6 l .debug_str 00000000
0000008f l .debug_str 00000000
000002af l .debug_str 00000000
00000098 l .debug_str 00000000
000002b6 l .debug_str 00000000
000002bf l .debug_str 00000000
000002c7 l .debug_str 00000000
00000127 l .debug_str 00000000
000000c0 l .debug_str 00000000
000002cb l .debug_str 00000000
000002d5 l .debug_str 00000000
000002da l .debug_str 00000000
000002e5 l .debug_str 00000000
000000cf l .debug_str 00000000
000002ef l .debug_str 00000000
000002f8 l .debug_str 00000000
00000135 l .debug_str 00000000
00000304 l .debug_str 00000000
0000030b l .debug_str 00000000
00000317 l .debug_str 00000000
00000321 l .debug_str 00000000
0000032a l .debug_str 00000000
0000033e l .debug_str 00000000
00000349 l .debug_str 00000000
0000034f l .debug_str 00000000
00000354 l .debug_str 00000000
0000035d l .debug_str 00000000
00000368 l .debug_str 00000000
00000373 l .debug_str 00000000
0000037e l .debug_str 00000000
00000382 l .debug_str 00000000
0000045c l .debug_str 00000000
0000038a l .debug_str 00000000
00000395 l .debug_str 00000000
0000039e l .debug_str 00000000
000003a9 l .debug_str 00000000
000003b4 l .debug_str 00000000
00000355 l .debug_str 00000000
000003bf l .debug_str 00000000
000003da l .debug_str 00000000
000003df l .debug_str 00000000
000003e3 l .debug_str 00000000
000003e8 l .debug_str 00000000
00000402 l .debug_str 00000000
00000411 l .debug_str 00000000
0000041b l .debug_str 00000000
0000041e l .debug_str 00000000
00000422 l .debug_str 00000000
00000426 l .debug_str 00000000
00000466 l .debug_str 00000000
0000042a l .debug_str 00000000
0000042e l .debug_str 00000000
00000432 l .debug_str 00000000
00000436 l .debug_str 00000000
0000043a l .debug_str 00000000
0000044a l .debug_str 00000000
00000454 l .debug_str 00000000
00000458 l .debug_str 00000000
0000045b l .debug_str 00000000
00000462 l .debug_str 00000000
00000308 l .debug_str 00000000
0000046a l .debug_str 00000000
00000474 l .debug_str 00000000
0000047c l .debug_str 00000000
00000484 l .debug_str 00000000
00000491 l .debug_str 00000000
00000499 l .debug_str 00000000
000004a4 l .debug_str 00000000
000004af l .debug_str 00000000
00000000 l df *ABS* 00000000 IO.cpp
00000000 l .debug_str 00000000
000004bc l .debug_str 00000000
00000033 l .debug_str 00000000
000002cb l .debug_str 00000000
000002d5 l .debug_str 00000000
000002bf l .debug_str 00000000
000002c7 l .debug_str 00000000
00000127 l .debug_str 00000000
00000135 l .debug_str 00000000
000004fa l .debug_str 00000000
000004fe l .debug_str 00000000
000000c0 l .debug_str 00000000
000000cf l .debug_str 00000000
00000503 l .debug_str 00000000
00000000 l df *ABS* 00000000 Paging.cpp
00000000 l .debug_str 00000000
00000507 l .debug_str 00000000
00000033 l .debug_str 00000000
00000549 l .debug_str 00000000
00000555 l .debug_str 00000000
0000008f l .debug_str 00000000
00000354 l .debug_str 00000000
00000563 l .debug_str 00000000
0000032a l .debug_str 00000000
00000576 l .debug_str 00000000
00000585 l .debug_str 00000000
000001e5 l .debug_str 00000000
000001f6 l .debug_str 00000000
0000021b l .debug_str 00000000
000001a7 l .debug_str 00000000
00000098 l .debug_str 00000000
00000000 l df *ABS* 00000000 Terminal.cpp
00000000 l .debug_str 00000000
00000594 l .debug_str 00000000
00000033 l .debug_str 00000000
00000085 l .debug_str 00000000
0000008f l .debug_str 00000000
0000009c l .debug_str 00000000
000000a3 l .debug_str 00000000
000000ae l .debug_str 00000000
000000b2 l .debug_str 00000000
000000b9 l .debug_str 00000000
000000c0 l .debug_str 00000000
000000cf l .debug_str 00000000
000000d8 l .debug_str 00000000
000000e1 l .debug_str 00000000
00000130 l .debug_str 00000000
000000e8 l .debug_str 00000000
000000ed l .debug_str 00000000
000000f1 l .debug_str 00000000
000000fa l .debug_str 00000000
0000011a l .debug_str 00000000
00000127 l .debug_str 00000000
00000135 l .debug_str 00000000
0000013d l .debug_str 00000000
00000156 l .debug_str 00000000
0000015f l .debug_str 00000000
00000177 l .debug_str 00000000
0000017d l .debug_str 00000000
00000194 l .debug_str 00000000
00000098 l .debug_str 00000000
000001a9 l .debug_str 00000000
000001c2 l .debug_str 00000000
000001ca l .debug_str 00000000
000001df l .debug_str 00000000
000005e5 l .debug_str 00000000
000003b4 l .debug_str 00000000
000005fc l .debug_str 00000000
0000032a l .debug_str 00000000
0000060d l .debug_str 00000000
0000061d l .debug_str 00000000
0000062c l .debug_str 00000000
0000063c l .debug_str 00000000
0000064b l .debug_str 00000000
00000659 l .debug_str 00000000
0000066b l .debug_str 00000000
0000067b l .debug_str 00000000
00000690 l .debug_str 00000000
000006a4 l .debug_str 00000000
000006b9 l .debug_str 00000000
000006cf l .debug_str 00000000
000006e4 l .debug_str 00000000
000006f8 l .debug_str 00000000
00000710 l .debug_str 00000000
00000726 l .debug_str 00000000
00000736 l .debug_str 00000000
000003da l .debug_str 00000000
00000192 l .debug_str 00000000
0000073a l .debug_str 00000000
00000438 l .debug_str 00000000
00000561 l .debug_str 00000000
00000740 l .debug_str 00000000
00000746 l .debug_str 00000000
00000756 l .debug_str 00000000
00000760 l .debug_str 00000000
000001a7 l .debug_str 00000000
00000763 l .debug_str 00000000
00000774 l .debug_str 00000000
0000077c l .debug_str 00000000
00000781 l .debug_str 00000000
00000785 l .debug_str 00000000
0000024d l .debug_str 00000000
00000789 l .debug_str 00000000
000003df l .debug_str 00000000
000007aa l .debug_str 00000000
000007ae l .debug_str 00000000
000007bb l .debug_str 00000000
000007c2 l .debug_str 00000000
000007d3 l .debug_str 00000000
000007be l .debug_str 00000000
000007d7 l .debug_str 00000000
000007e1 l .debug_str 00000000
000007e6 l .debug_str 00000000
000007eb l .debug_str 00000000
000033ea l O .rodata 0000000b _ZZZN8Terminal5writeEiENK3$_0clEjE16numberCharacters
0000e004 l O .bss 00000040 _ZZZN8Terminal5writeEiENK3$_0clEjE6buffer
00000000 l df *ABS* 00000000
00005edc l O .dynamic 00000000 _DYNAMIC
00004000 l .eh_frame_hdr 00000000 __GNU_EH_FRAME_HDR
00006000 l O .got.plt 00000000 _GLOBAL_OFFSET_TABLE_
000010e0 g .text 00000000 flushGDT
0000b02e g O .bss 00000800 idtEntries
00001b20 g F .text 0000006d _ZN8TerminalC1Ev
0000d000 g O .bss 00001000 firstPageTable
00001138 g .text 00000000 isr4
000011e8 g .text 00000000 isr27
00001188 g .text 00000000 isr13
000011c5 g .text 00000000 isr22
00001194 g .text 00000000 isr15
00001168 g .text 00000000 isr9
000011cc g .text 00000000 isr23
000011f6 g .text 00000000 isr29
000b8000 g *ABS* 00000000 VGA_POINTER
00001204 g .text 00000000 isr31
000011be g .text 00000000 isr21
000011ef g .text 00000000 isr28
000012b0 g F .text 000000d1 loadGDT
00002160 g F .text 0000007d _ZN8Terminal5writeEi
0000115e g .text 00000000 isr8
00001bc0 g F .text 000000ad _ZN8Terminal8put_charEch
00001ae0 g F .text 00000037 _Z7strcompPKcS0_
000011b7 g .text 00000000 isr20
0000118d g .text 00000000 isr14
00001142 g .text 00000000 isr5
0000b82e g O .bss 00000006 idtPointer
00001000 g F .text 000000d7 kernel_main
00001c70 g F .text 00000044 _ZN8Terminal5shiftEv
00001b20 g F .text 0000006d _ZN8TerminalC2Ev
00001278 g F .text 0000002c _start
0000b000 g O .bss 00000028 gdtEntries
0000111a g .text 00000000 isr1
00002130 g F .text 00000024 _ZN8Terminal5writeEPKc
00001cc0 g F .text 0000046e _ZN8Terminal5writeEPKcj
000011e1 g .text 00000000 isr26
00001178 g .text 00000000 isr11
00001100 g .text 00000000 flushIDT
000018b0 g F .text 0000004d ISRHandlerImpl
00001180 g .text 00000000 isr12
00007000 g .bss 00000000 __bss_start
00001230 g .text 00000000 memset
00001390 g F .text 00000513 loadIDT
00001110 g .text 00000000 isr0
00001900 g F .text 00000065 ISRHandler
0000b028 g O .bss 00000006 gdtPointer
000011d3 g .text 00000000 isr24
0000119b g .text 00000000 isr16
0000112e g .text 00000000 isr3
00001970 g F .text 000000d6 loadTables
0000114c g .text 00000000 isr6
00001a60 g F .text 0000000a _Z3inbt
000011a9 g .text 00000000 isr18
0000c000 g O .bss 00001000 pageDirectory
00007000 g .data 00000000 _edata
0000f000 g .bss 00000000 _end
000021e0 g F .text 00000037 _ZN8Terminal7printlnEPKc
00001170 g .text 00000000 isr10
00001a70 g F .text 0000004e _ZN16MemoryManagement11beginPagingEv
00001b90 g F .text 00000029 _ZN8Terminal12put_entry_atEchjj
000011a2 g .text 00000000 isr17
00001124 g .text 00000000 isr2
00001a50 g F .text 0000000d _Z4outbth
000011b0 g .text 00000000 isr19
0000e000 g O .bss 00000004 _ZN8Terminal8instanceE
000011fd g .text 00000000 isr30
00001156 g .text 00000000 isr7
00001ac0 g F .text 0000001c _Z6strlenPKc
000011da g .text 00000000 isr25
0000600c g O .data 00000004 logo
00001250 g .text 00000000 setupPaging
User contributions licensed under CC BY-SA 3.0