Created
January 25, 2022 23:53
-
-
Save haampie/ee1be0df1bac929152daab371c72da2d to your computer and use it in GitHub Desktop.
runtime linker
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
all: exef1 exef2 exef3 | |
EI_OSABI:=7 | |
EI_ABIVERSION:=8 | |
EI_PAD:=9 | |
libf1.so: | |
echo 'int f(){ return 1; }' | $(CC) -o $@ -shared -Wl,-soname,$@ -x c - | |
printf '\x0B' | dd of=$@ bs=1 seek=$(EI_OSABI) count=1 conv=notrunc status=none | |
libf2.so: | |
echo 'int f(){ return 2; }' | $(CC) -o $@ -shared -Wl,-soname,$@ -x c - | |
printf '\xff' | dd of=$@ bs=1 seek=$(EI_ABIVERSION) count=1 conv=notrunc status=none | |
libf3.so: | |
echo 'int f(){ return 3; }' | $(CC) -o $@ -shared -Wl,-soname,$@ -x c - | |
printf '\xff' | dd of=$@ bs=1 seek=$(EI_PAD) count=1 conv=notrunc status=none | |
exef1: libf1.so | |
echo 'int f(); int main(){printf("%d\\n", f());}' | $(CC) -include stdio.h -o $@ '-Wl,-rpath,$$ORIGIN' -x c - -L. -lf1 | |
exef2: libf2.so | |
echo 'int f(); int main(){printf("%d\\n", f());}' | $(CC) -include stdio.h -o $@ '-Wl,-rpath,$$ORIGIN' -x c - -L. -lf2 | |
exef3: libf3.so | |
echo 'int f(); int main(){printf("%d\\n", f());}' | $(CC) -include stdio.h -o $@ '-Wl,-rpath,$$ORIGIN' -x c - -L. -lf3 | |
clean: | |
rm -f -- *.so exe* |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment