[Fwd: Re: Add 7 more auxinfo types to support RTLD upgrade]

John Marino dragonflybsd at marino.st
Mon Feb 28 12:59:58 PST 2011


Hi Matt,
I'd like to make another pitch for implementing AT_EXECPATH only, and
leave the other six auxinfo candidates as unimplemented as previously
discussed.
The one-sentence summary is that the fallback mechanism doesn't provide
the same path information as the auxinfo AT_EXECPATH version, and it
affects the functionality of the new libmap.conf and the dynamic rpath
token expansion functionality of the rtld upgrade.
I have improved the fallback mechanism as shown in the attachments
(freebsd version, improved fallback version). This seems to allow the
new DragonFly RTLD to function as expected with libmap.conf and $ORIGIN
token, but it requires the use of getcwd, access, and realpath in order
to do it.  As an example, with AT_EXECPATH implemented, the command "ldd
somefile" to get expanded "/usr/bin/ldd /true/path/to/somefile".
Without AT_EXECPATH implemented it remains as "ldd somefile".  With my
improved fallback, the command gets expanded to "ldd
/true/path/to/somefile".
If vn_fullpath has better performance than 3 combined functions, then
implementing AT_EXECPATH may be worth it for performance reasons.
What do you think?

Regards,
John


Matthew Dillon wrote:
    Ok, I'm going to let Sascha handle this submission too.  I 
    talked with John a bit about it and here is my position:

    * For the sake of making the porting easier I'm O.K. with
      the userland side being implemented, with the exception
      of the PAGESIZES stuff.
    * I am very much <against> implementing any of the kernel side.
      I don't see any point whatsoever in these 'features' other than
      adding unnecessary complexity to the system just to replace
      a few system calls that already only take ~200ns to run or less.
    * Plus we also have our 'resident' utility.  I guess people might
      have forgotten that we have that.  It removes nearly all of the
      overhead of loading a complex dynamically linked program.  We
      don't need these added features in DFly to make things go faster.
    So, in summary, The #define's are ok, but the kernel shouldn't
    implement any of them (no kernel code or in-kernel structural
    changes).  The userland code support is ok, with the exception of
    the PAGESIZES sysctl stuff because I don't think we should implement
    any kernel side support for that, at least not the way they've got
    it setup.
					-Matt


    char buf[MAXPATHLEN];
    if (aux_info[AT_EXECPATH] != 0) {
	char *kexecpath;

	kexecpath = aux_info[AT_EXECPATH]->a_un.a_ptr;
	dbg("AT_EXECPATH %p %s", kexecpath, kexecpath);
	if (kexecpath[0] == '/')
		obj_main->path = kexecpath;
	else if (getcwd(buf, sizeof(buf)) == NULL ||
		strlcat(buf, "/", sizeof(buf)) >= sizeof(buf) ||
		strlcat(buf, kexecpath, sizeof(buf)) >= sizeof(buf))
		obj_main->path = xstrdup(argv0);
	else
		obj_main->path = xstrdup(buf);
    } else {
	char resolved[MAXPATHLEN];
	dbg("No AT_EXECPATH");
	if (argv0[0] == '/') {
		if (realpath(argv0, resolved) != NULL)
			obj_main->path = xstrdup(resolved);
		else
			obj_main->path = xstrdup(argv0);
	} else {
		if (getcwd(buf, sizeof(buf)) != NULL
		    && strlcat(buf, "/", sizeof(buf)) < sizeof(buf)
		    && strlcat(buf, argv0, sizeof (buf)) < sizeof(buf)
		    && access(buf, R_OK) == 0
		    && realpath(buf, resolved) != NULL)
			obj_main->path = xstrdup(resolved);
		else
			obj_main->path = xstrdup(argv0);
	}
    }
    dbg("obj_main path %s", obj_main->path);
    obj_main->mainprog = true;    if (aux_info[AT_EXECPATH] != 0) {
	char *kexecpath;
	char buf[MAXPATHLEN];

	kexecpath = aux_info[AT_EXECPATH]->a_un.a_ptr;
	dbg("AT_EXECPATH %p %s", kexecpath, kexecpath);
	if (kexecpath[0] == '/')
		obj_main->path = kexecpath;
	else if (getcwd(buf, sizeof(buf)) == NULL ||
		strlcat(buf, "/", sizeof(buf)) >= sizeof(buf) ||
		strlcat(buf, kexecpath, sizeof(buf)) >= sizeof(buf))
		obj_main->path = xstrdup(argv0);
	else
		obj_main->path = xstrdup(buf);
    } else {
	dbg("No AT_EXECPATH");
	obj_main->path = xstrdup(argv0);
    }
    dbg("obj_main path %s", obj_main->path);
    obj_main->mainprog = true;





More information about the Submit mailing list