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

John Baldwin jhb at freebsd.org
Mon Sep 9 17:46:05 UTC 2013


On Saturday, September 07, 2013 7:48:13 am Dag-Erling Smørgrav wrote:
> 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.

I think it would be fine to make it universally available.  You should talk to 
Doug Ambrisko.  He has patches to extend libmap support to key off OS-version, 
etc. and might already make the directory case universal.

-- 
John Baldwin


More information about the freebsd-arch mailing list