aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjohannst <johannes.stoelp@gmail.com>2021-04-26 21:41:43 +0200
committerjohannst <johannes.stoelp@gmail.com>2021-04-26 21:41:43 +0200
commit96cf3e4ee49c256b214795e30eb66801bcdcef6d (patch)
tree1f4483aa5cd34cdbd8fffcab660f49e120b75d13
parentc7fddba6753757be7def5670d8388e0d20bd4eab (diff)
downloaddynld-96cf3e4ee49c256b214795e30eb66801bcdcef6d.tar.gz
dynld-96cf3e4ee49c256b214795e30eb66801bcdcef6d.zip
Makefile: update comments
-rw-r--r--04_dynld_nostd/Makefile30
1 files changed, 19 insertions, 11 deletions
diff --git a/04_dynld_nostd/Makefile b/04_dynld_nostd/Makefile
index e72dde8..e4dceb1 100644
--- a/04_dynld_nostd/Makefile
+++ b/04_dynld_nostd/Makefile
@@ -7,9 +7,12 @@ COMMON_CFLAGS := -g -O0 -Wall -Wextra \
run: main
./$<
+# Build the example user program.
+#
+# We explicitly set the dynamic linker to `dynld.so` and use the ELF hash table
+# (DT_HASH), as we didn't implement support for the GNU hash table in our
+# dynamic linker.
main: dynld.so libgreet.so main.c ../lib/libcommon.a
- @# For now ew only add support for ELF hash tables (DT_HASH).
- @# Therefore we specify the `hash-style` below.
gcc -o $@ \
$(COMMON_CFLAGS) \
-L$(CURDIR) -lgreet \
@@ -18,20 +21,26 @@ main: dynld.so libgreet.so main.c ../lib/libcommon.a
-no-pie \
$(filter %.c %.a, $^)
- readelf -W --dynamic $@
- readelf -W --program-headers $@
- objdump --disassemble -j .plt -M intel $@
- objdump --disassemble=_start -M intel $@
+ #readelf -W --dynamic $@
+ #readelf -W --program-headers $@
+ #objdump --disassemble -j .plt -M intel $@
+ #objdump --disassemble=_start -M intel $@
+# Build the example shared library.
+#
+# We explicitly use the ELF hash table (DT_HASH), as we didn't implement
+# support for the GNU hash table in our dynamic linker.
libgreet.so: libgreet.c
- @# For now ew only add support for ELF hash tables (DT_HASH).
- @# Therefore we specify the `hash-style` below.
gcc -o $@ \
$(COMMON_CFLAGS) \
-fPIC -shared \
-Wl,--hash-style=sysv \
$^
+# Build the dynamic linker.
+#
+# We assert that the dynamic linker doesn't contain any relocations as we
+# didn't implement support to resolve its own relocations.
dynld.so: dynld.S dynld.c ../lib/libcommon.a
gcc -o $@ \
$(COMMON_CFLAGS) \
@@ -41,9 +50,8 @@ dynld.so: dynld.S dynld.c ../lib/libcommon.a
-Wl,--no-allow-shlib-undefined \
$^
- @if readelf -W -S $@ | grep plt >& /dev/null; then \
- echo "ERROR: $@ contains PLT while we don't support relocation calls in $@!"; \
- echo " All function calls in $@ must be statically resolved!"; \
+ @if ! readelf -r $@ | grep 'There are no relocations in this file' >& /dev/null; then \
+ echo "ERROR: $@ contains relocations while we don't support relocations in $@!"; \
exit 1; \
fi