Date: Mon, 07 Sep 2020 09:53:51 +0000 From: bugzilla-noreply@freebsd.org To: bugs@FreeBSD.org Subject: [Bug 249162] Consider passing argc/argv/env to the shared object init function (DT_INIT) for compatibility with glibc Message-ID: <bug-249162-227@https.bugs.freebsd.org/bugzilla/>
index | next in thread | raw e-mail
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=249162 Bug ID: 249162 Summary: Consider passing argc/argv/env to the shared object init function (DT_INIT) for compatibility with glibc Product: Base System Version: Unspecified Hardware: Any OS: Any Status: New Severity: Affects Only Me Priority: --- Component: bin Assignee: bugs@FreeBSD.org Reporter: iwtcex@gmail.com % cat so_init.c #include <stdio.h> void so_init(int argc, char** argv, char** env) { for (int i = 0; i < argc; i++) { printf("arg[%d]: %s\n", i, argv[i]); } } % cc -std=c99 -fPIC -shared -Wl,-init=so_init so_init.c -o test.so % env LD_PRELOAD=$PWD/test.so true 1 2 3 Bus error % /compat/linux/bin/cc -std=c99 -fPIC -shared -Wl,-init=so_init so_init.c -o test.so % env LD_PRELOAD=$PWD/test.so /compat/linux/bin/true 1 2 3 arg[0]: /compat/linux/bin/true arg[1]: 1 arg[2]: 2 arg[3]: 3 Some notes there: 1. relevant glibc code: https://sourceware.org/git/?p=glibc.git;a=blob;f=elf/dl-init.c;h=3e72fa3013a6aaeda05fe61a0ae7af5d46640826;hb=HEAD#l58 ; 2. rtld already does this for functions referenced in DT_INIT_ARRAY, so it's enough to replace a call_initfini_pointer call with call_init_pointer. -- 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-249162-227>
