Code: Select all
nasm -f bin src/loader.asm -o bin/loader.bin
Code: Select all
nasm -f elf64 -Wno-all src/loader.asm -o obj/loader.o
ld -nostdlib -o bin/loader.bin obj/loader.o --oformat=binary --entry=load -Ttext=0x7e00
The file outputted directly as binary is totally identical to the one with the linking stage except for a single instruction that has a major difference:
a near jump instruction in the 64-bit part of the code is totally different from the value it should be and obviously breaks everything.
dumping the binary I discovered that is exactly (0x130 + the org) bytes wrong so exactly these are the right bytes outputted from with the -f bin:
Code: Select all
e9 cc90 0f00
Code: Select all
e9 fc0f 1000
It could be worth noting that there are no other jumps in the 64-bit part of the code other than the broken one.
I don't think the code is worth to be posted, but if it is necessary let me know and I'll create a branch in the git repo for this issue.