I use nasm to compile this assembly code and link it with some other output file ‘i686-elf’:
global x86_Video_GetVbeInfo
x86_Video_GetVbeInfo:
; make new call frame
push ebp ; save old call frame
mov ebp, esp ; initialize new call frame
x86_EnterRealMode
; save modified regs
push edi
push es
push ebp ; bochs vbe changes ebp
; call interrupt
mov ax, 0x4f00
LinearToSegOffset [bp + 8], es, edi, di
int 10h
; check return
cmp al, 4fh
jne .error
; put status in eax
mov al, ah
and eax, 0xFF
jmp .cont
.error:
mov eax, -1
.cont:
; restore regs
pop ebp ; bochs vbe changes ebp
pop es
pop ebx
push eax
x86_EnterProtectedMode
pop eax
; restore old call frame
mov esp, ebp
pop ebp
ret
My linking command:
i686-elf-ld -T ../src/linker.ld -o ../binary/isolation/rcmiracle.bin -ffreestanding -O2 -nostdlib ../binary/compiler_out/x86.o ../binary/compiler_out/boot.o ../binary/compiler_out/kernel.o -lgcc
nasm doesn’t return any errors, but ld gave me some abstruse error:
../binary/compiler_out/x86.o: in function `x86_Video_GetVbeInfo':
../src/x86.asm:(.text+0x44): relocation truncated to fit: R_386_16 against `.text'
../binary/compiler_out/x86.o: in function `x86_Video_GetVbeInfo.pmode16':
../src/x86.asm:(.text+0x51): relocation truncated to fit: R_386_16 against `.text'
I tried to modify my linker script but no result. Any ideas?