Code: Select all
start.o: In function 'StartInHigherHalf':
start.asm:(.text+0x4d): undefined reference to '_kmain'
Has anyone had a similar problem?
Candamir
Code: Select all
start.o: In function 'StartInHigherHalf':
start.asm:(.text+0x4d): undefined reference to '_kmain'
Code: Select all
kernel.elf: file format elf32-i386
Sections:
Idx Name Size VMA LMA File off Algn
0 .text 00001541 c0100000 00100000 00001000 2**4
CONTENTS, ALLOC, LOAD, READONLY, CODE
1 .data 00001120 c0102000 00102000 00003000 2**5
CONTENTS, ALLOC, LOAD, DATA
2 .bss 000048dc c0103120 00103120 00004120 2**5
ALLOC
3 .comment 00000159 00000000 00000000 00004120 2**0
CONTENTS, READONLY
Code: Select all
...
OUTPUT_FORMAT(elf32-i386)
SECTIONS
{
. = 0xC0100000;
.text : AT(ADDR(.text) - 0xC0000000)
{
*(.text)
*(.rodata*)
}
.data ALIGN (0x1000) : AT(ADDR(.data) - 0xC0000000)
{
*(.data)
}
.bss : AT(ADDR(.bss) - 0xC0000000)
{
_sbss = .;
*(COMMON)
*(.bss)
_ebss = .;
}
}
You may have encountered a bug in the linker script. Try adding the .comments section in there and see if it fixes the problem...Candamir wrote:No .comments section... I already tried to solve the problems by removing the -O3 flag from my gcc commands, but it didn't result...
Can this be solved by properly including the .comments section in the linker script? Would that have to be done before or after the BSS section?
GRUB loads that fine. .note.GNU-stack and .comment don't have bits sets to actually load them, so this is no problem.kernel: file format elf32-i386
Sections:
Idx Name Size VMA LMA File off Algn
0 .text 00005340 00100000 00100000 00001000 2**5
CONTENTS, ALLOC, LOAD, READONLY, CODE
1 .data 00000204 00105340 00105340 00006340 2**5
CONTENTS, ALLOC, LOAD, DATA
2 .bss 00009500 00106000 00106000 00007000 2**12
ALLOC
3 .note.GNU-stack 00000000 00000000 00000000 00007000 2**0
CONTENTS, READONLY
4 .comment 00000484 00000000 00000000 00007000 2**0
CONTENTS, READONLY
Since the .bss section is for uninitialized data, there's not need to waste space in the file for it. In the objdump output the only flag for this section is ALLOC, which tells whatever is loading the file that it needs to reserve space for this section, but it doesn't need to load anything from the actual file. Thus the comment section actually starts at that address and just contains information that is ignored at load time, so I don't see how any of this could actually be the problem.Candamir wrote: I'll see what I can do...
BTW, I noticed that in my dump, the .comment section had the same offset in the file than the .bss section. Isn't there any space included for the .bss section? Is this realized dynamically, during program execution?
Code: Select all
...
OUTPUT_FORMAT(elf32-i386)
SECTIONS
{
. = 0xC0100000;
.text : AT(ADDR(.text) - 0xC0000000)
{
*(.text)
*(.rodata*)
}
.data ALIGN (0x1000) : AT(ADDR(.data) - 0xC0000000)
{
*(.data)
}
.bss : AT(ADDR(.bss) - 0xC0000000)
{
_sbss = .;
*(COMMON)
*(.bss)
_ebss = .;
}
/DISCARD/ :
{
*(.comment)
}
}
Code: Select all
...
section .setup
...
align 4
; Actual header
dd MULTIBOOT_HEADER_MAGIC
dd MULTIBOOT_HEADER_FLAGS
dd CHECKSUM
start:
; kernelEntry is inside .text, eg. will be at 0xC01xxxxx,
; If we add with the base then we have the real physical address.
jmp kernelEntry+0x40000000
section .text
kernelEntry:
; Same code as from the Wiki
lgdt [trickgdt]
mov ax, 0x10
mov ds, ax
mov es, ax
....
....
section .setup
trickgdt:
dw gdt_end - gdt - 1 ; size of the GDT
dd gdt ; linear address of GDT
....
....