1 /* $NetBSD: mdprologue.S,v 1.9 1998/09/05 13:08:38 pk Exp $ */
4 * Copyright (c) 1998 The NetBSD Foundation, Inc.
7 * This code is derived from software contributed to The NetBSD Foundation
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
33 * i386 run-time link editor entry points.
36 #include <sys/syscall.h>
39 .globl _binder, _binder_entry
42 * _rtl(int version, struct crt_ldso *crtp)
45 _rtl: # crt0 calls us here
46 pushl %ebp # Allocate stack frame
50 call 1f # PIC function prologue
53 addl $_GLOBAL_OFFSET_TABLE_+[.-1b],%ebx
55 movl 12(%ebp),%eax # Extract data from interface structure
56 movl (%eax),%eax # base address of ld.so (first field)
57 # setup arguments for rtld()
58 movl (%ebx),%ecx # 1st entry in GOT is our __DYNAMIC
59 addl %eax,%ecx # add load address
61 pushl 12(%ebp) # 2nd arg == &crt.
62 pushl 8(%ebp) # 1st arg == version
63 addl _rtld@GOT(%ebx),%eax # relocate address of function
64 call %eax # _rtld(version, crtp, DYNAMIC)
65 addl $12,%esp # pop arguments
68 leave # remove stack frame
71 # First call to a procedure generally comes through here for
75 pushl %ebp # setup a stack frame
79 xorl %eax,%eax # clear
80 movl 4(%ebp),%esi # return address in PLT
81 movw (%esi),%ax # get hold of relocation number
82 subl $6,%esi # make it point to the jmpslot
84 pushl %eax # pushd arguments
86 call _binder@PLT # _binder(rpc, index)
87 addl $8,%esp # pop arguments
88 movl %eax,4(%ebp) # return value from _binder() == actual
91 leave # remove our stack frame