]>
Commit | Line | Data |
---|---|---|
b811d2c2 | 1 | /* Copyright 2018-2020 Free Software Foundation, Inc. |
450d1e88 KB |
2 | |
3 | This program is free software; you can redistribute it and/or modify | |
4 | it under the terms of the GNU General Public License as published by | |
5 | the Free Software Foundation; either version 3 of the License, or | |
6 | (at your option) any later version. | |
7 | ||
8 | This program is distributed in the hope that it will be useful, | |
9 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
11 | GNU General Public License for more details. | |
12 | ||
13 | You should have received a copy of the GNU General Public License | |
14 | along with this program. If not, see <http://www.gnu.org/licenses/>. */ | |
15 | ||
16 | /* The idea here is to, via use of the dwarf assembler, create a function | |
17 | which occupies two non-contiguous address ranges. | |
18 | ||
5c076da4 | 19 | foo_cold and foo will be combined into a single function foo with a |
450d1e88 KB |
20 | function bar in between these two ranges. |
21 | ||
22 | This test case was motivated by a bug in which a function which | |
23 | occupied two non-contiguous address ranges was calling another | |
24 | function which resides in between these ranges. So we end up with | |
25 | a situation in which the low/start address of our constructed foo | |
26 | (in this case) will be less than any of the addresses in bar, but | |
27 | the high/end address of foo will be greater than any of bar's | |
28 | addresses. | |
29 | ||
30 | This situation was causing a problem in the caching code of | |
31 | find_pc_partial_function: When the low and high addresses of foo | |
32 | are placed in the cache, the simple check that was used to see if | |
33 | the cache was applicable would (incorrectly) succeed when presented | |
34 | with an address in bar. I.e. an address in bar presented as an | |
35 | input to find_pc_partial_function could produce the answer "this | |
36 | address belongs to foo". */ | |
37 | ||
38 | volatile int e = 0; | |
39 | ||
5c076da4 KB |
40 | void bar (void); |
41 | void foo_cold (void); | |
42 | void baz (void); | |
450d1e88 KB |
43 | |
44 | void | |
5c076da4 KB |
45 | foo (void) |
46 | { /* foo prologue */ | |
47 | asm ("foo_label: .globl foo_label"); | |
48 | bar (); /* foo bar call */ | |
49 | asm ("foo_label2: .globl foo_label2"); | |
50 | if (e) foo_cold (); /* foo foo_cold call */ | |
51 | asm ("foo_label3: .globl foo_label3"); | |
52 | } /* foo end */ | |
450d1e88 KB |
53 | |
54 | void | |
55 | bar (void) | |
56 | { | |
57 | asm ("bar_label: .globl bar_label"); | |
58 | } /* bar end */ | |
59 | ||
60 | void | |
5c076da4 KB |
61 | foo_cold (void) |
62 | { /* foo_cold prologue */ | |
63 | asm ("foo_cold_label: .globl foo_cold_label"); | |
64 | baz (); /* foo_cold baz call */ | |
65 | asm ("foo_cold_label2: .globl foo_cold_label2"); | |
66 | } /* foo_cold end */ | |
67 | ||
68 | void | |
69 | baz (void) | |
70 | { | |
71 | asm ("baz_label: .globl baz_label"); | |
72 | } /* baz end */ | |
450d1e88 KB |
73 | |
74 | int | |
75 | main (void) | |
76 | { /* main prologue */ | |
77 | asm ("main_label: .globl main_label"); | |
78 | foo (); /* main foo call */ | |
79 | asm ("main_label2: .globl main_label2"); | |
80 | return 0; /* main return */ | |
81 | } /* main end */ | |
82 |