Skip to content

Fix building with new rust-nightly.#561

Draft
jarovo wants to merge 2 commits intorust-osdev:mainfrom
jarovo:main
Draft

Fix building with new rust-nightly.#561
jarovo wants to merge 2 commits intorust-osdev:mainfrom
jarovo:main

Conversation

@jarovo
Copy link
Copy Markdown

@jarovo jarovo commented May 9, 2026

  • Fixes to enable compiling with new rust.
    after bumping the tempfile to use new deps, there was this linker issue to be fixed:
 = note: rust-lld: error: /home/jhenner/projects/bootloader/target/i386-code16-stage-2/stage-2/deps/bootloader_x86_64_bios_stage_2-2a60fabcbb129033.bootloader_x86_64_bios_stage_2.3f4927ae6a5f4601-cgu.0.rcgu.o:(function bootloader_x86_64_bios_stage_2::start: .text._RNvCs5qRQZAVXUQf_30bootloader_x86_64_bios_stage_25start+0x251): relocation R_386_16 out of range: 73531 is not in [-32768, 65535]; references section '.bss._RNvNvXNtCs5qRQZAVXUQf_30bootloader_x86_64_bios_stage_24diskNtB4_10DiskAccessNtB4_4Read10read_exact7TMP_BUF'

To address this I made disk_buffer a stack variable instead of static variable because the now large .text region pushed the .bss so much that it didn't fit to the 16bit address range ( the .text precedes the .bss in the stage-2-link.ld file). Another advantage is that this allowed me to remove the unsafe block. I think I was getting some memory corruption when dealing with the references to the static mem region.

  • Enlarge the stack.
    IIRC After moving the disk_buffer to the stack the some of the tests BIOS boot and then nothing was happening. After changing the ESP to 0x00080000 all the tests are passing. Only the large_ramdisk test sometimes fails. It seems to be flaky - many times it passes.

@Freax13
Copy link
Copy Markdown
Member

Freax13 commented May 10, 2026

  • Fixes to enable compiling with new rust.
    after bumping the tempfile to use new deps, there was this linker issue to be fixed:
 = note: rust-lld: error: /home/jhenner/projects/bootloader/target/i386-code16-stage-2/stage-2/deps/bootloader_x86_64_bios_stage_2-2a60fabcbb129033.bootloader_x86_64_bios_stage_2.3f4927ae6a5f4601-cgu.0.rcgu.o:(function bootloader_x86_64_bios_stage_2::start: .text._RNvCs5qRQZAVXUQf_30bootloader_x86_64_bios_stage_25start+0x251): relocation R_386_16 out of range: 73531 is not in [-32768, 65535]; references section '.bss._RNvNvXNtCs5qRQZAVXUQf_30bootloader_x86_64_bios_stage_24diskNtB4_10DiskAccessNtB4_4Read10read_exact7TMP_BUF'

To address this I made disk_buffer a stack variable instead of static variable because the now large .text region pushed the .bss so much that it didn't fit to the 16bit address range ( the .text precedes the .bss in the stage-2-link.ld file). Another advantage is that this allowed me to remove the unsafe block. I think I was getting some stack corruption when dealing with the references to the static mem region.

This was possibly already fixed by #521/#522.

@jarovo jarovo force-pushed the main branch 2 times, most recently from c74d791 to 951729a Compare May 10, 2026 14:10
jarovo added 2 commits May 10, 2026 16:13
Compiling wiht newest nightly failed this way:

    error: attributes starting with `rustc` are reserved for use by the `rustc` compiler
      --> /home/jhenner/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/rustix-0.37.26/src/backend/linux_raw/io/errno.rs:28:25
       |
    28 | #[cfg_attr(rustc_attrs, rustc_layout_scalar_valid_range_start(0xf001))]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants