diff options
author | johannst <johannes.stoelp@gmail.com> | 2021-03-20 03:16:23 +0100 |
---|---|---|
committer | johannst <johannes.stoelp@gmail.com> | 2021-03-20 03:16:23 +0100 |
commit | 4e871c9dd0418c4f6d33c83fd3338ad261f7dd3f (patch) | |
tree | b86c40b4dc1ad05b92eee8ad76615cf572bbf5b0 /03_hello_dynld/Makefile | |
parent | ef6a411ce8ff615d65e2be105834c2fdbe557de1 (diff) | |
download | dynld-4e871c9dd0418c4f6d33c83fd3338ad261f7dd3f.tar.gz dynld-4e871c9dd0418c4f6d33c83fd3338ad261f7dd3f.zip |
added chapter 03 hello dynld
Diffstat (limited to '03_hello_dynld/Makefile')
-rw-r--r-- | 03_hello_dynld/Makefile | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/03_hello_dynld/Makefile b/03_hello_dynld/Makefile new file mode 100644 index 0000000..5764166 --- /dev/null +++ b/03_hello_dynld/Makefile @@ -0,0 +1,33 @@ +# Copyright (c) 2021 Johannes Stoelp + +COMMON_CFLAGS := -g -O0 -Wall -Wextra \ + -I../lib/include -nostdlib + +run: main + ./$< + +main: dynld.so main.c ../lib/libcommon.a + gcc -o $@ \ + $(COMMON_CFLAGS) \ + -Wl,--dynamic-linker=$(CURDIR)/dynld.so \ + $(filter %.c %.a, $^) + + readelf -W --dynamic $@ + readelf -W --string-dump .interp $@ + readelf -W --program-headers $@ + +dynld.so: dynld.S dynld.c ../lib/libcommon.a + gcc -o $@ \ + $(COMMON_CFLAGS) \ + -fPIC \ + -fvisibility=hidden \ + -Wl,--entry=dl_start \ + -Wl,--no-allow-shlib-undefined \ + $^ + +../lib/libcommon.a: + make -C ../lib + +clean: + rm -f main + rm -f dynld.so |