Lines Matching refs:image

57 find_dt_string(image_t *image, int32 d_tag)
60 elf_dyn *d = (elf_dyn *)image->dynamic_ptr;
64 return STRING(image, d[i].d_un.d_val);
72 find_dt_rpath(image_t *image)
74 return find_dt_string(image, DT_RPATH);
79 find_dt_runpath(image_t *image)
81 return find_dt_string(image, DT_RUNPATH);
86 preload_image(char const* path, image_t **image)
93 status_t status = load_image(path, B_LIBRARY_IMAGE, NULL, NULL, NULL, image);
100 if ((*image)->find_undefined_symbol == NULL)
101 (*image)->find_undefined_symbol = find_undefined_symbol_global;
103 KTRACE("rld: preload_image(\"%s\") done: id: %" B_PRId32, path, (*image)->id);
105 return (*image)->id;
110 preload_images(image_t **image, int32 *_count = NULL)
122 // find begin of image path
129 // find end of image path
140 if (image == NULL) {
147 // load the image
148 preload_image(path, &image[count++]);
159 load_immediate_dependencies(image_t *image, bool preload)
161 elf_dyn *d = (elf_dyn *)image->dynamic_ptr;
166 if (!d || (image->flags & RFLAG_DEPENDENCIES_LOADED))
169 image->flags |= RFLAG_DEPENDENCIES_LOADED;
174 image->num_needed += preloadedCount;
176 if (image->num_needed == 0)
179 KTRACE("rld: load_dependencies(\"%s\", id: %" B_PRId32 ")", image->name,
180 image->id);
182 image->needed = (image_t**)malloc(image->num_needed * sizeof(image_t *));
183 if (image->needed == NULL) {
184 FATAL("%s: Failed to allocate needed struct\n", image->path);
186 ") failed: no memory", image->name, image->id);
190 memset(image->needed, 0, image->num_needed * sizeof(image_t *));
192 preload_images(image->needed);
193 runpath = find_dt_runpath(image);
195 rpath = find_dt_rpath(image);
202 const char *name = STRING(image, neededOffset);
205 rpath, runpath, image->path, &image->needed[j]);
219 ") failed: %s", image->name, image->id,
237 "failed: %s", image->name, image->id,
242 if (j != image->num_needed) {
245 "failed: internal error", image->name, image->id);
250 image->name, image->id);
257 load_dependencies(image_t* image, bool preload = false)
260 for (image_t* otherImage = image; otherImage != NULL;
268 // Check the needed versions for the given image and all newly loaded
270 for (image_t* otherImage = image; otherImage != NULL;
282 relocate_image(image_t *rootImage, image_t *image)
284 SymbolLookupCache cache(image);
286 status_t status = arch_relocate_image(rootImage, image, &cache);
288 FATAL("%s: Troubles relocating: %s\n", image->path, strerror(status));
292 _kern_image_relocated(image->id);
293 image_event(image, IMAGE_EVENT_RELOCATED);
299 relocate_dependencies(image_t *image)
303 ssize_t count = get_sorted_image_list(image, &list, RFLAG_RELOCATED);
309 status_t status = relocate_image(image, list[i]);
322 init_dependencies(image_t *image, bool initHead)
327 if (initHead && image->preinit_array) {
328 uint count_preinit = image->preinit_array_len / sizeof(addr_t);
330 ((initfini_array_function)image->preinit_array[j])();
333 count = get_sorted_image_list(image, &initList, RFLAG_INITIALIZED);
340 // this removes the "calling" image
341 image->flags &= ~RFLAG_INITIALIZED;
347 image = initList[i];
349 TRACE(("%ld: init: %s\n", find_thread(NULL), image->name));
352 if (find_symbol(image,
355 before(image->id);
358 if (image->init_routine != 0)
359 ((init_term_function)image->init_routine)(image->id);
361 if (image->init_array) {
362 uint count_init = image->init_array_len / sizeof(addr_t);
364 ((initfini_array_function)image->init_array[j])();
368 if (find_symbol(image,
371 after(image->id);
374 image_event(image, IMAGE_EVENT_INITIALIZED);
383 call_term_functions(image_t* image)
386 if (find_symbol(image,
389 before(image->id);
392 if (image->term_array) {
393 uint count_term = image->term_array_len / sizeof(addr_t);
395 ((initfini_array_function)image->term_array[i])();
398 if (image->term_routine)
399 ((init_term_function)image->term_routine)(image->id);
402 if (find_symbol(image,
405 after(image->id);
415 image_t* image;
418 SymbolLookupInfo("__gRuntimeLoader", B_SYMBOL_TYPE_DATA), &image,
426 add_preloaded_addon(image_t* image)
436 newArray[sPreloadedAddonCount++] = image;
450 image_t *image = NULL;
451 status_t status = load_image(path, B_LIBRARY_IMAGE, NULL, NULL, NULL, &image);
458 if (image->find_undefined_symbol == NULL)
459 image->find_undefined_symbol = find_undefined_symbol_global;
461 status = load_dependencies(image);
465 set_image_flags_recursively(image, RTLD_GLOBAL);
467 status = relocate_dependencies(image);
471 status = add_preloaded_addon(image);
475 inject_runtime_loader_api(image);
478 init_dependencies(image, true);
480 // if the image contains an add-on, register it
482 if (find_symbol(image,
485 add_add_on(image, addOnStruct);
488 KTRACE("rld: preload_addon(\"%s\") done: id: %" B_PRId32, path, image->id);
490 return image->id;
495 dequeue_loaded_image(image);
496 delete_image(image);
509 // find begin of image path
516 // find end of image path
529 // load the image
542 image_t *image;
580 SymbolLookupInfo("getenv", B_SYMBOL_TYPE_TEXT), &image,
621 image_t *image = NULL;
644 image = find_loaded_image_by_name(path, APP_OR_LIBRARY_TYPE);
645 if (image != NULL && (flags & RTLD_GLOBAL) != 0)
646 set_image_flags_recursively(image, RTLD_GLOBAL);
648 if (image) {
649 atomic_add(&image->ref_count, 1);
651 path, image->id);
652 *_handle = image;
653 return image->id;
656 // First of all, find the caller image.
662 // found the image
674 status = load_image(path, type, rpath, runpath, requestingObjectPath, &image);
681 if (image->find_undefined_symbol == NULL) {
683 image->find_undefined_symbol = find_undefined_symbol_add_on;
685 image->find_undefined_symbol = find_undefined_symbol_global;
688 status = load_dependencies(image);
692 // If specified, set the RTLD_GLOBAL flag recursively on this image and all
697 set_image_flags_recursively(image, RTLD_GLOBAL);
699 set_image_flags_recursively(image, RFLAG_USE_FOR_RESOLVING);
701 status = relocate_dependencies(image);
706 clear_image_flags_recursively(image, RFLAG_USE_FOR_RESOLVING);
709 init_dependencies(image, true);
711 KTRACE("rld: load_library(\"%s\") done: id: %" B_PRId32, path, image->id);
713 *_handle = image;
714 return image->id;
719 dequeue_loaded_image(image);
720 delete_image(image);
728 image_t *image;
741 // After fork, we lazily rebuild the image IDs of all loaded images
750 image = (image_t*)handle;
751 put_image(image);
754 image = find_loaded_image_by_id(imageID, true);
755 if (image != NULL) {
756 // unload image
757 if (type == image->type) {
758 put_image(image);
766 while ((image = get_disposable_images().head) != NULL) {
767 dequeue_disposable_image(image);
769 // Call the exit hooks that live in this image.
773 // termination routine should call __cxa_finalize() for the image.
775 // atexit() aren't associated with the image. We could find out
776 // there which image the hooks lives in and register it
783 image->regions[0].vmstart, image->regions[0].vmsize);
786 image_event(image, IMAGE_EVENT_UNINITIALIZING);
788 call_term_functions(image);
790 TLSBlockTemplates::Get().Unregister(image->dso_tls_id);
792 unmap_image(image);
794 image_event(image, IMAGE_EVENT_UNLOADING);
796 delete_image(image);
810 image_t *image;
814 // get the image from those who have been already initialized
815 image = find_loaded_image_by_id(imageID, false);
816 if (image == NULL)
820 for (i = 0; i < HASHTABSIZE(image); i++) {
821 for (j = HASHBUCKETS(image)[i]; j != STN_UNDEF; j = HASHCHAINS(image)[j]) {
822 elf_sym *symbol = &image->syms[j];
825 const char* symbolName = SYMNAME(image, symbol);
830 + image->regions[0].delta);
840 patch_defined_symbol(image, symbolName, &location, &type);
866 image_t* image = find_loaded_image_by_address((addr_t)address);
867 if (image == NULL)
871 *_imageID = image->id;
873 *_imagePath = image->path;
875 *_imageName = image->name;
877 // If the caller does not want the actual symbol name, only the image,
886 for (uint32 i = 0; i < HASHTABSIZE(image) && !exactMatch; i++) {
887 for (int32 j = HASHBUCKETS(image)[i]; j != STN_UNDEF;
888 j = HASHCHAINS(image)[j]) {
889 elf_sym *symbol = &image->syms[j];
890 addr_t location = symbol->st_value + image->regions[0].delta;
909 *_symbolName = SYMNAME(image, foundSymbol);
938 image_t *image;
957 // get the image from those who have been already initialized
958 image = find_loaded_image_by_id(imageID, false);
959 if (image != NULL) {
961 // breadth-first search in the given image and its dependencies
962 status = find_symbol_breadth_first(image,
965 &image, _location);
967 status = find_symbol(image,
974 *_inImage = image->id;
996 image_t* image;
1001 &image);
1003 *_location = (void*)(symbol->st_value + image->regions[0].delta);
1006 patch_defined_symbol(image, symbolName, _location, &symbolType);
1011 // calling image. Return the next after the caller symbol.
1013 // First of all, find the caller image.
1019 // found the image
1033 image_t* image = get_loaded_images().head;
1034 for (; image != NULL; image = image->next) {
1035 // skip the caller image
1036 if (image == callerImage) {
1041 // skip all images up to the caller image; also skip add-on
1043 if (!hitCallerImage || image->type == B_ADD_ON_IMAGE
1044 || (image->flags
1049 elf_sym *symbol = find_symbol(image,
1059 candidateImage = image;
1081 // breadth-first search in the given image and its dependencies
1098 image_t *image;
1105 image = find_loaded_image_by_id(id, false);
1106 if (image == NULL)
1109 dynamicSection = (elf_dyn *)image->dynamic_ptr;
1110 if (dynamicSection == NULL || image->num_needed <= searchIndex)
1120 *_name = STRING(image, neededOffset);
1184 // After fork, we lazily rebuild the image IDs of all loaded images
1190 image_t *image = termList[i];
1192 TRACE(("%ld: term: %s\n", find_thread(NULL), image->name));
1194 image_event(image, IMAGE_EVENT_UNINITIALIZING);
1196 call_term_functions(image);
1198 image_event(image, IMAGE_EVENT_UNLOADING);