Skip to content

Conversation

@phil-opp
Copy link
Member

We get relocation R_386_16 out of range: 74743 is not in [-32768, 65535] errors with the latest nightlies, as reported in #520. All the failed relocations are from the .start section, referencing the .bss section. This commit fixes these errors by moving the .bss section in between the .start and .text sections so that it is closer to the .start section.

Fixes #520

We get `relocation R_386_16 out of range: 74743 is not in [-32768, 65535]` errors with the latest nightlies, as reported in #520. All the failed relocations are from the `.start` section, referencing the `.bss` section. This commit fixes these errors by moving the `.bss` section in between the `.start` and `.text` sections so that it is closer to the `.start` section.
@phil-opp
Copy link
Member Author

#520 (comment) mentions a second issue:

2. This write call crashes. I'm not sure why. This only seems to be happening on nightly-2025-11-21 and later. It works on nightly-2025-11-20. AFAICT this isn't caused by the fix for the first issue. Shrinking the file size by other means still has this line failing, so I don't think it's the opt-level. Removing write call allows the kernel to boot.

Let's see whether the CI passes.

@Freax13
Copy link
Member

Freax13 commented Nov 27, 2025

All the failed relocations are from the .start section, referencing the .bss section.

Where did you see that? I only see references from .text e.g.

            rust-lld: error: /home/freax13/code/bootloader/target/i386-code16-stage-2/stage-2/deps/bootloader_x86_64_bios_stage_2-836cb229c0ae0c00.bootloader_x86_64_bios_stage_2.23a636a39f56531e-cgu.0.rcgu.o:(function bootloader_x86_64_bios_stage_2::start: .text._RNvCs33L8l6sfb8U_30bootloader_x86_64_bios_stage_25start+0x25a): relocation R_386_16 out of range: 74745 is not in [-32768, 65535]; references section '.bss._RNvNvXNtCs33L8l6sfb8U_30bootloader_x86_64_bios_stage_24diskNtB4_10DiskAccessNtB4_4Read10read_exact7TMP_BUF'
            >>> referenced by bootloader_x86_64_bios_stage_2.23a636a39f56531e-cgu.0

@Freax13
Copy link
Member

Freax13 commented Nov 27, 2025

The "Build examples" job is failing because it's depending on the bootloader crates from crates.io instead of using a path dependency. We can ignore this for this PR.

@phil-opp
Copy link
Member Author

Where did you see that? I only see references from .text e.g.


Yep, you're right! I blindly assumed that the start function in inlined into _start and thus ends up in the .start section. But it looks like this does not happen.

@phil-opp
Copy link
Member Author

The "Build examples" job is failing because it's depending on the bootloader crates from crates.io instead of using a path dependency. We can ignore this for this PR.

Yes, but the Test jobs time out too. I can reproduce this locally, it seems to crash/hang during parsing a RawDirectoryEntry. During my println debugging I noticed that crate::screen::Writer.write_str works fine, but writeln!(crate::screen::Writer, ...) hangs as soon as there is at least one fmt argument.

Without this PR, it works as expected...

@phil-opp
Copy link
Member Author

I opened #522 with alternative approach (keep the linker script unchanged and switch back to legacy mangling).

@phil-opp
Copy link
Member Author

Closing in favor of #522 for now.

@phil-opp phil-opp closed this Nov 27, 2025
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.

Build failure with nightly-2025-11-23

3 participants