1 /* Test program to trigger mcount overflow in profiling collection.
2 Copyright (C) 2017-2024 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <https://www.gnu.org/licenses/>. */
19 /* Program with sufficiently complex, yet pointless, call graph
20 that it will trigger an mcount overflow, when you set the
21 minarcs/maxarcs tunables to very low values. */
23 #define PREVENT_TAIL_CALL asm volatile ("")
25 /* Calls REP(n) macro 16 times, for n=0..15.
26 * You need to define REP(n) before using this.
29 REP(0) REP(1) REP(2) REP(3) REP(4) REP(5) REP(6) REP(7) \
30 REP(8) REP(9) REP(10) REP(11) REP(12) REP(13) REP(14) REP(15)
32 /* Defines 16 leaf functions named f1_0 to f1_15 */
34 __attribute__ ((noinline, noclone, weak)) void f1_##n (void) {};
38 /* Calls all 16 leaf functions f1_* in succession */
39 __attribute__ ((noinline
, noclone
, weak
)) void
42 # define REP(n) f1_##n();
48 /* Defines 16 functions named f2_0 to f2_15, which all just call f2 */
50 __attribute__ ((noinline, noclone, weak)) void \
51 f2_##n (void) { f2(); PREVENT_TAIL_CALL; };
55 __attribute__ ((noinline
, noclone
, weak
)) void
58 for (int i
= 0; i
< count
; ++i
)
60 /* Calls f1_0(), f2_0(), f1_1(), f2_1(), f3_0(), etc */
61 # define REP(n) f1_##n(); f2_##n();