I'm doing some ELF parsing and I need to simulate ld.so
's lookup routine (man ld.so
).
To do that, I need to grab RPATH
as well as RUNPATH
from binaries, so to test my tool
I naturally need to make some binaries with each of those. Here's how you do it.
cat <<EOF > /tmp/a.c
int main(){}
EOF
clang -c /tmp/a.c -o /tmp/a.o
mold --disable-new-dtags --rpath '$ORIGIN' -L/lib64 -lm -o /tmp/a-rpath.out /tmp/a.o
mold --enable-new-dtags --rpath '$ORIGIN' -L/lib64 -lm -o /tmp/a-runpath.out /tmp/a.o
readelf -d /tmp/a*.out