aboutsummaryrefslogtreecommitdiff
blob: 06e1ed805454dc9014bc27fdc728584ef4287243 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
/* Unwinder test program.

   Copyright (C) 2003-2018 Free Software Foundation, Inc.

   This file is part of GDB.

   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 3 of the License, or
   (at your option) any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */

#ifdef SYMBOL_PREFIX
#define SYMBOL(str)	SYMBOL_PREFIX #str
#else
#define SYMBOL(str)	#str
#endif

void gdb1253 (void);
void gdb1718 (void);
void gdb1338 (void);
void jump_at_beginning (void);
void standard (void);
void stack_align_ecx (void);
void stack_align_edx (void);
void stack_align_eax (void);

int
main (void)
{
  standard ();
  stack_align_ecx ();
  stack_align_edx ();
  stack_align_eax ();
  gdb1253 ();
  gdb1718 ();
  gdb1338 ();
  jump_at_beginning ();
  return 0;
}

/* A normal prologue.  */

asm(".text\n"
    "    .align 8\n"
    SYMBOL (standard) ":\n"
    "    pushl %ebp\n"
    "    movl  %esp, %ebp\n"
    "    pushl %edi\n"
    "    int   $0x03\n"
    "    leave\n"
    "    ret\n");

/* Relevant part of the prologue from symtab/1253.  */

asm(".text\n"
    "    .align 8\n"
    SYMBOL (gdb1253) ":\n"
    "    pushl %ebp\n"
    "    xorl  %ecx, %ecx\n"
    "    movl  %esp, %ebp\n"
    "    pushl %edi\n"
    "    int   $0x03\n"
    "    leave\n"
    "    ret\n");

/* Relevant part of the prologue from backtrace/1718.  */

asm(".text\n"
    "    .align 8\n"
    SYMBOL (gdb1718) ":\n"
    "    pushl %ebp\n"
    "    movl  $0x11111111, %eax\n"
    "    movl  %esp, %ebp\n"
    "    pushl %esi\n"
    "    movl  $0x22222222, %esi\n"
    "    pushl %ebx\n"
    "    int   $0x03\n"
    "    leave\n"
    "    ret\n");

/* Relevant part of the prologue from backtrace/1338.  */

asm(".text\n"
    "    .align 8\n"
    SYMBOL (gdb1338) ":\n"
    "    pushl %edi\n"
    "    pushl %esi\n"
    "    pushl %ebx\n"
    "    int   $0x03\n"
    "    popl  %ebx\n"
    "    popl  %esi\n"
    "    popl  %edi\n"
    "    ret\n");

/* The purpose of this function is to verify that, during prologue
   skip, GDB does not follow a jump at the beginnning of the "real"
   code.  */

asm(".text\n"
    "    .align 8\n"
    SYMBOL (jump_at_beginning) ":\n"
    "    pushl %ebp\n"
    "    movl  %esp,%ebp\n"
    "    jmp   .gdbjump\n"
    "    nop\n"
    ".gdbjump:\n"
    "    movl  %ebp,%esp\n"
    "    popl  %ebp\n"
    "    ret\n");

asm(".text\n"
    "    .align 8\n"
    SYMBOL (stack_align_ecx) ":\n"
    "    leal  4(%esp), %ecx\n"
    "    andl  $-16, %esp\n"
    "    pushl -4(%ecx)\n"
    "    pushl %ebp\n"
    "    movl  %esp, %ebp\n"
    "    pushl %edi\n"
    "    pushl %ecx\n"
    "    int   $0x03\n"
    "    popl  %ecx\n"
    "    popl  %edi\n"
    "    popl  %ebp\n"
    "    leal  -4(%ecx), %esp\n"
    "    ret\n");

asm(".text\n"
    "    .align 8\n"
    SYMBOL (stack_align_edx) ":\n"
    "    leal  4(%esp), %edx\n"
    "    andl  $-16, %esp\n"
    "    pushl -4(%edx)\n"
    "    pushl %ebp\n"
    "    movl  %esp, %ebp\n"
    "    pushl %edi\n"
    "    pushl %ecx\n"
    "    int   $0x03\n"
    "    popl  %ecx\n"
    "    popl  %edi\n"
    "    popl  %ebp\n"
    "    leal  -4(%edx), %esp\n"
    "    ret\n");

asm(".text\n"
    "    .align 8\n"
    SYMBOL (stack_align_eax) ":\n"
    "    leal  4(%esp), %eax\n"
    "    andl  $-16, %esp\n"
    "    pushl -4(%eax)\n"
    "    pushl %ebp\n"
    "    movl  %esp, %ebp\n"
    "    pushl %edi\n"
    "    pushl %ecx\n"
    "    int   $0x03\n"
    "    popl  %ecx\n"
    "    popl  %edi\n"
    "    popl  %ebp\n"
    "    leal  -4(%eax), %esp\n"
    "    ret\n");