Page 1 of 1

Strange thing with cross compiler

Posted: Sat Dec 11, 2021 7:19 am
by NeonLightions
Hi,
Now I'm trying to develop 64-bit OS. But I got a strange thing when compiling: When I use x86_64-elf-gcc or x86_64-elf-ld, GRUB shown this error:
Image
When I change to system compiler, it's back to normal. Can anyone explain this for me?

Re: Strange thing with cross compiler

Posted: Sat Dec 11, 2021 7:46 am
by iansjack
Your image is broken, so we can't see the error message.

But, are you perhaps using some libc function?

Re: Strange thing with cross compiler

Posted: Sat Dec 11, 2021 7:48 am
by NeonLightions
iansjack wrote:Your image is broken.
I used grub-file --is-x86-multiboot2 to check the binary and there is no multiboot in binary file. So i don't think the image i broken.

Re: Strange thing with cross compiler

Posted: Sat Dec 11, 2021 7:49 am
by iansjack
The image you tried to post of the error message.

Re: Strange thing with cross compiler

Posted: Sat Dec 11, 2021 7:53 am
by NeonLightions
iansjack wrote:The image you tried to post of the error message.
Oh,
It said: "Multiboot header not found"

Re: Strange thing with cross compiler

Posted: Sat Dec 11, 2021 8:52 am
by iansjack
It's impossible to say what the problem is without seeing your code, your linker file, and the exact commands you are using. Can you link to an on-line repository of your code. Something in this thread may help: viewtopic.php?f=1&t=33521

Re: Strange thing with cross compiler

Posted: Sat Dec 11, 2021 11:06 am
by deadmutex
Are you using multiboot or multiboot2?

Re: Strange thing with cross compiler

Posted: Sat Dec 11, 2021 7:20 pm
by NeonLightions
deadmutex wrote:Are you using multiboot or multiboot2?
I'm using multiboot2.

Re: Strange thing with cross compiler

Posted: Sat Dec 11, 2021 7:21 pm
by NeonLightions
iansjack wrote:It's impossible to say what the problem is without seeing your code, your linker file, and the exact commands you are using. Can you link to an on-line repository of your code. Something in this thread may help: viewtopic.php?f=1&t=33521
Here is my repo: https://github.com/NeonLightions/Amore-OS-x64. The header is at src/boot/grub/header.S, the _start function is at src/sys/_start.S and the linker is at scripts/linker.ld

Re: Strange thing with cross compiler

Posted: Sat Dec 11, 2021 7:46 pm
by Octocontrabass
That's the wrong LD. Also, you might need to use "-z max-page-size=0x1000" to tell LD that it shouldn't add a bunch of padding to your kernel.

Re: Strange thing with cross compiler

Posted: Sun Dec 12, 2021 6:41 am
by NeonLightions
Octocontrabass wrote:That's the wrong LD. Also, you might need to use "-z max-page-size=0x1000" to tell LD that it shouldn't add a bunch of padding to your kernel.
Thank you very much! Now I can use cross linker.