Code: Select all
#include <types.h>
#include <console.h>
void Kernel_Main()
{
Console_Initialize();
Console_Clear();
for(;;);
}
I am using a cross-compiler (i586-elf-*) on Cygwin, made a few days ago from fresly downloaded gcc-core-4.5.1 and binutils-2.20 sources, compiled with Cygwin's gcc-core 3.4.4-999 (the most recent stable version I could select). It feels very similar to this question, but that one was never answered.
Now follows the hopefully relevant information. I've stripped as much useless code as possible, and tested that the problem still persists. Thanks in advance to anyone pointing me in the right direction!
Code: Select all
$ make all
nasm -I./src/ -o src/boot.obj -f elf src/boot.asm
i586-elf-gcc -Wall -O -fno-stack-protector -fstrength-reduce -fomit-frame-pointer -finline-functions -nostdinc -fno-builtin -I./include -c -o src/kernel.o src/kernel.c
i586-elf-gcc -Wall -O -fno-stack-protector -fstrength-reduce -fomit-frame-pointer -finline-functions -nostdinc -fno-builtin -I./include -c -o src/system.o src/system.c
i586-elf-gcc -Wall -O -fno-stack-protector -fstrength-reduce -fomit-frame-pointer -finline-functions -nostdinc -fno-builtin -I./include -c -o src/memory.o src/memory.c
i586-elf-gcc -Wall -O -fno-stack-protector -fstrength-reduce -fomit-frame-pointer -finline-functions -nostdinc -fno-builtin -I./include -c -o src/string.o src/string.c
i586-elf-gcc -Wall -O -fno-stack-protector -fstrength-reduce -fomit-frame-pointer -finline-functions -nostdinc -fno-builtin -I./include -c -o src/console.o src/console.c
i586-elf-ld -o ../myos_kernel.bin -T link.ld src/boot.obj src/kernel.o src/system.o src/memory.o src/string.o src/console.o
src/kernel.o: In function `Kernel_Main':
kernel.c:(.text+0x9): undefined reference to `Console_Clear'
make: *** [../myos_kernel.bin] Error 1
Code: Select all
OUTPUT_FORMAT("binary")
ENTRY(start)
phys = 0x00100000;
SECTIONS
{
.text phys : AT(phys) {
code = .;
*(.text)
*(.rodata)
. = ALIGN(4096);
}
.data : AT(phys + (data - code))
{
data = .;
*(.data)
. = ALIGN(4096);
}
.bss : AT(phys + (bss - code))
{
bss = .;
*(.bss)
. = ALIGN(4096);
}
end = .;
}
Code: Select all
#ifndef __CONSOLE_H
#define __CONSOLE_H
#include <types.h>
extern void Console_SetCursorPosition(nint left, nint top);
extern void Console_Clear();
extern void Console_Write(const achar* text);
extern void Console_WriteLine(const achar* text);
extern void Console_WriteFromEnd(const achar* text);
extern byte Console_GetBackgroundColor();
extern void Console_SetBackgroundColor(byte value);
extern byte Console_GetForegroundColor();
extern void Console_SetForegroundColor(byte value);
extern void Console_ResetColor();
extern void Console_Initialize();
#endif // __CONSOLE_H
#ifndef __TYPES_H
#define __TYPES_H
#ifndef NULL
#define NULL ((void*) 0)
#endif
typedef unsigned char byte;
typedef signed char sbyte;
typedef signed short int16;
typedef unsigned short uint16;
typedef signed long int32;
typedef unsigned long uint32;
typedef signed int nint;
typedef unsigned int unint;
typedef char achar;
typedef enum { false, true } bool;
#endif // __TYPES_H
Code: Select all
$ objdump -t src/console.o
src/console.o: file format elf32-i386
SYMBOL TABLE:
00000000 l df *ABS* 00000000 console.c
00000000 l d .text 00000000 .text
00000000 l d .data 00000000 .data
00000000 l d .bss 00000000 .bss
00000004 l O .bss 00000004 cursor_x
00000008 l O .bss 00000004 cursor_y
00000000 l O .data 00000002 textcolor
00000000 l O .bss 00000004 consolememory
00000000 l d .rodata.str1.1 00000000 .rodata.str1.1
00000000 l d .comment 00000000 .comment
00000000 g F .text 00000095 Console_SetCursorPosition
00000000 *UND* 00000000 System_WritePortByte
00000095 g F .text 00000054 Console_Clear
00000000 *UND* 00000000 Memory_SetW
000000e9 g F .text 00000157 Console_Write
00000000 *UND* 00000000 Memory_Move
00000000 *UND* 00000000 String_Length
00000240 g F .text 0000001c Console_WriteLine
0000025c g F .text 00000028 Console_WriteFromEnd
00000000 *UND* 00000000 String_VisibleLength
00000284 g F .text 0000000b Console_GetBackgroundColor
0000028f g F .text 00000010 Console_SetBackgroundColor
0000029f g F .text 0000000a Console_GetForegroundColor
000002a9 g F .text 00000011 Console_SetForegroundColor
000002ba g F .text 0000000a Console_ResetColor
000002c4 g F .text 00000016 Console_Initialize
$ objdump -t src/kernel.o
src/kernel.o: file format elf32-i386
SYMBOL TABLE:
00000000 l df *ABS* 00000000 kernel.c
00000000 l d .text 00000000 .text
00000000 l d .data 00000000 .data
00000000 l d .bss 00000000 .bss
00000000 l d .comment 00000000 .comment
00000000 g F .text 0000000f Kernel_Main
00000000 *UND* 00000000 Console_Initialize
00000000 *UND* 00000000 Console_Clear