[libc++][Android] Allow testing libc++ with clang-r536225 (#116149)
[llvm-project.git] / libc / startup / linux / riscv / start.cpp
blob389f71a66d30ac858f6838fac1d2062868c7c798
1 //===-- Implementation of _start for riscv --------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 #include "src/__support/macros/attributes.h"
9 #include "startup/linux/do_start.h"
11 extern "C" [[noreturn]] void _start() {
12 asm volatile(".option push\n\t"
13 ".option norelax\n\t"
14 "lla gp, __global_pointer$\n\t"
15 ".option pop\n\t");
16 // Fetch the args using the frame pointer.
17 LIBC_NAMESPACE::app.args = reinterpret_cast<LIBC_NAMESPACE::Args *>(
18 reinterpret_cast<uintptr_t *>(__builtin_frame_address(0)));
19 LIBC_NAMESPACE::do_start();