OSDev.org

The Place to Start for Operating System Developers
It is currently Fri Mar 29, 2024 7:04 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Undefined reference to assembly function
PostPosted: Sun Apr 16, 2017 2:48 am 
Offline
Member
Member
User avatar

Joined: Sun Feb 12, 2017 1:50 am
Posts: 26
I have a function written in assembly and I am trying to access it from C through a header file.

I have 2 files, io.s and io.h
Code:
.intel_syntax noprefix

.global outb
.type outb, @function
mov al, [esp+8]
mov dx, [esp+4]
out dx, al
ret


Code:
#include <stddef.h>

void outb(size_t port, size_t data);


I'm inluding io.h in another file, terminal.c, but when trying to link I get an "undefined reference to outb" error.
Code:
i686-elf-as io.s -o io.o
i686-elf-gcc -T linker.ld -o myos.bin -ffreestanding -O2 -nostdlib boot.o kernel.o terminal.o io.o -lgcc
terminal.o: In function `terminal_move_cursor':
terminal.c:(.text+0x61): undefined reference to `outb'
terminal.c:(.text+0x81): undefined reference to `outb'
terminal.c:(.text+0x98): undefined reference to `outb'
terminal.c:(.text+0xb1): undefined reference to `outb'
collect2: error: ld returned 1 exit status


What am I doing wrong?


Top
 Profile  
 
 Post subject: Re: Undefined reference to assembly function
PostPosted: Sun Apr 16, 2017 3:00 am 
Offline
Member
Member
User avatar

Joined: Thu Jul 12, 2012 7:29 am
Posts: 723
Location: Tallinn, Estonia
You have not defined a label outb: in your asm file.

_________________
Learn to read.


Top
 Profile  
 
 Post subject: Re: Undefined reference to assembly function
PostPosted: Sun Apr 16, 2017 3:06 am 
Offline
Member
Member
User avatar

Joined: Sun Feb 12, 2017 1:50 am
Posts: 26
dozniak wrote:
You have not defined a label outb: in your asm file.


...it is late

Thank you


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

All times are UTC - 6 hours


Who is online

Users browsing this forum: Google [Bot] and 188 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