Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Got "relocation R_X86_64_16 out of range:" error in cargo bootimage #937

Closed
gentlyj opened this issue Mar 6, 2021 · 8 comments · Fixed by rust-osdev/bootloader#139
Closed

Comments

@gentlyj
Copy link

gentlyj commented Mar 6, 2021

I followed the post02 step by step, when I was running cmd : cargo bootimage
I got error log:

 = note: rust-lld: error: bootloader.8xx1g5ts-cgu.1:(.boot+0x6A): relocation R_X86_64_16 out of range: 87040 is not in [-32768, 65535]; references _kernel_start_addr
          >>> defined in /home/yang/share/develop/rust/os_code/blog_os-post-02/target/bootimage/bootloader/x86_64-bootloader/release/deps/libbootloader-040dab97d2aff907.rlib(kernel_bin-blog_os.o)
          
          rust-lld: error: bootloader.8xx1g5ts-cgu.1:(.boot-first-stage+0x81): relocation R_X86_64_16 out of range: 87040 is not in [-32768, 65535]; references _rest_of_bootloader_end_addr
          

error: aborting due to previous error

error: could not compile `bootloader`

Then I clone the code from branch, got the same error, help~~~

@rfrenchy
Copy link

rfrenchy commented Mar 6, 2021

rust-osdev/bootimage#73
i had the same issue and worked-around the same way as w-henderson by downgrading to nightly-2021-03-01

rustup override set nightly-2021-03-01
rustup component add rust-src
rustup component add llvm-tools-preview
cargo bootimage

@phil-opp
Copy link
Owner

phil-opp commented Mar 6, 2021

Thanks a lot for reporting! This is a bug in the bootloader crate which was presumably triggered by the recent update to LLVM 12 on Rust nightly. I'm already looking into it.

@gentlyj
Copy link
Author

gentlyj commented Mar 6, 2021

rustup component add llvm-tools-preview

thanks a lot! it works.

@phil-opp
Copy link
Owner

phil-opp commented Mar 7, 2021

I just published bootloader version 0.9.15. You should be able to fix your errors by running cargo update -p bootloader. Please let me know if there are still problems!

@EvanMu96
Copy link
Contributor

EvanMu96 commented Mar 7, 2021

I just published bootloader version 0.9.15. You should be able to fix your errors by running cargo update -p bootloader. Please let me know if there are still problems!

  • Platform: ubuntu-latest (20.04)
  • rustc version: rustc 1.52.0-nightly (51748a8fc 2021-03-05)
  • LLVM version: 12.0.0
  • Version of bootloader: 0.9.15

It failed on linking.

  = note: rust-lld: error: bootloader.2nb1ae77-cgu.0:(.boot+0x87): relocation R_X86_64_16 out of range: 252624 is not in [-32768, 65535]; references _kernel_size

I am not sure why the ci of bootloader repo works fine...

@phil-opp
Copy link
Owner

phil-opp commented Mar 7, 2021

@EvanMu96 Thanks for checking! It's probably because _kernel_size is much smaller for the test kernel used on the CI, compared to a real kernel. Give me a moment to fix it.

@phil-opp
Copy link
Owner

phil-opp commented Mar 7, 2021

@EvanMu96 I just pushed v0.9.16. Could you try whether this fixes it?

@EvanMu96
Copy link
Contributor

EvanMu96 commented Mar 7, 2021

@EvanMu96 I just pushed v0.9.16. Could you try whether this fixes it?

Fixed. Many thanks!

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 a pull request may close this issue.

4 participants