xref: /aosp_15_r20/external/elfutils/tests/run-dwarf-ranges.sh (revision 7304104da70ce23c86437a01be71edd1a2d7f37e)
1*7304104dSAndroid Build Coastguard Worker#! /bin/sh
2*7304104dSAndroid Build Coastguard Worker# Copyright (C) 2015, 2018 Red Hat, Inc.
3*7304104dSAndroid Build Coastguard Worker# This file is part of elfutils.
4*7304104dSAndroid Build Coastguard Worker#
5*7304104dSAndroid Build Coastguard Worker# This file is free software; you can redistribute it and/or modify
6*7304104dSAndroid Build Coastguard Worker# it under the terms of the GNU General Public License as published by
7*7304104dSAndroid Build Coastguard Worker# the Free Software Foundation; either version 3 of the License, or
8*7304104dSAndroid Build Coastguard Worker# (at your option) any later version.
9*7304104dSAndroid Build Coastguard Worker#
10*7304104dSAndroid Build Coastguard Worker# elfutils is distributed in the hope that it will be useful, but
11*7304104dSAndroid Build Coastguard Worker# WITHOUT ANY WARRANTY; without even the implied warranty of
12*7304104dSAndroid Build Coastguard Worker# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13*7304104dSAndroid Build Coastguard Worker# GNU General Public License for more details.
14*7304104dSAndroid Build Coastguard Worker#
15*7304104dSAndroid Build Coastguard Worker# You should have received a copy of the GNU General Public License
16*7304104dSAndroid Build Coastguard Worker# along with this program.  If not, see <http://www.gnu.org/licenses/>.
17*7304104dSAndroid Build Coastguard Worker
18*7304104dSAndroid Build Coastguard Worker. $srcdir/test-subr.sh
19*7304104dSAndroid Build Coastguard Worker
20*7304104dSAndroid Build Coastguard Workertestfiles debug-ranges-no-lowpc.o
21*7304104dSAndroid Build Coastguard Worker
22*7304104dSAndroid Build Coastguard Workertestrun_compare ${abs_builddir}/dwarf-ranges debug-ranges-no-lowpc.o 0xb <<\EOF
23*7304104dSAndroid Build Coastguard Worker1..2 (base 0)
24*7304104dSAndroid Build Coastguard Worker3..4 (base 0)
25*7304104dSAndroid Build Coastguard WorkerEOF
26*7304104dSAndroid Build Coastguard Worker
27*7304104dSAndroid Build Coastguard Worker# - hello.c
28*7304104dSAndroid Build Coastguard Worker# int say (const char *prefix);
29*7304104dSAndroid Build Coastguard Worker#
30*7304104dSAndroid Build Coastguard Worker# char *
31*7304104dSAndroid Build Coastguard Worker# subject (char *word, int count)
32*7304104dSAndroid Build Coastguard Worker# {
33*7304104dSAndroid Build Coastguard Worker#    return count > 0 ? word : (word + count);
34*7304104dSAndroid Build Coastguard Worker# }
35*7304104dSAndroid Build Coastguard Worker#
36*7304104dSAndroid Build Coastguard Worker# int
37*7304104dSAndroid Build Coastguard Worker# main (int argc, char **argv)
38*7304104dSAndroid Build Coastguard Worker# {
39*7304104dSAndroid Build Coastguard Worker#    return say (subject (argv[0], argc));
40*7304104dSAndroid Build Coastguard Worker# }
41*7304104dSAndroid Build Coastguard Worker#
42*7304104dSAndroid Build Coastguard Worker# int
43*7304104dSAndroid Build Coastguard Worker# no_say (const char *prefix)
44*7304104dSAndroid Build Coastguard Worker# {
45*7304104dSAndroid Build Coastguard Worker#   const char *world = subject ("World", 42);
46*7304104dSAndroid Build Coastguard Worker#   return prefix ? say (prefix) : say (world);
47*7304104dSAndroid Build Coastguard Worker# }
48*7304104dSAndroid Build Coastguard Worker#
49*7304104dSAndroid Build Coastguard Worker# - world.c
50*7304104dSAndroid Build Coastguard Worker# char * subject (char *word, int count);
51*7304104dSAndroid Build Coastguard Worker# int no_say (const char *prefix);
52*7304104dSAndroid Build Coastguard Worker#
53*7304104dSAndroid Build Coastguard Worker# static int
54*7304104dSAndroid Build Coastguard Worker# sad (char c)
55*7304104dSAndroid Build Coastguard Worker# {
56*7304104dSAndroid Build Coastguard Worker#   return c > 0 ? c : c + 1;
57*7304104dSAndroid Build Coastguard Worker# }
58*7304104dSAndroid Build Coastguard Worker#
59*7304104dSAndroid Build Coastguard Worker# static int
60*7304104dSAndroid Build Coastguard Worker# happy (const char *w)
61*7304104dSAndroid Build Coastguard Worker# {
62*7304104dSAndroid Build Coastguard Worker#   return sad (w[1]);
63*7304104dSAndroid Build Coastguard Worker# }
64*7304104dSAndroid Build Coastguard Worker#
65*7304104dSAndroid Build Coastguard Worker# int
66*7304104dSAndroid Build Coastguard Worker# say (const char *prefix)
67*7304104dSAndroid Build Coastguard Worker# {
68*7304104dSAndroid Build Coastguard Worker#   const char *world = subject ("World", 42);;
69*7304104dSAndroid Build Coastguard Worker#   return prefix ? sad (prefix[0]) : happy (world);
70*7304104dSAndroid Build Coastguard Worker# }
71*7304104dSAndroid Build Coastguard Worker#
72*7304104dSAndroid Build Coastguard Worker# char *
73*7304104dSAndroid Build Coastguard Worker# no_subject (char *word, int count)
74*7304104dSAndroid Build Coastguard Worker# {
75*7304104dSAndroid Build Coastguard Worker#    return count > 0 ? word : (word + count);
76*7304104dSAndroid Build Coastguard Worker# }
77*7304104dSAndroid Build Coastguard Worker#
78*7304104dSAndroid Build Coastguard Worker# int
79*7304104dSAndroid Build Coastguard Worker# no_main (int argc, char **argv)
80*7304104dSAndroid Build Coastguard Worker# {
81*7304104dSAndroid Build Coastguard Worker#    return no_say (no_subject (argv[0], argc));
82*7304104dSAndroid Build Coastguard Worker# }
83*7304104dSAndroid Build Coastguard Worker#
84*7304104dSAndroid Build Coastguard Worker# - gcc -c -O2 -gdwarf-4 hello.c
85*7304104dSAndroid Build Coastguard Worker# - gcc -c -O2 -gdwarf-4 world.c
86*7304104dSAndroid Build Coastguard Worker# - gcc -o testfileranges4 -O2 -gdwarf-4 hello.o world.o
87*7304104dSAndroid Build Coastguard Worker# - eu-strip -f testfileranges4.debug testfileranges4
88*7304104dSAndroid Build Coastguard Worker
89*7304104dSAndroid Build Coastguard Workertestfiles testfileranges4.debug
90*7304104dSAndroid Build Coastguard Workertestrun_compare ${abs_builddir}/dwarf-ranges testfileranges4.debug 0xb <<\EOF
91*7304104dSAndroid Build Coastguard Worker400500..40053a (base 0)
92*7304104dSAndroid Build Coastguard Worker400400..400415 (base 0)
93*7304104dSAndroid Build Coastguard WorkerEOF
94*7304104dSAndroid Build Coastguard Worker
95*7304104dSAndroid Build Coastguard Workertestrun_compare ${abs_builddir}/dwarf-ranges testfileranges4.debug 0xcd <<\EOF
96*7304104dSAndroid Build Coastguard Worker400400..400402 (base 0)
97*7304104dSAndroid Build Coastguard Worker400405..40040d (base 0)
98*7304104dSAndroid Build Coastguard WorkerEOF
99*7304104dSAndroid Build Coastguard Worker
100*7304104dSAndroid Build Coastguard Workertestrun_compare ${abs_builddir}/dwarf-ranges testfileranges4.debug 0x374 <<\EOF
101*7304104dSAndroid Build Coastguard Worker4005a0..4005a2 (base 400540)
102*7304104dSAndroid Build Coastguard Worker4005a5..4005ad (base 400540)
103*7304104dSAndroid Build Coastguard WorkerEOF
104*7304104dSAndroid Build Coastguard Worker
105*7304104dSAndroid Build Coastguard Worker# Like above, but with -gdwarf-5.
106*7304104dSAndroid Build Coastguard Workertestfiles testfileranges5.debug
107*7304104dSAndroid Build Coastguard Workertestrun_compare ${abs_builddir}/dwarf-ranges testfileranges5.debug 0xc <<\EOF
108*7304104dSAndroid Build Coastguard Worker401150..40117a (base 0)
109*7304104dSAndroid Build Coastguard Worker401050..401067 (base 0)
110*7304104dSAndroid Build Coastguard WorkerEOF
111*7304104dSAndroid Build Coastguard Worker
112*7304104dSAndroid Build Coastguard Workertestrun_compare ${abs_builddir}/dwarf-ranges testfileranges5.debug 0x2ce <<\EOF
113*7304104dSAndroid Build Coastguard Worker40119b..40119b (base 401180)
114*7304104dSAndroid Build Coastguard Worker40119c..4011a6 (base 401180)
115*7304104dSAndroid Build Coastguard Worker4011b0..4011b4 (base 401180)
116*7304104dSAndroid Build Coastguard Worker4011b5..4011bf (base 401180)
117*7304104dSAndroid Build Coastguard WorkerEOF
118*7304104dSAndroid Build Coastguard Worker
119*7304104dSAndroid Build Coastguard Workertestrun_compare ${abs_builddir}/dwarf-ranges testfileranges5.debug 0x2ef <<\EOF
120*7304104dSAndroid Build Coastguard Worker40119b..40119b (base 401180)
121*7304104dSAndroid Build Coastguard Worker40119c..4011a6 (base 401180)
122*7304104dSAndroid Build Coastguard Worker4011b4..4011b4 (base 401180)
123*7304104dSAndroid Build Coastguard Worker4011b5..4011bf (base 401180)
124*7304104dSAndroid Build Coastguard WorkerEOF
125*7304104dSAndroid Build Coastguard Worker
126*7304104dSAndroid Build Coastguard Workerexit 0
127