Skip to content

Commit dc4b165

Browse files
hcahcashuahkh
authored andcommitted
selftests/ftrace: Use readelf to find entry point in uprobe test
The uprobe events test fails on s390, but also on x86 (Fedora 41). The problem appears to be that there is an assumption that adding a uprobe to the beginning of the executable mapping of /bin/sh is sufficient to trigger a uprobe event when /bin/sh is executed. This assumption is not necessarily true. Therefore use "readelf -h" to find the entry point address of /bin/sh and use this address when adding the uprobe event. This adds a dependency to readelf which is not always installed. Therefore add a check and exit with exit_unresolved if it is not installed. Link: https://lore.kernel.org/r/20250220130102.2079179-1-hca@linux.ibm.com Signed-off-by: Heiko Carstens <hca@linux.ibm.com> Acked-by: Steven Rostedt (Google) <rostedt@goodmis.org> Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
1 parent e402c70 commit dc4b165

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

tools/testing/selftests/ftrace/test.d/dynevent/add_remove_uprobe.tc

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,18 @@
33
# description: Generic dynamic event - add/remove/test uprobe events
44
# requires: uprobe_events
55

6+
if ! which readelf > /dev/null 2>&1 ; then
7+
echo "No readelf found. skipped."
8+
exit_unresolved
9+
fi
10+
611
echo 0 > events/enable
712
echo > dynamic_events
813

914
REALBIN=`readlink -f /bin/sh`
15+
ENTRYPOINT=`readelf -h ${REALBIN} | grep Entry | sed -e 's/[^0]*//'`
1016

11-
echo 'cat /proc/$$/maps' | /bin/sh | \
12-
grep "r-xp .*${REALBIN}$" | \
13-
awk '{printf "p:myevent %s:0x%s\n", $6,$3 }' >> uprobe_events
17+
echo "p:myevent ${REALBIN}:${ENTRYPOINT}" >> uprobe_events
1418

1519
grep -q myevent uprobe_events
1620
test -d events/uprobes/myevent

0 commit comments

Comments
 (0)