1/* Copyright (c) 2007, Google Inc. 2 * All rights reserved. 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions are 6 * met: 7 * 8 * * Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * * Redistributions in binary form must reproduce the above 11 * copyright notice, this list of conditions and the following disclaimer 12 * in the documentation and/or other materials provided with the 13 * distribution. 14 * * Neither the name of Google Inc. nor the names of its 15 * contributors may be used to endorse or promote products derived from 16 * this software without specific prior written permission. 17 * 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 */ 30 31/* stackwalker_selftest_sol.s 32 * On Solaris, the recommeded compiler is CC, so we can not use gcc inline 33 * asm, use this method instead. 34 * 35 * How to compile: as -P -L -D_ASM -D_STDC -K PIC -o \ 36 * src/processor/stackwalker_selftest_sol.o \ 37 * src/processor/stackwalker_selftest_sol.s 38 * 39 * Author: Michael Shang 40 */ 41 42#include <sys/asm_linkage.h> 43 44#if defined(__i386) 45 46 47ENTRY(GetEBP) 48 pushl %ebp 49 movl %esp,%ebp 50 subl $0x00000004,%esp 51 movl 0x00000000(%ebp),%eax 52 movl %eax,0xfffffffc(%ebp) 53 movl 0xfffffffc(%ebp),%eax 54 leave 55 ret 56SET_SIZE(GetEBP) 57 58ENTRY(GetEIP) 59 pushl %ebp 60 movl %esp,%ebp 61 subl $0x00000004,%esp 62 movl 0x00000004(%ebp),%eax 63 movl %eax,0xfffffffc(%ebp) 64 movl 0xfffffffc(%ebp),%eax 65 leave 66 ret 67SET_SIZE(GetEIP) 68 69ENTRY(GetESP) 70 pushl %ebp 71 movl %esp,%ebp 72 subl $0x00000004,%esp 73 movl %ebp,%eax 74 movl %eax,0xfffffffc(%ebp) 75 movl 0xfffffffc(%ebp),%eax 76 addl $0x00000008,%eax 77 leave 78 ret 79SET_SIZE(GetESP) 80 81 82#elif defined(__sparc) 83 84 85ENTRY(GetPC) 86 save %sp, -120, %sp 87 mov %i7, %i4 88 inccc 8, %i4 89 mov %i4, %i0 90 ret 91 restore 92SET_SIZE(GetPC) 93 94ENTRY(GetSP) 95 save %sp, -120, %sp 96 mov %fp, %i4 97 mov %i4, %i0 98 ret 99 restore 100SET_SIZE(GetSP) 101 102ENTRY(GetFP) 103 save %sp, -120, %sp 104 ld [%fp + 56], %g1 105 mov %g1, %i0 106 ret 107 restore 108SET_SIZE(GetFP) 109 110 111#endif // __i386 || __sparc 112