[libc-commits] [libc] 3db36d6 - [libc] Initiliaze the global pointer in riscv startup code.

Siva Chandra via libc-commits libc-commits at lists.llvm.org
Wed Jul 5 00:32:39 PDT 2023


Author: Siva Chandra
Date: 2023-07-05T07:32:31Z
New Revision: 3db36d6a9b57d4ab8f68e4a31368f8b7bf64167c

URL: https://github.com/llvm/llvm-project/commit/3db36d6a9b57d4ab8f68e4a31368f8b7bf64167c
DIFF: https://github.com/llvm/llvm-project/commit/3db36d6a9b57d4ab8f68e4a31368f8b7bf64167c.diff

LOG: [libc] Initiliaze the global pointer in riscv startup code.

Reviewed By: mikhail.ramalho

Differential Revision: https://reviews.llvm.org/D151539

Added: 
    

Modified: 
    libc/startup/linux/riscv64/start.cpp
    libc/test/src/stdio/CMakeLists.txt

Removed: 
    


################################################################################
diff  --git a/libc/startup/linux/riscv64/start.cpp b/libc/startup/linux/riscv64/start.cpp
index 80e7d3f1bdb3eb..67aa3e6f8772ed 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 19fd4942de74aa..c138f35cb57f4c 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


        


More information about the libc-commits mailing list