kernel/eka/euser/epoc/arm/uc_dll.cpp
branchGCC_SURGE
changeset 246 4a60358e2cbf
parent 104 466a0df5c15a
equal deleted inserted replaced
241:973a4e3b29b5 246:4a60358e2cbf
    44 	return 0;
    44 	return 0;
    45 	}
    45 	}
    46 
    46 
    47 #elif defined(__EABI__)
    47 #elif defined(__EABI__)
    48 
    48 
       
    49 #ifdef __GCCE__
       
    50 // Workaround for bug #3560, http://developer.symbian.org/bugs/show_bug.cgi?id=3560
       
    51 static int AddressIsInCodeSegment(void *addr)
       
    52 {
       
    53 	void * code_seg_base;
       
    54 	void * code_seg_limit;
       
    55 	asm(".extern Image$$ER_RO$$Base");
       
    56 	asm(".extern Image$$ER_RO$$Limit");
       
    57 	asm("code_seg_limit:");
       
    58 	asm(".word Image$$ER_RO$$Limit");
       
    59 	asm("code_seg_base:");
       
    60 	asm(".word Image$$ER_RO$$Base");
       
    61 	asm("ldr %[result], code_seg_base" : [result] "=r" (code_seg_base));
       
    62 	asm("ldr %[result], code_seg_limit" : [result] "=r" (code_seg_limit));
       
    63 	return addr >= code_seg_base && addr < code_seg_limit;		
       
    64 }
       
    65 #endif
       
    66 
    49 void __DLL_Export_Table__(void);
    67 void __DLL_Export_Table__(void);
    50 void __cpp_initialize__aeabi_(void);
    68 void __cpp_initialize__aeabi_(void);
    51 __WEAK__ void run_static_dtors(void);
    69 __WEAK__ void run_static_dtors(void);
    52 
    70 
    53 GLDEF_C TInt _E32Dll_Body(TInt aReason)
    71 GLDEF_C TInt _E32Dll_Body(TInt aReason)
    57 		__DLL_Export_Table__();
    75 		__DLL_Export_Table__();
    58 		__cpp_initialize__aeabi_();
    76 		__cpp_initialize__aeabi_();
    59 		}
    77 		}
    60 	else if (aReason==KModuleEntryReasonProcessDetach)
    78 	else if (aReason==KModuleEntryReasonProcessDetach)
    61 		{
    79 		{
       
    80 #if defined(__ARMCC__)
    62 		int call_static_dtors = (int)run_static_dtors;
    81 		int call_static_dtors = (int)run_static_dtors;
    63 		if (call_static_dtors) run_static_dtors();
    82 		if (call_static_dtors) run_static_dtors();
       
    83 #elif defined(__GCCE__)
       
    84 // Workaround for bug #3560, http://developer.symbian.org/bugs/show_bug.cgi?id=3560
       
    85 		if (AddressIsInCodeSegment((void *)run_static_dtors)) run_static_dtors();
       
    86 #else
       
    87 #error What compiler?
       
    88 #endif
    64 		return KErrNone;
    89 		return KErrNone;
    65 		}
    90 		}
    66 	return 0;
    91 	return 0;
    67 	}
    92 	}
    68 
    93