OSDev.org

The Place to Start for Operating System Developers
It is currently Tue Mar 19, 2024 12:51 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: BARE BONES file boot.s
PostPosted: Fri Jan 29, 2016 11:45 pm 
Offline
Member
Member

Joined: Sat Dec 19, 2015 10:48 am
Posts: 42
I converted BARE BONES file boot.s (see below) into NASM format (boot.asm below) as well as I could. I tried to assemble boot.asm (nasm boot.asm -o boot.o) and I get the error:

symbol `kernel_main' undefined

Of course. So why doesnt: (as boot.s -o boot.o) get the same error?. boot.s has the same undefined symbol yet it assembles fine.


Quote:
BARE BONES 'as' format boot.s

.set ALIGN, 1<<0 # align loaded modules on page boundaries
.set MEMINFO, 1<<1 # provide memory map
.set FLAGS, ALIGN | MEMINFO # this is the Multiboot 'flag' field
.set MAGIC, 0x1BADB002 # 'magic number' lets bootloader find the header
.set CHECKSUM, -(MAGIC + FLAGS) # checksum of above, to prove we are multiboot
.section .multiboot
.align 4
.long MAGIC
.long FLAGS
.long CHECKSUM
.section .bootstrap_stack, "aw", @nobits
stack_bottom:
.skip 16384 # 16 KiB
stack_top:
.section .text
.global _start
.type _start, @function
_start:
call kernel_main
cli
hlt
.Lhang:
jmp .Lhang

.size _start, . - _start




Quote:
NASM format: boot.asm:

FLAGS EQU 3
MAGIC EQU 0x1badb002
CHECKSUM EQU -(MAGIC + FLAGS)
SECTION .multiboot
align 4
dd MAGIC
dd FLAGS
dd CHECKSUM
SECTION bootstrap_stack nobits
stack_bottom:
resb 16384 ; 16 KiB
stack_top:
SECTION .text
global _start
_start:
call kernel_main
cli
hlt
Lhang:
jmp Lhang



Thanks. Bill S.


Top
 Profile  
 
 Post subject: Re: BARE BONES file boot.s
PostPosted: Sat Jan 30, 2016 12:57 am 
Offline
Member
Member
User avatar

Joined: Sat Mar 31, 2012 3:07 am
Posts: 4591
Location: Chichester, UK
kernel_main() should be defined in your kernel.c file. It sounds as if you are trying to build an executable just from boot.o and forgetting to produce, and link, kernel.o also. You need to use the -f elf switch with your nasm command.


Top
 Profile  
 
 Post subject: Re: BARE BONES file boot.s
PostPosted: Sat Jan 30, 2016 2:15 am 
Offline
Member
Member
User avatar

Joined: Thu Mar 27, 2014 3:57 am
Posts: 568
Location: Moscow, Russia
In GAS you don't have to define external symbols. In NASM you have to.
Code:
extern kernel_main

_________________
"If you don't fail at least 90 percent of the time, you're not aiming high enough."
- Alan Kay


Top
 Profile  
 
 Post subject: Re: BARE BONES file boot.s
PostPosted: Sat Jan 30, 2016 3:19 am 
Offline
Member
Member

Joined: Sat Dec 19, 2015 10:48 am
Posts: 42
extern kernel_main - that's it ! thanks


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 8 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group