boot_elf.s revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright (c) 1988 AT&T
* All Rights Reserved
*
*
* Copyright 2000-2002 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#if defined(lint)
#include "_rtld.h"
#include "_audit.h"
#include "_elf.h"
/* ARGSUSED0 */
int
{
return (0);
}
#else
#include <link.h>
#include "_audit.h"
.file "boot_elf.s"
.text
/*
* On entry the 'glue code' has already done the following:
*
* pushl %ebp
* movl %esp, %ebp
* pushl dyndata_ptr
* jmp elf_plt_trace
*
* so - -4(%ebp) contains the dyndata ptr
*
* 0x0 uintptr_t reflmp
* 0x4 uintptr_t deflmp
* 0x8 ulong_t symndx
* 0xc ulont_t sb_flags
* 0x10 Elf32_Sym symdef.st_name
* 0x14 symdef.st_value
* 0x18 symdef.st_size
* 0x1c symdef.st_info
* 0x1d symdef.st_other
* 0x1e symdef.st_shndx
*/
#define REFLMP_OFF 0x0
#define DEFLMP_OFF 0x4
#define SYMNDX_OFF 0x8
#define SBFLAGS_OFF 0xc
#define SYMDEF_OFF 0x10
#define SYMDEF_VALUE_OFF 0x14
.align 16
.L1:
/*
* Local stack space storage is allocated as follows:
*
* -4(%ebp) store dyndata ptr
* -8(%ebp) store call destination
* -84(%ebp) space for gregset
* -88(%ebp) prev stack size
* -92(%ebp) entering %eax
* -96(%ebp) entering %ebx
* -100(%ebp) entering %edi
* -104(%ebp) entering %esi
*/
/*
* save all registers into gregset_t
*/
/*
* trapno, err, eip, cs, efl, uesp, ss
*/
/*
* If *no* la_pltexit() routines exist
* we do not need to keep the stack frame
* before we call the actual routine. Instead we
* jump to it and remove our stack from the stack
* at the same time.
*/
/*
* Has the *nopltexit* flag been set for this entry point
*/
/*
* No PLTEXIT processing required.
*/
/*
* At this point, after a little doctoring, we should
* have the following on the stack:
*
* 8(%esp): ret addr
* 4(%esp): dest_addr
* 0(%esp): Previous %ebp
*
* So - we pop the previous %ebp, and then
* ret to our final destination.
*/
/*
* In order to call the destination procedure and then return
* to audit_pltexit() for post analysis we must first grow
* our stack frame and then duplicate the original callers
* stack state. This duplicates all of the arguements
* that were to be passed to the destination procedure.
*/
/*
* If audit_argcnt > 0 then we limit the number of
* arguements that will be duplicated to audit_argcnt.
*
* If (prev_stack_size > (audit_argcnt * 4))
* prev_stack_size = audit_argcnt * 4;
*/
/*
* Grow the stack and duplicate the arguements of the
* original caller.
*/
jmp .while_base / }
/*
* The above stack is now an exact duplicate of
* the stack of the original calling procedure.
*/
/*
* Clean up after ourselves and return to the
* original calling procedure.
*/
#endif
/*
* We got here because a call to a function resolved to a procedure
* linkage table entry. That entry did a JMPL to the first PLT entry, which
* in turn did a call to elf_rtbndr.
*
* the code sequence that got us here was:
*
* PLT entry for foo:
* jmp *name1@GOT(%ebx)
* pushl $rel.plt.foo
* jmp PLT0
*
* 1st PLT entry (PLT0):
* pushl 4(%ebx)
* jmp *8(%ebx)
* nop; nop; nop;nop;
*
*/
#if defined(lint)
void
{
}
#else
.align 4
#endif