static VkResult
anv_physical_device_init_uuids(struct anv_physical_device *device)
{
- const struct build_id_note *note = build_id_find_nhdr("libvulkan_intel.so");
+ const struct build_id_note *note =
+ build_id_find_nhdr_for_addr(anv_physical_device_init_uuids);
if (!note) {
return vk_errorf(device->instance, device,
VK_ERROR_INITIALIZATION_FAILED,
};
struct callback_data {
- const char *filename;
+ /* Base address of shared object, taken from Dl_info::dli_fbase */
+ const void *dli_fbase;
+
struct build_id_note *note;
};
{
struct callback_data *data = data_;
- /* The first object visited by callback is the main program.
- * Android's libc returns a NULL pointer for the first executable.
- */
- if (info->dlpi_name == NULL)
- return 0;
-
- char *ptr = strstr(info->dlpi_name, data->filename);
- if (ptr == NULL || ptr[strlen(data->filename)] != '\0')
+ if ((void *)info->dlpi_addr != data->dli_fbase)
return 0;
for (unsigned i = 0; i < info->dlpi_phnum; i++) {
}
const struct build_id_note *
-build_id_find_nhdr(const char *filename)
+build_id_find_nhdr_for_addr(const void *addr)
{
+ Dl_info info;
+
+ if (!dladdr(addr, &info))
+ return NULL;
+
+ if (!info.dli_fbase)
+ return NULL;
+
struct callback_data data = {
- .filename = filename,
+ .dli_fbase = info.dli_fbase,
.note = NULL,
};
struct build_id_note;
const struct build_id_note *
-build_id_find_nhdr(const char *filename);
+build_id_find_nhdr_for_addr(const void *addr);
unsigned
build_id_length(const struct build_id_note *note);