runtime_loader: Combine and correct term function invocations.
In d49942867b (part of hrev52813),
I moved invocation of the TERM_BEFORE/TERM_AFTER functions to
runtime_loader. Unfortunately, I only updated one location where
they should be invoked, and runtime_loader had two.
After this commit, there is one function that they are called from,
which is itself invoked from the appropriate places.
Noted by ttcoder & mmlr in #14047.
This commit is contained in:
@@ -362,6 +362,34 @@ init_dependencies(image_t *image, bool initHead)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
call_term_functions(image_t* image)
|
||||||
|
{
|
||||||
|
init_term_function before;
|
||||||
|
if (find_symbol(image,
|
||||||
|
SymbolLookupInfo(B_TERM_BEFORE_FUNCTION_NAME, B_SYMBOL_TYPE_TEXT),
|
||||||
|
(void**)&before) == B_OK) {
|
||||||
|
before(image->id);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (image->term_array) {
|
||||||
|
uint count_term = image->term_array_len / sizeof(addr_t);
|
||||||
|
for (uint i = count_term; i-- > 0;)
|
||||||
|
((initfini_array_function)image->term_array[i])();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (image->term_routine)
|
||||||
|
((init_term_function)image->term_routine)(image->id);
|
||||||
|
|
||||||
|
init_term_function after;
|
||||||
|
if (find_symbol(image,
|
||||||
|
SymbolLookupInfo(B_TERM_AFTER_FUNCTION_NAME, B_SYMBOL_TYPE_TEXT),
|
||||||
|
(void**)&after) == B_OK) {
|
||||||
|
after(image->id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
inject_runtime_loader_api(image_t* rootImage)
|
inject_runtime_loader_api(image_t* rootImage)
|
||||||
{
|
{
|
||||||
@@ -718,28 +746,7 @@ unload_library(void* handle, image_id imageID, bool addOn)
|
|||||||
|
|
||||||
image_event(image, IMAGE_EVENT_UNINITIALIZING);
|
image_event(image, IMAGE_EVENT_UNINITIALIZING);
|
||||||
|
|
||||||
init_term_function before;
|
call_term_functions(image);
|
||||||
if (find_symbol(image,
|
|
||||||
SymbolLookupInfo(B_TERM_BEFORE_FUNCTION_NAME, B_SYMBOL_TYPE_TEXT),
|
|
||||||
(void**)&before) == B_OK) {
|
|
||||||
before(image->id);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (image->term_array) {
|
|
||||||
uint count_term = image->term_array_len / sizeof(addr_t);
|
|
||||||
for (uint i = count_term; i-- > 0;)
|
|
||||||
((initfini_array_function)image->term_array[i])();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (image->term_routine)
|
|
||||||
((init_term_function)image->term_routine)(image->id);
|
|
||||||
|
|
||||||
init_term_function after;
|
|
||||||
if (find_symbol(image,
|
|
||||||
SymbolLookupInfo(B_TERM_AFTER_FUNCTION_NAME, B_SYMBOL_TYPE_TEXT),
|
|
||||||
(void**)&after) == B_OK) {
|
|
||||||
after(image->id);
|
|
||||||
}
|
|
||||||
|
|
||||||
TLSBlockTemplates::Get().Unregister(image->dso_tls_id);
|
TLSBlockTemplates::Get().Unregister(image->dso_tls_id);
|
||||||
|
|
||||||
@@ -1148,14 +1155,7 @@ terminate_program(void)
|
|||||||
|
|
||||||
image_event(image, IMAGE_EVENT_UNINITIALIZING);
|
image_event(image, IMAGE_EVENT_UNINITIALIZING);
|
||||||
|
|
||||||
if (image->term_array) {
|
call_term_functions(image);
|
||||||
uint count_term = image->term_array_len / sizeof(addr_t);
|
|
||||||
for (uint j = count_term; j-- > 0;)
|
|
||||||
((init_term_function)image->term_array[j])(image->id);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (image->term_routine)
|
|
||||||
((init_term_function)image->term_routine)(image->id);
|
|
||||||
|
|
||||||
image_event(image, IMAGE_EVENT_UNLOADING);
|
image_event(image, IMAGE_EVENT_UNLOADING);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user