1#! /bin/sh
2# Copyright (C) 2005, 2013 Red Hat, Inc.
3# This file is part of elfutils.
4# Written by Ulrich Drepper <drepper@redhat.com>, 2005.
5#
6# This file is free software; you can redistribute it and/or modify
7# it under the terms of the GNU General Public License as published by
8# the Free Software Foundation; either version 3 of the License, or
9# (at your option) any later version.
10#
11# elfutils is distributed in the hope that it will be useful, but
12# WITHOUT ANY WARRANTY; without even the implied warranty of
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14# GNU General Public License for more details.
15#
16# You should have received a copy of the GNU General Public License
17# along with this program.  If not, see <http://www.gnu.org/licenses/>.
18
19. $srcdir/test-subr.sh
20
21testfiles testfile testfile2 testfile8
22
23testrun_compare ${abs_builddir}/allfcts testfile testfile2 testfile8 <<\EOF
24/home/drepper/gnu/new-bu/build/ttt/m.c:5:main
25/home/drepper/gnu/new-bu/build/ttt/b.c:4:bar
26/home/drepper/gnu/new-bu/build/ttt/f.c:3:foo
27/shoggoth/drepper/b.c:4:bar
28/shoggoth/drepper/f.c:3:foo
29/shoggoth/drepper/m.c:5:main
30/home/drepper/gnu/elfutils/build/src/../../src/strip.c:107:main
31/home/drepper/gnu/elfutils/build/src/../../src/strip.c:159:print_version
32/home/drepper/gnu/elfutils/build/src/../../src/strip.c:173:parse_opt
33/home/drepper/gnu/elfutils/build/src/../../src/strip.c:201:more_help
34/home/drepper/gnu/elfutils/build/src/../../src/strip.c:217:process_file
35/usr/include/sys/stat.h:375:stat64
36/home/drepper/gnu/elfutils/build/src/../../src/strip.c:291:crc32_file
37/home/drepper/gnu/elfutils/build/src/../../src/strip.c:313:handle_elf
38EOF
39
40# = nested_funcs.c =
41#
42# static int
43# foo (int x)
44# {
45#   int bar (int y)
46#   {
47#     return x - y;
48#   }
49#
50#   return bar (x * 2);
51# }
52#
53# int
54# main (int argc, char ** argv)
55# {
56#   return foo (argc);
57# }
58#
59# gcc -g -o nested_funcs nested_funcs.c
60
61# = class_func.cxx =
62#
63# namespace foobar
64# {
65#   class Foo
66#   {
67#   public:
68#     int bar(int x);
69#   };
70#
71#   int Foo::bar(int x) { return x - 42; }
72# };
73#
74# int
75# main (int argc, char **argv)
76# {
77#   foobar::Foo foo;
78#
79#   return foo.bar (42);
80# }
81#
82# clang++ -g -o class_func class_func.cxx
83
84testfiles testfile_nested_funcs testfile_class_func
85
86testrun_compare ${abs_builddir}/allfcts testfile_nested_funcs testfile_class_func <<\EOF
87/home/mark/src/tests/nested/nested_funcs.c:2:foo
88/home/mark/src/tests/nested/nested_funcs.c:4:bar
89/home/mark/src/tests/nested/nested_funcs.c:13:main
90/home/mark/src/tests/nested/class_func.cxx:6:bar
91/home/mark/src/tests/nested/class_func.cxx:13:main
92EOF
93
94# = testfile-lto.h =
95# struct t
96# {
97#   int *p;
98#   int c;
99# };
100#
101# extern int foo (int i, struct t *t);
102
103# = testfile-lto-func.c =
104# #include "testfile-lto.h"
105#
106# int
107# foo (int i, struct t *t)
108# {
109#   int j, res = 0;
110#   for (j = 0; j < i && j < t->c; j++)
111#     res += t->p[j];
112#
113#   return res;
114# }
115
116# = testfile-lto-main.c =
117# #include "testfile-lto.h"
118#
119# static struct t g;
120#
121# int
122# main (int argc, char **argv)
123# {
124#   int i;
125#   int j[argc];
126#   g.c = argc;
127#   g.p = j;
128#   for (i = 0; i < argc; i++)
129#     j[i] = (int) argv[i][0];
130#   return foo (3, &g);
131# }
132
133# Using gcc (GCC) 10.0.1 20200430 (Red Hat 10.0.1-0.13)
134# gcc -g -O2 -flto -c testfile-lto-func.c
135# gcc -g -O2 -flto -c testfile-lto-main.c
136# gcc -g -O2 -flto -o testfile-lto-gcc10 testfile-lto-func.o testfile-lto-main.o
137
138testfiles testfile-lto-gcc10
139
140testrun_compare ${abs_builddir}/allfcts testfile-lto-gcc10 <<\EOF
141/home/mark/src/tests/testfile-lto-main.c:6:main
142/home/mark/src/tests/testfile-lto-func.c:4:foo
143/home/mark/src/tests/testfile-lto-main.c:6:main
144EOF
145
146# Using gcc (GCC) 8.3.1 20190311 (Red Hat 8.3.1-3)
147# gcc -g -O2 -flto -c testfile-lto-func.c
148# gcc -g -O2 -flto -c testfile-lto-main.c
149# gcc -g -O2 -flto -o testfile-lto-gcc8 testfile-lto-func.o testfile-lto-main.o
150
151testfiles testfile-lto-gcc8
152
153testrun_compare ${abs_builddir}/allfcts testfile-lto-gcc8 <<\EOF
154/home/mark/src/tests/testfile-lto-func.c:4:foo
155/home/mark/src/tests/testfile-lto-main.c:6:main
156/home/mark/src/tests/testfile-lto-main.c:6:main
157/home/mark/src/tests/testfile-lto-func.c:4:foo
158EOF
159
160# gcc (GCC) 9.1.1 20190605 (Red Hat 9.1.1-2)
161# gcc -g -O2 -flto -c testfile-lto-func.c
162# gcc -g -O2 -flto -c testfile-lto-main.c
163# gcc -g -O2 -flto -o testfile-lto-gcc9 testfile-lto-func.o testfile-lto-main.o
164
165testfiles testfile-lto-gcc9
166
167testrun_compare ${abs_builddir}/allfcts testfile-lto-gcc9 <<\EOF
168/home/mark/src/tests/testfile-lto-main.c:6:main
169/home/mark/src/tests/testfile-lto-func.c:4:foo
170/home/mark/src/tests/testfile-lto-main.c:6:main
171EOF
172
173exit 0
174