xref: /aosp_15_r20/external/elfutils/tests/run-dwfl-core-noncontig.sh (revision 7304104da70ce23c86437a01be71edd1a2d7f37e)
1*7304104dSAndroid Build Coastguard Worker#! /bin/sh
2*7304104dSAndroid Build Coastguard Worker# Copyright (C) 2023 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 Worker# Test whether libdwfl can handle corefiles containing non-contiguous
21*7304104dSAndroid Build Coastguard Worker# segments where multiple modules are contained within the address
22*7304104dSAndroid Build Coastguard Worker# space of some other module.
23*7304104dSAndroid Build Coastguard Worker
24*7304104dSAndroid Build Coastguard Worker# testcore-noncontig was generated from the following program with
25*7304104dSAndroid Build Coastguard Worker# systemd-coredump on RHEL 7.9 Workstation, kernel
26*7304104dSAndroid Build Coastguard Worker# 3.10.0-1160.105.1.el7.x86_64. liblgpllibs.so was packaged with
27*7304104dSAndroid Build Coastguard Worker# firefox-115.4.0-1.el7_9.x86_64.rpm.
28*7304104dSAndroid Build Coastguard Worker
29*7304104dSAndroid Build Coastguard Worker# #include <unistd.h>
30*7304104dSAndroid Build Coastguard Worker# #include <dlfcn.h>
31*7304104dSAndroid Build Coastguard Worker#
32*7304104dSAndroid Build Coastguard Worker# int main () {
33*7304104dSAndroid Build Coastguard Worker#   dlopen ("/usr/lib64/firefox/liblgpllibs.so", RTLD_GLOBAL | RTLD_NOW);
34*7304104dSAndroid Build Coastguard Worker#   sleep (60);
35*7304104dSAndroid Build Coastguard Worker#   return 0;
36*7304104dSAndroid Build Coastguard Worker# }
37*7304104dSAndroid Build Coastguard Worker#
38*7304104dSAndroid Build Coastguard Worker# gcc -ldl -o test test.c
39*7304104dSAndroid Build Coastguard Worker
40*7304104dSAndroid Build Coastguard Workertempfiles out
41*7304104dSAndroid Build Coastguard Workertestfiles testcore-noncontig
42*7304104dSAndroid Build Coastguard Worker
43*7304104dSAndroid Build Coastguard Workertestrun ${abs_builddir}/dwfl-core-noncontig testcore-noncontig
44*7304104dSAndroid Build Coastguard Worker
45*7304104dSAndroid Build Coastguard Worker# Remove parts of the output that could change depending on which
46*7304104dSAndroid Build Coastguard Worker# libraries are locally installed.
47*7304104dSAndroid Build Coastguard Workertestrun ${abs_top_builddir}/src/unstrip -n --core testcore-noncontig \
48*7304104dSAndroid Build Coastguard Worker  | sed 's/+/ /g' | cut -d " " -f1,3 | sort > out
49*7304104dSAndroid Build Coastguard Worker
50*7304104dSAndroid Build Coastguard Workertestrun_compare cat out <<\EOF
51*7304104dSAndroid Build Coastguard Worker0x400000 3a1748a544b40a38b3be3d2d13ffa34a2a5a71c0@0x400284
52*7304104dSAndroid Build Coastguard Worker0x7f14e357e000 edf51350c7f71496149d064aa8b1441f786df88a@0x7f14e357e1d8
53*7304104dSAndroid Build Coastguard Worker0x7f14e3794000 7615604eaf4a068dfae5085444d15c0dee93dfbd@0x7f14e37941d8
54*7304104dSAndroid Build Coastguard Worker0x7f14e3a96000 09cfb171310110bc7ea9f4476c9fa044d85baff4@0x7f14e3a96210
55*7304104dSAndroid Build Coastguard Worker0x7f14e3d9e000 e10cc8f2b932fc3daeda22f8dac5ebb969524e5b@0x7f14e3d9e248
56*7304104dSAndroid Build Coastguard Worker0x7f14e3fba000 fc4fa58e47a5acc137eadb7689bce4357c557a96@0x7f14e3fba280
57*7304104dSAndroid Build Coastguard Worker0x7f14e4388000 7f2e9cb0769d7e57bd669b485a74b537b63a57c4@0x7f14e43881d8
58*7304104dSAndroid Build Coastguard Worker0x7f14e458c000 62c449974331341bb08dcce3859560a22af1e172@0x7f14e458c1d8
59*7304104dSAndroid Build Coastguard Worker0x7f14e4795000 175efdcef445455872a86a6fbee7567ca16a513e@0x7f14e4795248
60*7304104dSAndroid Build Coastguard Worker0x7ffcfe59f000 80d79b32785868a2dc10047b39a80d1daec8923d@0x7ffcfe59f328
61*7304104dSAndroid Build Coastguard WorkerEOF
62*7304104dSAndroid Build Coastguard Worker
63*7304104dSAndroid Build Coastguard Workerexit 0
64