[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
Fri May 26 01:10:12 PDT 2023
sivachandra created this revision.
sivachandra added a reviewer: mikhail.ramalho.
Herald added subscribers: libc-commits, luke, VincentWu, vkmr, frasercrmck, luismarques, apazos, sameer.abuasal, tschuett, s.egerton, Jim, benna, psnobl, jocewei, PkmX, the_o, brucehoult, MartinMosbeck, rogfer01, edward-jones, zzheng, jrtc27, shiva0217, kito-cheng, niosHD, sabuasal, simoncook, johnrusso, rbar, asb, arichardson.
Herald added projects: libc-project, All.
sivachandra requested review of this revision.
Herald added subscribers: pcwang-thead, eopXD.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D151539
Files:
libc/startup/linux/riscv64/start.cpp
Index: libc/startup/linux/riscv64/start.cpp
===================================================================
--- libc/startup/linux/riscv64/start.cpp
+++ libc/startup/linux/riscv64/start.cpp
@@ -122,7 +122,13 @@
uint64_t value;
};
+extern "C" {
+extern intptr_t __global_pointer$;
+}
+
__attribute__((noinline)) static void do_start() {
+ void *ptr = &__global_pointer$;
+ LIBC_INLINE_ASM("ld gp, %0\n\t" : : "m"(ptr));
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.525970.patch
Type: text/x-patch
Size: 547 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libc-commits/attachments/20230526/e3163c43/attachment.bin>
More information about the libc-commits
mailing list