Undefined reference to assembly function
Posted: Sun Apr 16, 2017 2:48 am
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
I'm inluding io.h in another file, terminal.c, but when trying to link I get an "undefined reference to outb" error.
What am I doing wrong?
I have 2 files, io.s and io.h
Code: Select all
.intel_syntax noprefix
.global outb
.type outb, @function
mov al, [esp+8]
mov dx, [esp+4]
out dx, al
ret
Code: Select all
#include <stddef.h>
void outb(size_t port, size_t data);
Code: Select all
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