Git Product home page Git Product logo

Comments (9)

bjorn3 avatar bjorn3 commented on June 11, 2024

How are you linking the code? It looks like you are invoking the linker yourself rather than having rustc invoke it for you. You may be missing necessary linker flags.

from blog_os.

sadkris avatar sadkris commented on June 11, 2024

How are you linking the code? It looks like you are invoking the linker yourself rather than having rustc invoke it for you. You may be missing necessary linker flags.

After compiling it in rustc, I'm using the command i686-elf-ld -o tmp/kernel.bin -Ttext 0x1000 tmp/kernel_entry.o tmp/kernel.o --oformat binary with the compiled .o file being kernel.o, and kernel_entry being an assembly script to import and run _start.

from blog_os.

bjorn3 avatar bjorn3 commented on June 11, 2024

How did you get that kernel.o file? If you literally passed --emit obj, that will not work. That will not include the machine code for dependencies. What you could do however is compile with the staticlib crate type and then link the resulting libkernel.a. This bundles all dependencies.

from blog_os.

sadkris avatar sadkris commented on June 11, 2024

What would the config need to look like in order to do that?

from blog_os.

bjorn3 avatar bjorn3 commented on June 11, 2024

In Cargo.toml you can add

[lib]
crate-type = ["staticlib"]

from blog_os.

sadkris avatar sadkris commented on June 11, 2024

Recompiling it with that change, as well as changing the file name from main to lib, then copying the .a file from target/i686/debug, it produced a linking error since it was using a GOT with PIE enabled. When I disabled PIE, the script compiled correctly and linked properly, but running it in qemu gets stuck in a boot loop of flashing the "SeaBIOS" header as well as "Booting from hard disk", then going to a blank screen, then repeating.

from blog_os.

phil-opp avatar phil-opp commented on June 11, 2024

The bootloader crate only supports booting x86_64 kernels, not 32-bit kernels.

from blog_os.

sadkris avatar sadkris commented on June 11, 2024

The bootloader crate only supports booting x86_64 kernels, not 32-bit kernels.

I am not using the bootloader crate at all. As I mentioned before, I'm using my own bootloader

from blog_os.

phil-opp avatar phil-opp commented on June 11, 2024

Ah, I missed that! In that case, you probably have to debug your bootloader. You can either connect gdb and step through the assembly to see where it fails, or you use QEMU's -d int flag to see which exceptions occur where. If course you can also insert endless loops at various stages in your bootloader to narrow down which part causes the crash.

from blog_os.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.