--- /dev/null
+#!/bin/sh
+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
SOURCES = $(shell find $(SRCDIR)/ -iname "*.c")
OBJS = $(patsubst $(SRCDIR)/%.c, $(BUILDDIR)/%.o, $(SOURCES))
-EXENAMES = putsmain putsmainsub
+EXENAMES = putsmain putsmainsub putsmainsubglobal
EXES = $(patsubst %, $(BUILDDIR)/%, $(EXENAMES))
CFLAGS = -Wall -pedantic
./runtests.sh
-$(BUILDDIR)/putsmain: $(SRCDIR)/putsmain.c
- @if [ ! -d $(dir $@) ] ; then mkdir -p $(dir $@) ; fi
- gcc $(CFLAGS) -o $@ $^
-
-$(BUILDDIR)/putsmainsub: $(SRCDIR)/putsmainsub.c
+$(BUILDDIR)/%: $(SRCDIR)/%.c
@if [ ! -d $(dir $@) ] ; then mkdir -p $(dir $@) ; fi
gcc $(CFLAGS) -o $@ $^
--- /dev/null
+#include <stdio.h>
+
+void sub_with_global()
+{
+ fprintf(stdout, "sub_with_global() has been reached.\n");
+ fprintf(stdout, "sub_with_global() is returning.\n");
+}