1 # This file is part of ltrace. 2 # Copyright (C) 2013 Petr Machata, Red Hat Inc. 3 # 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. 8 # 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. 13 # 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 17 # 02110-1301 USA 18 19 proc do_tests {bin appendage} { 20 ltraceMatch1 [ltraceRun -e *xyz -- $bin] {xyz\(} == 2 21 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. 25 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 29 30 # If we request abc's tracing explicitly, than it definitely needs 31 # to be presented as abc, not as xyz. 32 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 36 } 37 38 set src [ltraceSource c { 39 int abc (int a) { return a + 1; } 40 41 __asm__(".type xyz, \%gnu_indirect_function"); 42 43 int xyz (int a); 44 extern void *xyz_ifunc(void) __asm__("xyz"); 45 extern void *xyz_ifunc(void) { 46 return &abc; 47 } 48 49 int 50 main(int argc, char *argv[]) 51 { 52 return xyz (xyz (argc)); 53 } 54 }] 55 56 foreach ext {{} .pie} { 57 set bin1 [ltraceCompile $ext $src] 58 do_tests $bin1 "" 59 } 60 61 set lib [ltraceCompile lib.so $src] 62 63 foreach ext {{} .pie} { 64 set bin2 [ltraceCompile $ext $lib [ltraceSource c {/* Empty. */}]] 65 do_tests $bin2 @lib.so 66 } 67 68 ltraceDone 69