Coder Social home page Coder Social logo

Comments (7)

pitust avatar pitust commented on August 21, 2024

I have some extra logging output from the bootloader

from bootloader.

phil-opp avatar phil-opp commented on August 21, 2024

Are you using any linker arguments? For me, the default linker script without any arguments seems to always produce aligned segments.

Either way, I agree that it would be nice if the bootloader could work with non-aligned segments.

from bootloader.

pitust avatar pitust commented on August 21, 2024

Indeed, my target triple is:

{
    "llvm-target": "x86_64-unknown-none",
    "data-layout": "e-m:e-i64:64-f80:128-n8:16:32:64-S128",
    "arch": "x86_64",
    "target-endian": "little",
    "target-pointer-width": "64",
    "target-c-int-width": "32",
    "os": "none",
    "executables": true,
    "linker-flavor": "ld.lld",
    "linker": "rust-lld",
    "disable-redzone": true,
    "features": "-mmx,+sse",
    "panic-strategy": "unwind",
    "pre-link-args": {
        "ld.lld": [
            "/opt/cross/lib/gcc/x86_64-elf/10.2.0/libgcc.a", "--allow-multiple-definition",
        ]
    }
}

I need libgcc for _Unwind_* functions (i use that for stack traces). I assume that it is due to libgcc.a having a .got section which isn't 4k-aligned.

from bootloader.

pitust avatar pitust commented on August 21, 2024

anyway i switched to multiboot2 and first edition of the guide, because i want support for modern architectures.

from bootloader.

pitust avatar pitust commented on August 21, 2024

Wait, no, i got wrong args, i do indeed have a linker script, the one found on osdev.org (https://wiki.osdev.org/Bare_Bones)

from bootloader.

phil-opp avatar phil-opp commented on August 21, 2024

i do indeed have a linker script, the one found on osdev.org (https://wiki.osdev.org/Bare_Bones)

Ah, that explains things. I think most default linker scripts align all sections properly, but a custom linker script might not. The linker script you linked does not mention any .got section, so the linker just places it after the last section, without any special alignment.

While I still agree that it would be nice if the bootloader crate supported non-aligned sections, section alignment is still recommended because otherwise you might not be able to set the correct write/executable permissions for these pages. For example, if .text shares a page with .data, that page must be mapped as both writable and executable, which is generally discouraged since attackers can easily run their injected code this way.

anyway i switched to multiboot2 and first edition of the guide, because i want support for modern architectures.

Could you clarify what you mean with "modern architectures"? Support for UEFI booting or something else? I'm currently working on a new version of the bootloader with UEFI support, so it would be useful to know if something else is missing too.

from bootloader.

pitust avatar pitust commented on August 21, 2024

UEFI and coreboot. I know CSM is a thing, but i wouldn't rely on that. (there are some laptops that use coreboot out of the box, most notably pixelbooks and everything with System76 Open Firmware)

from bootloader.

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.