LD Warning due to being unable to find symbol "start"?

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
JamieEdwards
Posts: 11
Joined: Fri Apr 06, 2012 5:18 am

LD Warning due to being unable to find symbol "start"?

Post by JamieEdwards »

Hi guys,

I can't see what could be happening as I've done nothing to my boot file and for some strange reason LD isn't linking this file with my main file which is driving me nuts ( even though there might be some extremely simple reason behind it. ) I've Googled for a cure and one said to change "_start" to "start" but I already had the latter.

The warning is:

Code: Select all

ld: warning: cannot find entry symbol start; defaulting to 0000000000100000
And my boot file:

Code: Select all

; boot.asm -- Kernel entry point

global start										; Make entry point visible to the linker
global magic										; Used in kmain
global mbd											; Also used in kmain

extern kmain										; kmain is defined in kmain.c

section .__mbHeader

BITS 32												; Instructions are 32 bit

; Set up the Multiboot header

MBOOT_PAGE_ALIGN		   equ			1<<0			; Align modules on page boundaries
MBOOT_MEM_INFO			equ			1<<1			; Provide memory map to kernel
MBOOT_HEADER_FLAGS		equ			MBOOT_PAGE_ALIGN | MBOOT_MEM_INFO

MBOOT_HEADER_MAGIC		equ			0x1BADB002		; Required by GRUB
MBOOT_CHECKSUM			equ			-(MBOOT_HEADER_FLAGS + MBOOT_HEADER_MAGIC)

align 4
	dd	MBOOT_HEADER_MAGIC
	dd	MBOOT_HEADER_FLAGS
	dd	MBOOT_HEADER_CHECKSUM

section .text

; Reserve initial stack space
STACKSIZE		equ			0x4000					; That's 16k

start:
	mov			esp,		stack + STACKSIZE		; Set up the stack
	mov			[magic],	eax						; Multiboot header number
	mov			[mbd],		ebx						; Multiboot info structure

	call		kmain								; Call the kernel

	cli

.hang:
	hlt												; Halt the machine should kernel return
	jmp			.hang



section .bss

align 4
stack:			resb		STACKSIZE				; Reserve 16k stack on a doubleword boundary
magic:			resd		1
mbd:			resd		1
and my link file:

Code: Select all

ENTRY(start)
OUTPUT_FORMAT(elf32-i386)

phys = 0x00100000;
SECTIONS
{
/*Set the virtual address:*/
. = phys;
/*
* http://wiki.osdev.org/Grub_Error_13
*/

/* .__mbHeader will begin @ 'phys' */
.__mbHeader : AT ( ADDR( .__mbHeader ) ) {
/* mboot = .;*/
*(.__mbHeader)
}

.text ALIGN(4096) : AT(ADDR(.text)) {
code = .;
*(.text)
*(.rodata)
}
.data ALIGN(4096) : AT(ADDR(.data)) /*Voila*/
{
data = .;
*(.data)
}
.bss ALIGN(4096) : AT ( ADDR (.bss) )
{
bss = .;
*(.bss)
}
end = .;
}
Oh and as a result, I get no "boot.o" but a kernel executable which throws a GRUB error 13 as boot isn't present :L

Any idea's?

Thanks.
FallenAvatar
Member
Member
Posts: 283
Joined: Mon Jan 03, 2011 6:58 pm

Re: LD Warning due to being unable to find symbol "start"?

Post by FallenAvatar »

I'm confused... You say that no boot.o is created, and yet point to ld's error....

LD relies on boot.o, as well as the other object files (*.o) to generate your binary. It doesn't create them.

Me thinks you missed an error from nasm/gas/fasm/(insert assembler here) that will point you in the correct direction.

- Monk
JamieEdwards
Posts: 11
Joined: Fri Apr 06, 2012 5:18 am

Re: LD Warning due to being unable to find symbol "start"?

Post by JamieEdwards »

This is how it looks like when I run the make command:

Code: Select all

$ make
ld -Tlink.ld -melf_i386  -o kern/kernel obj/main.o
ld: warning: cannot find entry symbol start; defaulting to 0000000000100000
Linking Everything for kernel...
Linking Complete...



Kernel is ready for use
And inside my obj directory:

Code: Select all

$ ls
main.o
I also noticed that when I ran "make clean", it wouldn't delete the *.o files despite stating it in the make file?

Here's how I have my dir tree at the moment:

Code: Select all

/
    core/
        arch/
            boot.asm
        main.c
    docs/
    include/
        This will house the system used header files
    iso/
        bootable.iso
    isofiles/
        This is where I store the GRUB eltorito file and cfg file to make my bootable.iso image
    kern/
        kernel ( this is the binary executable that I boot with Bochs )
    obj/
        main.o /* boot.o */
    shScripts/
        update_image.sh
        run_bochs.sh
    link.ld
    makefile
    run.sh ( This is the file I use after running "make" its use is to run the scripts that are in shScripts/ )
FallenAvatar
Member
Member
Posts: 283
Joined: Mon Jan 03, 2011 6:58 pm

Re: LD Warning due to being unable to find symbol "start"?

Post by FallenAvatar »

What does your makefile look like?

- Monk
JamieEdwards
Posts: 11
Joined: Fri Apr 06, 2012 5:18 am

Re: LD Warning due to being unable to find symbol "start"?

Post by JamieEdwards »

I don't know what's happened but I tried it again this morning and it decided to start working again XD
Post Reply