COMPAT_32BIT oddness in rtld-elf (was: Re: /usr/lib/private)

Dag-Erling Smørgrav des at des.no
Sat Sep 7 11:48:41 UTC 2013


I'm having trouble understanding this code in libexec/rtld-elf/rtld.c:

static void *
path_enumerate(const char *path, path_enum_proc callback, void *arg)
{
#ifdef COMPAT_32BIT
    const char *trans;
#endif
    if (path == NULL)
	return (NULL);

    path += strspn(path, ":;");
    while (*path != '\0') {
	size_t len;
	char  *res;

	len = strcspn(path, ":;");
#ifdef COMPAT_32BIT
	trans = lm_findn(NULL, path, len);
	if (trans)
	    res = callback(trans, strlen(trans), arg);
	else
#endif
	res = callback(path, len, arg);

	if (res != NULL)
	    return (res);

	path += len;
	path += strspn(path, ":;");
    }

    return (NULL);
}

This function is used to traverse paths, such as rtld's built-in search
path, LD_LIBRARY_PATH, an Elf object's rpath, etc.  As far as I can
tell, the result of this is that *in the COMPAT_32BIT case only* it is
possible to list one directory as replacing another in libmap.conf.  In
other words, we could have this in libmap32.conf:

/lib                    /lib32
/usr/lib                /usr/lib32
/usr/lib/private        /usr/lib32/private

instead of hardcoding a different standard search path in rtld.h.

What I don't understand is why this functionality is only available in
the COMPAT_32BIT case.  It seems universally useful to me.

DES
-- 
Dag-Erling Smørgrav - des at des.no


More information about the freebsd-arch mailing list