Linker error while linking static library compiled by arm-none-eabi-gcc
gmmyung opened this issue · 1 comments
Hello, I am trying to use a C library compiled with arm-none-eabi-gcc and specs.nosys.
I am trying to link the compiled library into a bare metal rust executable, but I am keep getting the following error:
rust-lld: error:
ERROR(cortex-m-rt): .got section detected in the input object files
Dynamic relocations are not supported. If you are linking to C code compiled using
the 'cc' crate then modify your build script to compile the C code _without_
the -fPIC flag. See the documentation of the `cc::Build.pic` method for details.
I have viewed the CMake invocation in build.rs, but there was no -fPIC flag passed to the compiler. Also, I have inspected the static library using objdump -h, but there were no <.got> or <plt.got> sections. Upon research, I found this thread: https://discourse.llvm.org/t/exceptions-not-working-when-cross-compiling-for-arm-cortex-m4-with-clang-and-precompiled-libraries-from-arm-gnu-gcc-toolchain/59299/6, but I am not so sure if it is related, because the same kind of error shows up when I use arm-none-eabi-ld instead of rust-lld. Are there any suggestions? Any help will be appreciated.
This is resolved. It turns out that it was a weird CMake configuration issue.