mr4th-dynamic-linking/linux_concrete/build.sh

27 lines
809 B
Bash

#!/bin/bash
# Path setup
src=$PWD
cd ..
mkdir -p build
cd build
#### THE ARRANGEMENT OF THIS BUILD ####
# The "base layer" must be built and shared by all dynamic components.
# In this example the the base layer is linked via load-time linking with the other modules.
# The "plugin" is loaded at run-time.
# Build the base layer as a .so
gcc -fvisibility=hidden -fPIC -shared $src/linux_base.c -o linux_base.so
# Build the executable; provide the base layer's load-time linking data via linux_base.so
gcc -fvisibility=hidden $src/linux_main.c linux_base.so -o linux_main -Wl,-rpath,\$ORIGIN/
# Build the plugin as a .so; provide the base layer's load-time linking data via linux_base.so
gcc -fvisibility=hidden -fPIC -shared $src/linux_plugin.c linux_base.so -o linux_plugin.so -Wl,-rpath,\$ORIGIN/