1//===- x86_64 implementation of the get_start_args_addr function -*- C++ -*===// 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 9%%begin() 10 11namespace __llvm_libc { 12 13__attribute__((always_inline)) inline uintptr_t get_start_args_addr() { 14 // NOTE: For __builtin_frame_address to work reliably across compilers, 15 // architectures and various optimization levels, the TU including this file 16 // should be compiled with -fno-omit-frame-pointer. 17 return reinterpret_cast<uintptr_t>(__builtin_frame_address(0)) + 18 // The x86_64 call instruction pushes resume address on to the stack. 19 // Next, The x86_64 SysV ABI also pushes the frame pointer on the 20 // stack. Hence, we look past these items to get to the start args. 21 sizeof(uintptr_t) * 2; 22} 23 24} // namespace __llvm_libc 25