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