[libc-commits] [PATCH] D151539: [libc] Initiliaze the global pointer in riscv startup code.

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


sivachandra updated this revision to Diff 537239.
sivachandra added a comment.

Rebase and disable sprintf_test.__hermetic__  as it is failing on riscv.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D151539/new/

https://reviews.llvm.org/D151539

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


Index: libc/test/src/stdio/CMakeLists.txt
===================================================================
--- libc/test/src/stdio/CMakeLists.txt
+++ libc/test/src/stdio/CMakeLists.txt
@@ -114,6 +114,7 @@
 
 add_fp_unittest(
   sprintf_test
+  UNIT_TEST_ONLY
   SUITE
     libc_stdio_unittests
   SRCS
Index: libc/startup/linux/riscv64/start.cpp
===================================================================
--- libc/startup/linux/riscv64/start.cpp
+++ libc/startup/linux/riscv64/start.cpp
@@ -123,6 +123,10 @@
 };
 
 __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);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D151539.537239.patch
Type: text/x-patch
Size: 862 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libc-commits/attachments/20230705/296fbd53/attachment-0001.bin>


More information about the libc-commits mailing list