Cross Reference: rtld_start.S
xref: /src/libexec/ld.elf_so/arch/x86_64/rtld_start.S
  • Home
  • History
  • Annotate
  • Line#
  • Navigate
  • Raw
  • Download
  • only in /src/libexec/ld.elf_so/arch/x86_64/
rtld_start.S revision 1.2
1/*	$NetBSD: rtld_start.S,v 1.2 2001/06/20 17:58:16 fvdl Exp $	*/
2
3#include <machine/asm.h>
4
5	.text
6	.align	16
7	.globl	.rtld_start
8	.type	.rtld_start,@function
9.rtld_start:
10	subq	$16,%rsp		# make room of obj_main and exit proc
11	movq	%rsp,%rdi		# stack pointer arg to _rtld
12	pushq	%rbx			# save ps_strings
13
14	call	_rtld@PLT		# _rtld(sp)
15
16	popq	%rbx			# %rbx = ps_strings
17	popq	%rdx			# %rdx = cleanup
18	popq	%rcx			# %rcx = obj_main
19	jmp	*%rax
20
21	.align	4
22	.globl	_rtld_bind_start
23	.type	_rtld_bind_start,@function
24_rtld_bind_start:	# (obj, reloff)
25	pushfq				# save caller-saved registers
26	pushq	%rax
27	pushq	%rcx
28	pushq	%rdx
29	pushq	%rsi
30	pushq	%rdi
31	pushq	%r8
32	pushq	%r9
33	pushq	%r10
34	pushq	%r11
35
36	movq	80(%rsp),%rdi
37	movq	88(%rsp),%rsi
38	movq	%rsi,%r11		# multiply by sizeof (Elf64_Rela) (24)
39	shlq	$3,%r11
40	shlq	$4,%rsi			# 16 * index + 8 * index = 24 * index
41	addq	%r11,%rsi
42
43	call	_rtld_bind@PLT		# call the binder
44	movq	%rax,88(%rsp)		# store function in obj
45
46	popq	%r11
47	popq	%r10
48	popq	%r9
49	popq	%r8
50	popq	%rdi
51	popq	%rsi
52	popq	%rdx
53	popq	%rcx
54	popq	%rax
55	popfq
56
57	leaq	8(%rsp),%rsp
58
59	ret
60

Indexes created Mon Nov 10 17:20:41 GMT 2025