GCC's name for this symbol is _mcount, which the Linux kernel expects in
a few different place:
$ echo 'int main(void) { return 0; }' | riscv32-linux-gcc -c -pg -o tmp.o -x c - $ llvm-objdump -dr tmp.o | grep mcount 0000000c: R_RISCV_CALL _mcount $ echo 'int main(void) { return 0; }' | riscv64-linux-gcc -c -pg -o tmp.o -x c - $ llvm-objdump -dr tmp.o | grep mcount 000000000000000c: R_RISCV_CALL _mcount $ echo 'int main(void) { return 0; }' | clang -c -pg -o tmp.o --target=riscv32-linux-gnu -x c - $ llvm-objdump -dr tmp.o | grep mcount 0000000a: R_RISCV_CALL_PLT mcount $ echo 'int main(void) { return 0; }' | clang -c -pg -o tmp.o --target=riscv64-linux-gnu -x c - $ llvm-objdump -dr tmp.o | grep mcount 000000000000000a: R_RISCV_CALL_PLT mcount
Set MCountName to "_mcount" in RISCVTargetInfo then prevent it from
getting overridden in certain OSTargetInfo constructors.
No need to test both riscv32 and riscv32-elf. They are the same - generic ELF.