]>
Commit | Line | Data |
---|---|---|
b985be81 | 1 | /* Machine-dependent ELF dynamic relocation inline functions. x32 version. |
688903eb | 2 | Copyright (C) 2012-2018 Free Software Foundation, Inc. |
b985be81 L |
3 | This file is part of the GNU C Library. |
4 | ||
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. | |
9 | ||
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. | |
14 | ||
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/>. */ | |
18 | ||
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> | |
22 | ||
23 | #ifndef _X32_DL_MACHINE_H | |
24 | #define _X32_DL_MACHINE_H | |
25 | ||
26 | #undef ARCH_LA_PLTENTER | |
27 | #undef ARCH_LA_PLTEXIT | |
28 | #undef RTLD_START | |
29 | ||
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 | |
33 | ||
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\ | |
38 | .text\n\ | |
39 | .p2align 4\n\ | |
40 | .globl _start\n\ | |
41 | .globl _dl_start_user\n\ | |
42 | _start:\n\ | |
43 | movl %esp, %edi\n\ | |
44 | call _dl_start\n\ | |
45 | _dl_start_user:\n\ | |
46 | # Save the user entry point address in %r12.\n\ | |
47 | movl %eax, %r12d\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\ | |
52 | movl (%rsp), %edx\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\ | |
56 | subl %eax, %edx\n\ | |
57 | # Push argc back on the stack.\n\ | |
58 | subl $4, %esp\n\ | |
59 | movl %edx, (%rsp)\n\ | |
60 | # Call _dl_init (struct link_map *main_map, int argc, char **argv, char **env)\n\ | |
61 | # argc -> rsi\n\ | |
62 | movl %edx, %esi\n\ | |
63 | # Save %rsp value in %r13.\n\ | |
64 | movl %esp, %r13d\n\ | |
c5684fdb | 65 | # And align stack for the _dl_init call.\n\ |
b985be81 L |
66 | and $-16, %esp\n\ |
67 | # _dl_loaded -> rdi\n\ | |
68 | movl _rtld_local(%rip), %edi\n\ | |
69 | # env -> rcx\n\ | |
70 | lea 8(%r13,%rdx,4), %ecx\n\ | |
71 | # argv -> rdx\n\ | |
72 | lea 4(%r13), %edx\n\ | |
73 | # Clear %rbp to mark outermost frame obviously even for constructors.\n\ | |
74 | xorl %ebp, %ebp\n\ | |
75 | # Call the function to run the initializers.\n\ | |
c5684fdb | 76 | call _dl_init\n\ |
b985be81 L |
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\ | |
80 | movl %r13d, %esp\n\ | |
81 | # Jump to the user's entry point.\n\ | |
82 | jmp *%r12\n\ | |
83 | .previous\n\ | |
84 | "); | |
85 | ||
86 | #endif /* !_X32_DL_MACHINE_H */ |