21 lines · cpp
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-exception6//7//===----------------------------------------------------------------------===//8#include "src/__support/macros/attributes.h"9#include "startup/linux/do_start.h"10 11extern "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();20}21