rust-embedded / cortex-m

Low level access to Cortex-M processors
Apache License 2.0
832 stars 152 forks source link

rust-lld: warning: section type mismatch for .got #475

Closed Dirbaio closed 7 months ago

Dirbaio commented 1 year ago

Every project using cortex-m-rt gets these linker warnings. I don't know what could cause them, it might be good to investigate if we can get rid of them.

Normally they're not visible (cargo or rustc doesn't show linker output if it's successful). They're only visible when you get an actual real linker error. The linker error gets often printed after these warnings. I've seen them confuse people a few times on Matrix, thinking the warnings are what's causing the linker failure and trying to troubleshoot them.

          rust-lld: warning: section type mismatch for .got
          >>> <internal>:(.got): SHT_PROGBITS
          >>> output section .got: SHT_NOBITS

          rust-lld: warning: section type mismatch for .got.plt
          >>> <internal>:(.got.plt): SHT_PROGBITS
          >>> output section .got: SHT_NOBITS

          rust-lld: warning: section type mismatch for .got
          >>> <internal>:(.got): SHT_PROGBITS
          >>> output section .got: SHT_NOBITS
JosefUtbult commented 1 year ago

I have the same problem when using cortex-m and usb-device.

JosefUtbult commented 1 year ago

I got some help which seems to have solved my problem. Try adding the following feature in Cargo.toml

critical-section-single-core

Dirbaio commented 7 months ago

Rust 1.73 (probably due to the upgrade to llvm 17) has magically fixed this warning for us. It doesn't show up with latest Rust versions anymore.