summaryrefslogtreecommitdiff
path: root/tests/07-dynlink-globalvar.test
blob: 227bc91962cd551f881dd49fc5ae096188b64ed4 (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 and global variable.
# 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/putsmainsubglobal \
        --reladd $BUILDDIR/sub_with_global.o \
        --detour sub,sub_with_global \
        --output $BUILDDIR/putsmainsubglobal-with-sub-with-global-detour
test_check_retval

$BUILDDIR/putsmainsubglobal-with-sub-with-global-detour | grep -q "sub_with_global() is returning."
test_check_retval