riscvarchive / riscv-linux

RISC-V Linux Port
607 stars 205 forks source link

Asking for help! Error in execution of compiled : $Top/riscv-tools/lib/gcc/riscv64-unknown-elf/7.2.0/../../../../riscv64-unknown-elf/bin/ld:unsupported -shared #134

Closed WX10 closed 6 years ago

kito-cheng commented 6 years ago

It seem like because -shared and -pie support is removed from riscv elf binutils. So that's mean you must use linux toolchain to compile linux kernel.

@palmer-dabbelt @jim-wilson just curious why those option are removed in elf bare-metal toolchain? AArch64 and ARM's elf toolchain seems support -shared and -pie?

WX10 commented 6 years ago

@kito-cheng Thank U very much!According to your answer, I have solved the problem successfully.

jim-wilson commented 6 years ago

RISC-V newlib does not have -shared support. This was causing binutils testsuite failures, as the riscv*-elf toolchain claimed to have shared support, but it did not work. Disabling shared support solved the problem. Most bare metal toolchains have shared support turned off, so this is normal behavior.

Note that linux and bare metal toolchains often have different ABIs. Using an elf toolchain on a linux kernel is risky. You really should use the linux toolchain to ensure that you get the right ABI.