From 3db36d6a9b57d4ab8f68e4a31368f8b7bf64167c Mon Sep 17 00:00:00 2001 From: Siva Chandra Date: Fri, 26 May 2023 08:08:46 +0000 Subject: [PATCH] [libc] Initiliaze the global pointer in riscv startup code. Reviewed By: mikhail.ramalho Differential Revision: https://reviews.llvm.org/D151539 --- libc/startup/linux/riscv64/start.cpp | 4 ++++ libc/test/src/stdio/CMakeLists.txt | 1 + 2 files changed, 5 insertions(+) diff --git a/libc/startup/linux/riscv64/start.cpp b/libc/startup/linux/riscv64/start.cpp index 80e7d3f..67aa3e6 100644 --- a/libc/startup/linux/riscv64/start.cpp +++ b/libc/startup/linux/riscv64/start.cpp @@ -123,6 +123,10 @@ struct AuxEntry { }; __attribute__((noinline)) static void do_start() { + LIBC_INLINE_ASM(".option push\n\t" + ".option norelax\n\t" + "lla gp, __global_pointer$\n\t" + ".option pop\n\t"); auto tid = __llvm_libc::syscall_impl(SYS_gettid); if (tid <= 0) __llvm_libc::syscall_impl(SYS_exit, 1); diff --git a/libc/test/src/stdio/CMakeLists.txt b/libc/test/src/stdio/CMakeLists.txt index 19fd494..c138f35 100644 --- a/libc/test/src/stdio/CMakeLists.txt +++ b/libc/test/src/stdio/CMakeLists.txt @@ -114,6 +114,7 @@ add_libc_unittest( add_fp_unittest( sprintf_test + UNIT_TEST_ONLY SUITE libc_stdio_unittests SRCS -- 2.7.4