Tutorial 2: Warnings Generated after Linking

I've begun working through the tutorials on a System 76 machine I have with Xubuntu and a 64 bit processor. I downloaded a zip of the files from your github and followed along with the video. When I got to running nasm, there was seemingly no problem. When I began to link, I got the following:

ld: i386 architecture of input file `Kernel.o' is incompatible with i386:x86-64 output
ld: warning: cannot find entry symbol _start; defaulting to 0000000000400080

I searched for that, and found that when I ran nasm, it probably should have been:

nasm -g -f elf64 -o Kernel.o Kernel.asm

This time when I ran the linker, I got the following still:

ld: warning: cannot find entry symbol _start; defaulting to 0000000000400080


I don't think this will be a problem, but I did want to mention the rest above.

Comments

  • Also, would it be possible to run the ISO tool from Linux with Wine?
  • Hi,

    This is because NASM produces 32-bit code and you're running the system's Ld on a 64-bit system so it will be expecting 64-bit machine code. Modifying the command as you have produces 64-bit code which might be fine but be careful it doesn't use non-32 bit ops.

    The "couldn't find _start" is a very big problem. The linker inserts the start-point of the system as part of the file header which is used in the ISO / by the bootloader. The default address is unlikely to work properly though you might get lucky. In fact, it should be using _Kernel_Start as the entry point - ensure you're using the proper link script. Also make sure _Kernel_Start is global in your ASM file. If the linker and NASM aren't working in harmony the final ISO won't work.

    Regarding the ISO tool, it might be possible but you'd be better off doing it using Linux mkisofs - see the second post in this thread (on this forum) about it: http://community.flingos.co.uk/discussion/4/generating-the-iso-image-from-the-tutorials-on-linux
  • edited January 2016
    Ed,

    All pertinent information! Thank you for not only doing this, but for your quick and insightful response. I think I'll re-evaluate and update this sprog when I am successful.

    Unrelated, is there a section for how to do things like indent code on your forum that I'm missing?
  • No problem and no, sorry. This forum is currently powered by Vanilla Forums without plug in for code etc so it's just simple text for now (and possibly links - I forget exactly what's available). When I get time I'll expand the forum capabilities :)
  • Ed,

    the tutorials are a great help in understanding systems and what it takes to create an OS. As of now, I only have a 64-bit machine with Windows 10. Am I able to install NASM 32 and run it to follow the tutorials?

    Thanks,
    BG
  • Hi BG,

    Glad you find them helpful!

    Yes, you can definitely do all 32-bit development on a 64-bit machine. In fact, I've not used a 32-bit processor for development for quite some years now.

    NASM doesn't actually require installation - it's a standalone executable that you can download and run from the command line. It can handle 16, 32 or 64-bit code - it all depends on the ASM you feed it! It can also produce code for Windows or Unix-like systems.

    FlingOS is generally designed for development on Windows but (almost all of it) is known to work on Linux. The tutorials use NASM to produce ELF-binaries which are actually the Linux format-of-choice not Windows. ELF is easier to work with, works with Ld (the GCC linker used in the tutorials) and the various other GCC tools.

    A final note that any x86 32-bit (and a lot of 16-bit) is still compatible with even Intel Skylake processors. x86 has a history of maintaining compatibility so any 32-bit code will execute on a 64-bit processor (or in a VM on a 64-bit processor). MIPS and ARM don't have the same level of compatibility across versions. The only caveat is that you can't randomly mix 32-bit and 64-bit (and definitely don't use 16-bit code!). You've got to settle for one or the other. FlingOS doesn't deal with 64-bit code because it adds unnecessary complexity with no benefits for just learning how operating systems work.

    Best of luck!
    Ed
  • Ed,

    Excellent! I will continue with the tutorials and start my path on OS development.

    Thanks again, Ed. You are presenting some quality material and I will spread the word.
  • Thank you very much! Very happy that you like the content :)

    Cheers, Ed
Sign In or Register to comment.