brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.3 KiB · d0a8526 Raw
25 lines · cpp
1//===-- Implementation of _start for aarch64 ------------------------------===//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 9#include "startup/linux/do_start.h"10extern "C" [[noreturn]] void _start() {11  // Skip the Frame Pointer and the Link Register12  // https://github.com/ARM-software/abi-aa/blob/main/aapcs64/aapcs64.rst13  // Section 6.2.3. Note that this only works if the current function14  // is not using any callee-saved registers (x19 to x28). If the15  // function uses such registers, then their value is pushed on to the16  // stack before the frame pointer an link register values. That breaks17  // the assumption that stepping over the frame pointer and link register18  // will take us to the previous stack pointer. That is the reason why the19  // actual business logic of the startup code is pushed into a non-inline20  // function do_start so that this function is free of any stack usage.21  LIBC_NAMESPACE::app.args = reinterpret_cast<LIBC_NAMESPACE::Args *>(22      reinterpret_cast<uintptr_t *>(__builtin_frame_address(0)) + 2);23  LIBC_NAMESPACE::do_start();24}25