[PATCH] D98881: [RISCV] Fix mcount name for Linux
Nathan Chancellor via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Mar 18 11:31:10 PDT 2021
nathanchance created this revision.
Herald added subscribers: vkmr, evandro, luismarques, sameer.abuasal, s.egerton, Jim, benna, psnobl, PkmX, rogfer01, shiva0217, kito-cheng, simoncook.
nathanchance requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
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
Signed-off-by: Nathan Chancellor <nathan at kernel.org>
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D98881
Files:
clang/lib/Basic/Targets/OSTargets.h
clang/test/CodeGen/mcount.c
Index: clang/test/CodeGen/mcount.c
===================================================================
--- clang/test/CodeGen/mcount.c
+++ clang/test/CodeGen/mcount.c
@@ -12,6 +12,8 @@
// RUN: %clang_cc1 -pg -triple mipsel-unknown-gnu-linux -emit-llvm -o - %s | FileCheck -check-prefixes=CHECK-PREFIXED,NO-MCOUNT1 %s
// RUN: %clang_cc1 -pg -triple mips64-unknown-gnu-linux -emit-llvm -o - %s | FileCheck -check-prefixes=CHECK-PREFIXED,NO-MCOUNT1 %s
// RUN: %clang_cc1 -pg -triple mips64el-unknown-gnu-linux -emit-llvm -o - %s | FileCheck -check-prefixes=CHECK-PREFIXED,NO-MCOUNT1 %s
+// RUN: %clang_cc1 -pg -triple riscv32-unknown-gnu-linux -emit-llvm -o - %s | FileCheck -check-prefixes=CHECK-PREFIXED,NO-MCOUNT1 %s
+// RUN: %clang_cc1 -pg -triple riscv64-unknown-gnu-linux -emit-llvm -o - %s | FileCheck -check-prefixes=CHECK-PREFIXED,NO-MCOUNT1 %s
// RUN: %clang_cc1 -pg -triple powerpc-netbsd -emit-llvm -o - %s | FileCheck -check-prefixes=CHECK-DOUBLE-PREFIXED,NO-MCOUNT1 %s
// RUN: %clang_cc1 -pg -triple powerpc64-netbsd -emit-llvm -o - %s | FileCheck -check-prefixes=CHECK-DOUBLE-PREFIXED,NO-MCOUNT1 %s
// RUN: %clang_cc1 -pg -triple powerpc64le-netbsd -emit-llvm -o - %s | FileCheck -check-prefixes=CHECK-DOUBLE-PREFIXED,NO-MCOUNT1 %s
Index: clang/lib/Basic/Targets/OSTargets.h
===================================================================
--- clang/lib/Basic/Targets/OSTargets.h
+++ clang/lib/Basic/Targets/OSTargets.h
@@ -417,6 +417,8 @@
case llvm::Triple::ppcle:
case llvm::Triple::ppc64:
case llvm::Triple::ppc64le:
+ case llvm::Triple::riscv32:
+ case llvm::Triple::riscv64:
this->MCountName = "_mcount";
break;
case llvm::Triple::x86:
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D98881.331641.patch
Type: text/x-patch
Size: 1702 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210318/2d01745b/attachment.bin>
More information about the cfe-commits
mailing list