#!/bin/bash echodo() { echo "$*" eval "$*" } echo "## Creating testdll.c source" cat << EOF > testdll.c #include __declspec(dllexport) int test_main(int argc, char **argv) { printf("hello\n"); } EOF echo "## Creating testmain.c source" cat << EOF > testmain.c #include __declspec(dllimport) extern int test_main(int argc, char **argv); main(int argc, char **argv) { test_main(argc,argv); } EOF echo "## Compiling testdll.c -> testdll.o" echodo "gcc -g -c testdll.c" echo "## Creating testdll.dll" echodo "dllwrap -g --export-all-symbols -o testdll.dll testdll.o -lc" echo "## Compiling testmain.c -> testmain.o" echodo "gcc -g -c testmain.c" echo "## Linking testmain.o, testdll.dll -> testmain.exe" echodo "gcc -g -o testmain testmain.o testdll.dll -lc" echo "## Running testmain.exe, should produce 'hello'" echodo "./testmain" echo "## Getting objdump of clean testdll.dll for later perusal" echodo "objdump -a -f -p -x -d -D -S -s -g -e -G -t -T -r -R testdll.dll > testdll.dll.objdump" echo "## Saving clean testdll.dll and objdump" echodo "cp -a testdll.dll testdll.clean.dll" echodo "cp -a testdll.dll.objdump testdll.clean.dll.objdump" echo "## Rebasing testdll.dll" echodo "rebase -v -d -b 0x70000000 -o 0x10000 testdll.dll" echo "## Getting objdump of clean testdll.dll for later perusal" objdump -a -f -p -x -d -D -S -s -g -e -G -t -T -r -R testdll.dll > testdll.dll.objdump echo "## Running testmain.exe, should produce a Windows popup error box" echodo "./testmain"