Date: Thu, 31 Dec 2020 22:24:17 +0000 From: bugzilla-noreply@freebsd.org To: bugs@FreeBSD.org Subject: [Bug 252307] dlopen (without RTLD_GLOBAL) overrides weak symbols in libc Message-ID: <bug-252307-227-8GPmeCF2ye@https.bugs.freebsd.org/bugzilla/> In-Reply-To: <bug-252307-227@https.bugs.freebsd.org/bugzilla/>
index | next in thread | previous in thread | raw e-mail
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=252307 --- Comment #2 from Alex S <iwtcex@gmail.com> --- > OTOH for malloc(3) related functions, I suspect the decision was deliberate to make it possible to interpose system implementation with any other user provided with LD_PRELOAD. Well, I tested (before filling the bug) whether this works in general and, as expected, it doesn't: % cat weak_sym_override_test2.c #include <assert.h> #include <dlfcn.h> #include <stdlib.h> #include <stdio.h> #if defined(ORIG) void __attribute__((weak)) test() { printf("original\n"); } void wrapper() { test(); } #elif defined(OVERRIDE) void test() { printf("override\n"); } #else extern void wrapper(); int main() { assert(dlopen("override.so", RTLD_NOW) != NULL); wrapper(); return 0; } #endif % cc -shared -fPIC -DORIG weak_sym_override_test2.c -o orig.so % cc -shared -fPIC -DOVERRIDE weak_sym_override_test2.c -o override.so % cc weak_sym_override_test2.c orig.so -Wl,-rpath,. -o test % ./test original Did I miss some compilation flags or something? How do I deliberately get this effect? -- You are receiving this mail because: You are the assignee for the bug.help
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-252307-227-8GPmeCF2ye>
