1 # This file is part of ltrace.
2 # Copyright (C) 2013 Petr Machata, Red Hat Inc.
4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License as
6 # published by the Free Software Foundation; either version 2 of the
7 # License, or (at your option) any later version.
9 # This program is distributed in the hope that it will be useful, but
10 # WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 # General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
19 proc do_tests {bin appendage} {
20 ltraceMatch1 [ltraceRun -e *xyz -- $bin] {xyz\(} == 2
22 # If the actual entry point that xyz resolves to is not traced, it
23 # should get xyz's name. But we don't mind if somebody implements
24 # the late lookup and actually names the symbol properly.
26 set log [ltraceRun -L -x xyz -- $bin]
27 ltraceMatch1 $log [format {xyz\.IFUNC%s\(\)} $appendage] == 1
28 ltraceMatch1 $log [format {(xyz|abc)%s\(} $appendage] == 2
30 # If we request abc's tracing explicitly, than it definitely needs
31 # to be presented as abc, not as xyz.
33 set log [ltraceRun -L -x xyz+abc -- $bin]
34 ltraceMatch1 $log [format {xyz\.IFUNC%s\(\)} $appendage] == 1
35 ltraceMatch1 $log [format {abc%s\(} $appendage] == 2
38 set src [ltraceSource c {
39 int abc (int a) { return a + 1; }
41 __asm__(".type xyz, \%gnu_indirect_function");
44 extern void *xyz_ifunc(void) __asm__("xyz");
45 extern void *xyz_ifunc(void) {
50 main(int argc, char *argv[])
52 return xyz (xyz (argc));
56 foreach ext {{} .pie} {
57 set bin1 [ltraceCompile $ext $src]
61 set lib [ltraceCompile lib.so $src]
63 foreach ext {{} .pie} {
64 set bin2 [ltraceCompile $ext $lib [ltraceSource c {/* Empty. */}]]
65 do_tests $bin2 @lib.so