Ticket #6427: add-ons-relative-path.patch

File add-ons-relative-path.patch, 1.2 KB (added by phoudoin, 13 years ago)

Search relative-path add-on image in search paths too.

  • runtime_loader.cpp

     
    224224    if (strchr(name, '/')) {
    225225        // the name already contains a path, we don't have to search for it
    226226        fd = _kern_open(-1, name, O_RDONLY, 0);
    227         if (fd >= 0 || type != B_LIBRARY_IMAGE)
     227        if (fd >= 0 || type == B_APP_IMAGE)
    228228            return fd;
    229229
     230        // can't search harder an absolute path add-on name!
     231        if (type == B_ADD_ON_IMAGE && name[0] == '/')
     232            return fd;
     233
    230234        // Even though ELF specs don't say this, we give shared libraries
    231         // another chance and look them up in the usual search paths - at
     235        // and relative path based add-ons another chance and look
     236        // them up in the usual search paths - at
    232237        // least that seems to be what BeOS does, and since it doesn't hurt...
    233         paths = strrchr(name, '/') + 1;
    234         memmove(name, paths, strlen(paths) + 1);
     238        if (type == B_LIBRARY_IMAGE) {
     239            // For library (but not add-on),  strip any path from name
     240            // Relative path of add-on is kept
     241            paths = strrchr(name, '/') + 1;
     242            memmove(name, paths, strlen(paths) + 1);
     243        }
    235244    }
    236245
    237246    // let's evaluate the system path variables to find the container