From d64f6189c009fe90c83d113ef2870c48d13193e9 Mon Sep 17 00:00:00 2001 From: Ingo Weinhold Date: Thu, 4 Nov 2010 16:22:11 +0000 Subject: [PATCH] unload_library(): Added comment about the exit hook handling. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39299 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/system/runtime_loader/elf.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/system/runtime_loader/elf.cpp b/src/system/runtime_loader/elf.cpp index 907c6a2ad0..e8d8af9657 100644 --- a/src/system/runtime_loader/elf.cpp +++ b/src/system/runtime_loader/elf.cpp @@ -612,7 +612,18 @@ unload_library(void* handle, image_id imageID, bool addOn) if (status == B_OK) { while ((image = get_disposable_images().head) != NULL) { - // call image fini here... + // Call the exit hooks that live in this image. + // Note: With the Itanium ABI this shouldn't really be done this + // way anymore, since global destructors are registered via + // __cxa_atexit() (the ones that are registered dynamically) and the + // termination routine should call __cxa_finalize() for the image. + // The reason why we still do it is that hooks registered with + // atexit() aren't associated with the image. We could find out + // there which image the hooks lives in and register it + // respectively, but since that would be done always, that's + // probably more expensive than calling + // call_atexit_hooks_for_range() only here, which happens only when + // libraries are unloaded dynamically. if (gRuntimeLoader.call_atexit_hooks_for_range) { gRuntimeLoader.call_atexit_hooks_for_range( image->regions[0].vmstart, image->regions[0].vmsize);