Blame sysdeps/x86_64/x32/dl-machine.h

Packit 6c4009
/* Machine-dependent ELF dynamic relocation inline functions.  x32 version.
Packit 6c4009
   Copyright (C) 2012-2018 Free Software Foundation, Inc.
Packit 6c4009
   This file is part of the GNU C Library.
Packit 6c4009
Packit 6c4009
   The GNU C Library is free software; you can redistribute it and/or
Packit 6c4009
   modify it under the terms of the GNU Lesser General Public
Packit 6c4009
   License as published by the Free Software Foundation; either
Packit 6c4009
   version 2.1 of the License, or (at your option) any later version.
Packit 6c4009
Packit 6c4009
   The GNU C Library is distributed in the hope that it will be useful,
Packit 6c4009
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 6c4009
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit 6c4009
   Lesser General Public License for more details.
Packit 6c4009
Packit 6c4009
   You should have received a copy of the GNU Lesser General Public
Packit 6c4009
   License along with the GNU C Library; if not, see
Packit 6c4009
   <http://www.gnu.org/licenses/>.  */
Packit 6c4009
Packit 6c4009
/* Must allow <sysdeps/x86_64/dl-machine.h> to be included more than once.
Packit 6c4009
   See #ifdef RESOLVE_MAP in sysdeps/x86_64/dl-machine.h.  */
Packit 6c4009
#include <sysdeps/x86_64/dl-machine.h>
Packit 6c4009
Packit 6c4009
#ifndef _X32_DL_MACHINE_H
Packit 6c4009
#define _X32_DL_MACHINE_H
Packit 6c4009
Packit 6c4009
#undef ARCH_LA_PLTENTER
Packit 6c4009
#undef ARCH_LA_PLTEXIT
Packit 6c4009
#undef RTLD_START
Packit 6c4009
Packit 6c4009
/* Names of the architecture-specific auditing callback functions.  */
Packit 6c4009
#define ARCH_LA_PLTENTER x32_gnu_pltenter
Packit 6c4009
#define ARCH_LA_PLTEXIT x32_gnu_pltexit
Packit 6c4009
Packit 6c4009
/* Initial entry point code for the dynamic linker.
Packit 6c4009
   The C function `_dl_start' is the real entry point;
Packit 6c4009
   its return value is the user program's entry point.  */
Packit 6c4009
#define RTLD_START asm ("\n\
Packit 6c4009
.text\n\
Packit 6c4009
	.p2align 4\n\
Packit 6c4009
.globl _start\n\
Packit 6c4009
.globl _dl_start_user\n\
Packit 6c4009
_start:\n\
Packit 6c4009
	movl %esp, %edi\n\
Packit 6c4009
	call _dl_start\n\
Packit 6c4009
_dl_start_user:\n\
Packit 6c4009
	# Save the user entry point address in %r12.\n\
Packit 6c4009
	movl %eax, %r12d\n\
Packit 6c4009
	# See if we were run as a command with the executable file\n\
Packit 6c4009
	# name as an extra leading argument.\n\
Packit 6c4009
	movl _dl_skip_args(%rip), %eax\n\
Packit 6c4009
	# Pop the original argument count.\n\
Packit 6c4009
	movl (%rsp), %edx\n\
Packit 6c4009
	# Adjust the stack pointer to skip _dl_skip_args words.\n\
Packit 6c4009
	lea 4(%rsp,%rax,4), %esp\n\
Packit 6c4009
	# Subtract _dl_skip_args from argc.\n\
Packit 6c4009
	subl %eax, %edx\n\
Packit 6c4009
	# Push argc back on the stack.\n\
Packit 6c4009
	subl $4, %esp\n\
Packit 6c4009
	movl %edx, (%rsp)\n\
Packit 6c4009
	# Call _dl_init (struct link_map *main_map, int argc, char **argv, char **env)\n\
Packit 6c4009
	# argc -> rsi\n\
Packit 6c4009
	movl %edx, %esi\n\
Packit 6c4009
	# Save %rsp value in %r13.\n\
Packit 6c4009
	movl %esp, %r13d\n\
Packit 6c4009
	# And align stack for the _dl_init call.\n\
Packit 6c4009
	and $-16, %esp\n\
Packit 6c4009
	# _dl_loaded -> rdi\n\
Packit 6c4009
	movl _rtld_local(%rip), %edi\n\
Packit 6c4009
	# env -> rcx\n\
Packit 6c4009
	lea 8(%r13,%rdx,4), %ecx\n\
Packit 6c4009
	# argv -> rdx\n\
Packit 6c4009
	lea 4(%r13), %edx\n\
Packit 6c4009
	# Clear %rbp to mark outermost frame obviously even for constructors.\n\
Packit 6c4009
	xorl %ebp, %ebp\n\
Packit 6c4009
	# Call the function to run the initializers.\n\
Packit 6c4009
	call _dl_init\n\
Packit 6c4009
	# Pass our finalizer function to the user in %rdx, as per ELF ABI.\n\
Packit 6c4009
	lea _dl_fini(%rip), %edx\n\
Packit 6c4009
	# And make sure %rsp points to argc stored on the stack.\n\
Packit 6c4009
	movl %r13d, %esp\n\
Packit 6c4009
	# Jump to the user's entry point.\n\
Packit 6c4009
	jmp *%r12\n\
Packit 6c4009
.previous\n\
Packit 6c4009
");
Packit 6c4009
Packit 6c4009
#endif /* !_X32_DL_MACHINE_H */