I was experimenting with a possible implementation of this CR http://bugs.opensolaris.org/view_bug.do?bug_id=6735446
where I would add a small function like this to: http://src.opensolaris.org/source/xref/onnv/onnv-gate/usr/src/lib/libc/port/gen/err.c Here's the function I was trying: /* * This sets __progname at library load time, * before anything can use it. */ #pragma init(set_progname) static void set_progname(void) { char *p; if (__progname == NULL && ___Argv != NULL && (p = ___Argv[0]) != NULL) { if ((p = strrchr(p, '/')) != NULL) p = p + 1; __progname = p; } } Now my surprise is that the libc _init function is apparently not called from crt1.s even though I see a call in there: http://src.opensolaris.org/source/xref/onnv/onnv-gate/usr/src/lib/common/i386/crt1.s but is called _earlier_, by rtld.so call_init, in here: http://src.opensolaris.org/source/xref/onnv/onnv-gate/usr/src/cmd/sgs/rtld/common/setup.c So unfortunately, I don't see how to add some code that would be called by the crt1.s _init call, after ___Argv has been set. Any suggestions? And no, execname is actually not the correct thing to put in __progname. It really is supposed to be argv[0], which may be different from the actual exec'ed program name. Thanks, Gordon