@@ -76,8 +76,6 @@ OBJ_CLASS_INSTANCE(mca_patcher_linux_patch_t, mca_patcher_base_patch_t, mca_patc
76
76
mca_patcher_linux_patch_destruct );
77
77
78
78
/* List of patches to be applied to additional libraries */
79
- static bool mca_patcher_linux_dlopen_installed ;
80
- static mca_patcher_linux_patch_t * mca_patcher_linux_dlopen_patch ;
81
79
static void * (* orig_dlopen ) (const char * , int );
82
80
83
81
static const ElfW (Phdr ) *
@@ -401,39 +399,6 @@ static intptr_t mca_patcher_linux_get_orig (const char *symbol, void *replacemen
401
399
return (intptr_t ) func_ptr ;
402
400
}
403
401
404
- /* called with lock held */
405
- static int mca_patcher_linux_install_dlopen (void )
406
- {
407
- int rc ;
408
-
409
- if (mca_patcher_linux_dlopen_installed ) {
410
- return OPAL_SUCCESS ;
411
- }
412
-
413
- orig_dlopen = (void * (* ) (const char * , int )) mca_patcher_linux_get_orig (mca_patcher_linux_dlopen_patch -> super .patch_symbol ,
414
- (void * ) mca_patcher_linux_dlopen_patch -> super .patch_value );
415
-
416
- rc = mca_patcher_base_patch_hook (& mca_patcher_linux_module , mca_patcher_linux_dlopen_patch -> super .patch_value );
417
- if (OPAL_SUCCESS != rc ) {
418
- return rc ;
419
- }
420
-
421
- rc = mca_patcher_linux_apply_patch (mca_patcher_linux_dlopen_patch );
422
- if (OPAL_SUCCESS != rc ) {
423
- return rc ;
424
- }
425
-
426
- mca_patcher_linux_dlopen_installed = true;
427
-
428
- return OPAL_SUCCESS ;
429
- }
430
-
431
- static int mca_patcher_linux_remove_dlopen (void )
432
- {
433
- mca_patcher_linux_dlopen_installed = false;
434
- return mca_patcher_linux_remove_patch (mca_patcher_linux_dlopen_patch );
435
- }
436
-
437
402
static int mca_patcher_linux_patch_symbol (const char * symbol_name , uintptr_t replacement , uintptr_t * orig )
438
403
{
439
404
mca_patcher_linux_patch_t * patch = OBJ_NEW (mca_patcher_linux_patch_t );
@@ -478,46 +443,19 @@ static int mca_patcher_linux_patch_symbol (const char *symbol_name, uintptr_t re
478
443
return rc ;
479
444
}
480
445
481
- static int mca_patcher_linux_init (void )
446
+ /* called with lock held */
447
+ static int mca_patcher_linux_install_dlopen (void )
482
448
{
483
- int rc ;
484
-
485
- mca_patcher_linux_dlopen_patch = OBJ_NEW (mca_patcher_linux_patch_t );
486
- if (NULL == mca_patcher_linux_dlopen_patch ) {
487
- return OPAL_ERR_OUT_OF_RESOURCE ;
488
- }
489
-
490
- mca_patcher_linux_dlopen_patch -> super .patch_symbol = strdup ("dlopen" );
491
- if (NULL == mca_patcher_linux_dlopen_patch -> super .patch_symbol ) {
492
- OBJ_RELEASE (mca_patcher_linux_dlopen_patch );
493
- return OPAL_ERR_OUT_OF_RESOURCE ;
494
- }
495
-
496
- mca_patcher_linux_dlopen_patch -> super .patch_value = mca_patcher_base_addr_text ((intptr_t ) mca_patcher_linux_dlopen );
497
- mca_patcher_linux_dlopen_patch -> super .patch_restore = (mca_patcher_base_restore_fn_t ) mca_patcher_linux_remove_patch ;
498
-
499
- rc = mca_patcher_linux_install_dlopen ();
500
- if (OPAL_SUCCESS != rc ) {
501
- OBJ_RELEASE (mca_patcher_linux_dlopen_patch );
502
- }
503
-
504
- return rc ;
449
+ return mca_patcher_linux_patch_symbol ("dlopen" , (uintptr_t ) mca_patcher_linux_dlopen ,
450
+ (uintptr_t * ) & orig_dlopen );
505
451
}
506
452
507
- static int mca_patcher_linux_fini (void )
453
+ static int mca_patcher_linux_init (void )
508
454
{
509
- int rc = OPAL_SUCCESS ;
510
-
511
- if (mca_patcher_linux_dlopen_patch ) {
512
- rc = mca_patcher_linux_remove_dlopen ();
513
- OBJ_RELEASE (mca_patcher_linux_dlopen_patch );
514
- }
515
-
516
- return rc ;
455
+ return mca_patcher_linux_install_dlopen ();
517
456
}
518
457
519
458
mca_patcher_base_module_t mca_patcher_linux_module = {
520
459
.patch_init = mca_patcher_linux_init ,
521
- .patch_fini = mca_patcher_linux_fini ,
522
460
.patch_symbol = mca_patcher_linux_patch_symbol ,
523
461
};
0 commit comments