Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
And it used to work fine until last night. I changed some file contents and ld starts linking them in the wrong way. I always got "error 13: invalid or unsupported executable format", because the entry point in the script is placed by ld in the middle of the executable (from my quick analyze, it links them alphabetically), making it impossible for GRUB to load. So, I change the command to link them where my loader and kernel are the first two and it works! Can someone explain how can this happen? I thought ld was smart enough to put entry point in the correct place (which I think, the first line in .text segment).
This is because of the grub multiboot header being out of the range searched. Try renaming the start.asm or similar to 0start.asm or specifically state it so it is linked first.
The files are sorted alphabetically because of the obj\*.o sorting them.
no it is because the header has been moved by an increased file before the entrypoint file, this means that grub cannot find the information required to boot your kernel.
Using the old version of my os as an example:
kernel.bin file order:
gdt.c
kb.c
main.c
scrn.c start.asm
...
When the files before start.asm grew to large the multiboot header was shifted out of the range that grub looks in.