Created
January 12, 2022 23:52
-
-
Save fzakaria/375f2c27f2db000369ec49a684ef8095 to your computer and use it in GitHub Desktop.
musl soname cache discrepancy
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
all: exe | |
# This library depends libx.so soname and calls f() from it | |
b/liby.so: c/libx.so | |
@mkdir -p $(dir $@) | |
echo 'int g() { h(); }' | $(CC) -o $@ -include dlfcn.h -shared -Wl,--no-as-needed -x c - -Lc -lx | |
# This library has both file and soname libx.so | |
c/libx.so: | |
@mkdir -p $(dir $@) | |
echo 'int h(){return 12;}' | $(CC) -o $@ -shared -Wl,-soname,libx.so,--no-as-needed -x c - | |
# This links to b/liby.so and c/libx.so, and gets libx.so and liby.so in DT_NEEDED, no paths. | |
exe: b/liby.so c/libx.so | |
echo 'extern int g(); extern int h(); int main(){ printf("\%d\\n", g() + h()); }' | $(CC) -o $@ -include stdio.h -x c - -Lb -Lc -ly -l:libx.so '-Wl,--no-as-needed,--enable-new-dtags,-rpath,$$ORIGIN/b' | |
patchelf --replace-needed libx.so $(shell pwd)/c/libx.so exe | |
clean: | |
rm -rf -- a b c exe |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment