1 /* Machine-dependent ELF dynamic relocation inline functions. x32 version.
2 Copyright (C) 2012-2018 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
19 /* Must allow <sysdeps/x86_64/dl-machine.h> to be included more than once.
20 See #ifdef RESOLVE_MAP in sysdeps/x86_64/dl-machine.h. */
21 #include <sysdeps/x86_64/dl-machine.h>
23 #ifndef _X32_DL_MACHINE_H
24 #define _X32_DL_MACHINE_H
26 #undef ARCH_LA_PLTENTER
27 #undef ARCH_LA_PLTEXIT
30 /* Names of the architecture-specific auditing callback functions. */
31 #define ARCH_LA_PLTENTER x32_gnu_pltenter
32 #define ARCH_LA_PLTEXIT x32_gnu_pltexit
34 /* Initial entry point code for the dynamic linker.
35 The C function `_dl_start' is the real entry point;
36 its return value is the user program's entry point. */
37 #define RTLD_START asm ("\n\
41 .globl _dl_start_user\n\
46 # Save the user entry point address in %r12.\n\
48 # See if we were run as a command with the executable file\n\
49 # name as an extra leading argument.\n\
50 movl _dl_skip_args(%rip), %eax\n\
51 # Pop the original argument count.\n\
53 # Adjust the stack pointer to skip _dl_skip_args words.\n\
54 lea 4(%rsp,%rax,4), %esp\n\
55 # Subtract _dl_skip_args from argc.\n\
57 # Push argc back on the stack.\n\
60 # Call _dl_init (struct link_map *main_map, int argc, char **argv, char **env)\n\
63 # Save %rsp value in %r13.\n\
65 # And align stack for the _dl_init call.\n\
67 # _dl_loaded -> rdi\n\
68 movl _rtld_local(%rip), %edi\n\
70 lea 8(%r13,%rdx,4), %ecx\n\
73 # Clear %rbp to mark outermost frame obviously even for constructors.\n\
75 # Call the function to run the initializers.\n\
77 # Pass our finalizer function to the user in %rdx, as per ELF ABI.\n\
78 lea _dl_fini(%rip), %edx\n\
79 # And make sure %rsp points to argc stored on the stack.\n\
81 # Jump to the user's entry point.\n\
86 #endif /* !_X32_DL_MACHINE_H */