release-1.0 branch:
static int open_library(const char *name)
{
int fd;
char buf[512];
const char **path;
TRACE("[ %5d opening %s ]\n", pid, name);
if(strlen(name) > 256) return -1;
if(name == 0) return -1;
fd = open(name, O_RDONLY);
if(fd != -1) return fd;
for(path = sopaths; *path; path++){
sprintf(buf,"%s/%s", *path, name);
fd = open(buf, O_RDONLY);
if(fd != -1) return fd;
}
return -1;
}
cupcake branch:
/* TODO: Need to add support for initializing the so search path with
* LD_LIBRARY_PATH env variable for non-setuid programs. */
static int open_library(const char *name)
{
int fd;
char buf[512];
const char **path;
TRACE("[ %5d opening %s ]\n", pid, name);
if(name == 0) return -1;
if(strlen(name) > 256) return -1;
if ((name[0] == '/') && ((fd = _open_lib(name)) >= 0))
return fd;
for (path = sopaths; *path; path++) {
snprintf(buf, sizeof(buf), "%s/%s", *path, name);
if ((fd = _open_lib(buf)) >= 0)
return fd;
}
return -1;
}
Summary: Android’s linker used to look in the current working directory to resolve library references. Now it doesn’t. (And it never used LD_LIBRARY_PATH at all) This is really only annoying for 3rd party command line applications which have references to libraries that aren’t part of the standard Android build (and contained in /system/lib). I need to figure out how to make gcc, et al, create binaries that store the full path to the libraries they reference, rather than just the base file name...
Edit: I tried patching it to use LD_LIBRARY_PATH, but calling getenv from within the linker would always return NULL. Not sure why. So I did the next best thing and added “.” to the list of search paths. I think that is default behavior anyways on other Linux based systems (will verify later). Submitted the change, hope it gets accepted.