(I use same linker script and I also link it with font.psf just like in BOOTBOOT example)
Code: Select all
x86_64-elf-gcc --sysroot=/home/<...>/sysroot -isystem=/usr/include -nostdlib -nostartfiles -T kernel.ld -nostdlib -lk -lgcc kernel/kernel.o rc/font.o utils/tty.o -o sielawix.kernel
x86_64-elf-strip -s -K mmio -K fb -K bootboot -K environment -K initstack sielawix.kernel
/usr/local/lib/gcc/x86_64-elf/10.0.0/../../../../x86_64-elf/bin/ld: kernel/kernel.o: in function `_start':
kernel.c:(.text+0x1b0): undefined reference to `printf'
/usr/local/lib/gcc/x86_64-elf/10.0.0/../../../../x86_64-elf/bin/ld: utils/tty.o: in function `tty_clear':
tty.c:(.text+0xc0): undefined reference to `memset'
/usr/local/lib/gcc/x86_64-elf/10.0.0/../../../../x86_64-elf/bin/ld: utils/tty.o: in function `tty_puti':
tty.c:(.text+0x56f): undefined reference to `itoa'
/usr/local/lib/gcc/x86_64-elf/10.0.0/../../../../x86_64-elf/bin/ld: utils/tty.o: in function `tty_putl':
tty.c:(.text+0x59f): undefined reference to `itoa64'
collect2: error: ld returned 1 exit status
Code: Select all
BITS 64
global printf
printf:
nop
nop
"printf" and other required functions ARE in libk.a:
Code: Select all
readelf -s sysroot/usr/lib/libk.a
File: sysroot/usr/lib/libk.a(printf.libk.o)
Symbol table '.symtab' contains 21 entries:
Num: Value Size Type Bind Vis Ndx Name
0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND
1: 0000000000000000 0 FILE LOCAL DEFAULT ABS printf.c
2: 0000000000000000 0 SECTION LOCAL DEFAULT 1
3: 0000000000000000 0 SECTION LOCAL DEFAULT 3
4: 0000000000000000 0 SECTION LOCAL DEFAULT 4
5: 0000000000000000 0 SECTION LOCAL DEFAULT 5
6: 0000000000000000 0 SECTION LOCAL DEFAULT 7
7: 0000000000000000 0 SECTION LOCAL DEFAULT 8
8: 0000000000000000 0 SECTION LOCAL DEFAULT 9
9: 0000000000000000 0 SECTION LOCAL DEFAULT 11
10: 0000000000000000 0 SECTION LOCAL DEFAULT 12
11: 0000000000000000 0 SECTION LOCAL DEFAULT 14
12: 0000000000000000 0 SECTION LOCAL DEFAULT 16
13: 0000000000000000 0 SECTION LOCAL DEFAULT 15
14: 0000000000000000 1129 FUNC GLOBAL DEFAULT 1 vprintf
15: 0000000000000000 0 NOTYPE GLOBAL DEFAULT UND strlen
16: 0000000000000000 0 NOTYPE GLOBAL DEFAULT UND putchar
17: 0000000000000000 0 NOTYPE GLOBAL DEFAULT UND itoa
18: 0000000000000000 0 NOTYPE GLOBAL DEFAULT UND tty_puts
19: 0000000000000000 0 NOTYPE GLOBAL DEFAULT UND itoa64
20: 0000000000000470 148 FUNC GLOBAL DEFAULT 1 printf
.
.
.
Here's my code: https://we.tl/t-o8GDiazQot
In order to compile it just run "make" command in root directory, but you need x86_64-elf cross compiler and toolchain.