summaryrefslogtreecommitdiff
path: root/tests/05-detour.test
blob: a2d5d0677f7fdcaecb4b075ed2220c7863b62b99 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#!/bin/sh

# 1. Inject a freshly built object file into a fresh executable.
#    Both use a dynamically loaded function.
# 2. Detour execution from a function in the executable to a function
#    originating from the object file.
# 3. Check if the new executable prints the expected changed output.

source ./boilerplate.sh

elfucli --input $BUILDDIR/putsmainsub \
        --reladd $BUILDDIR/puts_noarg.o \
        --detour sub,puts_noarg \
        --output $BUILDDIR/putsmainsub-with-puts-noarg-detour
test_check_retval

$BUILDDIR/putsmainsub-with-puts-noarg-detour | grep -q "puts_noarg() is returning."
test_check_retval