示例#1
0
void *halide_get_symbol(const char *name) {
    // Try dlsym first. We need to try both RTLD_SELF and
    // RTLD_DEFAULT. Sometimes, RTLD_SELF finds a symbol when
    // RTLD_DEFAULT does not. This is surprising, I *think* RLTD_SELF
    // should search a subset of the symbols searched by
    // RTLD_DEFAULT...
    void *def = dlsym(RTLD_SELF, name);
    if (def) {
        return def;
    }
    def = dlsym(RTLD_DEFAULT, name);
    if (def) {
        return def;
    }
    if (!use_dlopenbuf()) {
        // If we aren't using dlopenbuf, also try mmap_dlsym
        def = mmap_dlsym(RTLD_DEFAULT, name);
        if (def) {
            return def;
        }
    }

    // dlsym has some very unpredictable behavior that makes
    // it randomly unable to find symbols. To mitigate this, check our known symbols mapping.
    return get_known_symbol(name);
}
示例#2
0
handle_t get_symbol(handle_t module_ptr, const char* name, int nameLen, bool use_dlopenbuf) {
    if (use_dlopenbuf) {
        return reinterpret_cast<handle_t>(dlsym(reinterpret_cast<void *>(module_ptr), name));
    } else {
        return reinterpret_cast<handle_t>(mmap_dlsym(reinterpret_cast<void *>(module_ptr), name));
    }
}
示例#3
0
int halide_hexagon_remote_get_symbol_v4(handle_t module_ptr, const char* name, int nameLen, handle_t *sym_ptr) {
    if (use_dlopenbuf()) {
       *sym_ptr = reinterpret_cast<handle_t>(dlsym(reinterpret_cast<void*>(module_ptr), name));
    } else {
        *sym_ptr= reinterpret_cast<handle_t>(mmap_dlsym(reinterpret_cast<void*>(module_ptr), name));
    }
    return *sym_ptr != 0 ? 0 : -1;
}