mr4th-dynamic-linking/clang/build_linux_linking.sh

28 lines
835 B
Bash

#!/bin/bash
# Path setup
cd ../linux_linking
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
clang -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
clang -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
clang -fvisibility=hidden -fPIC -shared $src/linux_plugin.c linux_base.so -o linux_plugin.so -Wl,-rpath,\$ORIGIN/