1) Revised fix for Bug 2975 - [GCCE] Illegal inline assembler in kernel/eka/drivers/debug/rmdebug/d_rmd_stepping.cpp. GCC_SURGE
authormikek
Tue, 15 Jun 2010 19:10:20 +0100
branchGCC_SURGE
changeset 156 12b6722e7753
parent 155 e28362b72ccc
child 157 72699c76850a
1) Revised fix for Bug 2975 - [GCCE] Illegal inline assembler in kernel/eka/drivers/debug/rmdebug/d_rmd_stepping.cpp. Should have conditionally different code for __ARMCC__ and __GCCE_ 2) Fix for Bug 2976 - [GCCE] Overlapping naked function bodies break exception-handling. 3) Fix an incidental "impossible constraint in asm" gripe.
kernel/eka/common/arm/carray.cia
kernel/eka/compsupp/gcce/gcce.h
kernel/eka/compsupp/rvct.h
kernel/eka/compsupp/rvct2_1/rvct2_1.h
kernel/eka/drivers/debug/rmdebug/d_rmd_stepping.cpp
kernel/eka/kernel/arm/ckernel.cia
--- a/kernel/eka/common/arm/carray.cia	Tue Jun 15 15:02:48 2010 +0100
+++ b/kernel/eka/common/arm/carray.cia	Tue Jun 15 19:10:20 2010 +0100
@@ -82,6 +82,7 @@
 
 EXPORT_C __NAKED__ TInt RPointerArrayBase::Find(const TAny* /*anEntry*/, TGeneralIdentityRelation /*anIdentity*/) const
 	{
+	__EH_FNSTART
 	asm("stmfd sp!, {r4-r8,lr} ");
 	__EH_FRAME_PUSH2(r4-r8,lr)
 	asm("ldmia r0, {r4,r5} ");			// r4=iCount, r5=iEntries
@@ -103,16 +104,17 @@
 	asm("ptr_find2_return: ");			// return r6
 	asm("mov r0, r6 ");
 	__POPRET("r4-r8,");
+	__EH_FNEND
 	}
 
-EXPORT_C __NAKED__ TInt RPointerArrayBase::BinarySearchSigned(TInt /*anEntry*/, TInt& /*anIndex*/) const
+EXPORT_C TInt RPointerArrayBase::BinarySearchSigned(TInt anEntry, TInt& anIndex) const
 	{
-	asm("mov r3, #0 ");
-	// fall through
+	return RPointerArrayBase::BinarySearchSigned(anEntry, anIndex, 0);
 	}
 
 EXPORT_C __NAKED__ TInt RPointerArrayBase::BinarySearchSigned(TInt /*anEntry*/, TInt& /*anIndex*/, TInt /*aMode*/) const
 	{
+	__EH_FNSTART
 	asm("stmfd sp!, {r4-r6,lr} ");
 	__EH_FRAME_PUSH2(r4-r6,lr)
 	asm("mov r6, r2 ");					// r6=&anIndex
@@ -160,16 +162,17 @@
 	asm("bne 3b ");						// if not, V=0 (left from subs), N=1 for last, 0 for first, Z=0 => LAST->LT FIRST->GT
 	asm("mov r2, r12 ");				// if so, r2 = mid
 	__JUMP(,lr);						// and return with r0 = 0
+	__EH_FNEND
 	}
 
-EXPORT_C __NAKED__ TInt RPointerArrayBase::BinarySearchUnsigned(TUint /*anEntry*/, TInt& /*anIndex*/) const
+EXPORT_C TInt RPointerArrayBase::BinarySearchUnsigned(TUint anEntry, TInt& anIndex) const
 	{
-	asm("mov r3, #0 ");
-	// fall through
+	return RPointerArrayBase::BinarySearchUnsigned(anEntry, anIndex, 0);
 	}
 
 EXPORT_C __NAKED__ TInt RPointerArrayBase::BinarySearchUnsigned(TUint /*anEntry*/, TInt& /*anIndex*/, TInt /*aMode*/) const
 	{
+	__EH_FNSTART
 	asm("stmfd sp!, {r4-r6,lr} ");
 	__EH_FRAME_PUSH2(r4-r6,lr)
 	asm("mov r6, r2 ");					// r6=&anIndex
@@ -218,10 +221,12 @@
 	asm("bne 3b ");						// if not ANY, branch back
 	asm("mov r2, r12 ");				// if ANY, r2 = mid
 	__JUMP(,lr);						// and return with r0 = 0
+	__EH_FNEND
 	}
 
 EXPORT_C __NAKED__ TInt RPointerArrayBase::BinarySearch(const TAny* /*anEntry*/, TInt& /*anIndex*/, TGeneralLinearOrder /*anOrder*/, TInt /*aMode*/) const
 	{
+	__EH_FNSTART
 	asm("stmfd sp!, {r2,r4-r11,lr} ");	// store &anIndex, r4-r11, lr
 	__EH_FRAME_ADDRESS(sp,4)
 	__EH_FRAME_PUSH2(r4-r11,lr)
@@ -282,16 +287,17 @@
 	asm("2: ");
 	asm("mov r5, r8 ");					// if ANY, r8 = mid
 	__JUMP(,r9);						// and return with r0 = 0, Z=1
+	__EH_FNEND
 	}
 
-EXPORT_C __NAKED__ TInt RPointerArrayBase::FindIsqSigned(TInt /*anEntry*/) const
+EXPORT_C TInt RPointerArrayBase::FindIsqSigned(TInt anEntry) const
 	{
-	asm("mov r2, #0 ");
-	// fall through
+	return RPointerArrayBase::FindIsqSigned(anEntry, 0);
 	}
 
 EXPORT_C __NAKED__ TInt RPointerArrayBase::FindIsqSigned(TInt /*anEntry*/, TInt /*aMode*/) const
 	{
+	__EH_FNSTART
 #ifdef __EABI__
 	// sp needs correct alignment
 	asm("stmfd sp!, {r4-r6,lr} ");
@@ -308,16 +314,17 @@
 #else
 	__POPRET("r4,r5,");
 #endif
+	__EH_FNEND
 	}
 
-EXPORT_C __NAKED__ TInt RPointerArrayBase::FindIsqUnsigned(TUint /*anEntry*/) const
+EXPORT_C TInt RPointerArrayBase::FindIsqUnsigned(TUint anEntry) const
 	{
-	asm("mov r2, #0 ");
-	// fall through
+	return RPointerArrayBase::FindIsqUnsigned(anEntry, 0);
 	}
 
 EXPORT_C __NAKED__ TInt RPointerArrayBase::FindIsqUnsigned(TUint /*anEntry*/, TInt /*aMode*/) const
 	{
+	__EH_FNSTART
 #ifdef __EABI__
 	// sp needs correct alignment
 	asm("stmfd sp!, {r4-r6,lr} ");
@@ -334,17 +341,17 @@
 #else
 	__POPRET("r4,r5,");
 #endif
+	__EH_FNEND
 	}
 
-EXPORT_C __NAKED__ TInt RPointerArrayBase::FindIsq(const TAny* /*anEntry*/, TGeneralLinearOrder /*anOrder*/) const
+EXPORT_C TInt RPointerArrayBase::FindIsq(const TAny* anEntry, TGeneralLinearOrder anOrder) const
 	{
-	asm("mov r3, #0 ");
-	// fall through
+	return RPointerArrayBase::FindIsq(anEntry, anOrder, 0);
 	}
 
 EXPORT_C __NAKED__ TInt RPointerArrayBase::FindIsq(const TAny* /*anEntry*/, TGeneralLinearOrder /*anOrder*/, TInt /*aMode*/) const
 	{
-
+	__EH_FNSTART
 	asm("stmfd sp!, {r3-r11,lr} ");
 	__EH_FRAME_PUSH2(r4-r6,lr)
 	asm("ldmia r0, {r5,r6} ");			// r5=count, r6=iEntries
@@ -354,11 +361,13 @@
 	asm("bl BinarySearchPointers ");
 	asm("moveq r0, r5 ");				// if match, r0=match index
 	__POPRET("r3-r11,");
+	__EH_FNEND
 	}
 
 #ifndef __KERNEL_MODE__
 EXPORT_C __NAKED__ void RPointerArrayBase::HeapSortSigned()
 	{
+	__EH_FNSTART
 #ifdef __EABI__
 	asm("stmfd sp!, {r4-r10,lr} ");
 	__EH_FRAME_PUSH2(r4-r10,lr)
@@ -420,6 +429,7 @@
 	asm("bgt hss_loop_start2 ");
 	asm("str r7, [r5, #0] ");
 	__JUMP(,lr);
+	__EH_FNEND
 	}
 
 EXPORT_C __NAKED__ void RPointerArrayBase::HeapSortUnsigned()
@@ -492,6 +502,7 @@
 #ifndef __KERNEL_MODE__
 EXPORT_C __NAKED__ void RPointerArrayBase::HeapSort(TGeneralLinearOrder /*anOrder*/)
 	{
+	__EH_FNSTART
 	asm("stmfd sp!, {r3-r11,lr} ");
 	// r3 is caller save
 	__EH_FRAME_ADDRESS(sp,4)
@@ -553,6 +564,7 @@
 	asm("bgt hsp_loop_start2 ");
 	asm("str r7, [r5, #0] ");
 	__JUMP(,r11);
+	__EH_FNEND
 	}
 #endif	// __KERNEL_MODE__
 
@@ -623,6 +635,7 @@
 
 EXPORT_C __NAKED__ TInt RArrayBase::Find(const TAny* /*anEntry*/, TGeneralIdentityRelation /*anIdentity*/) const
 	{
+	__EH_FNSTART
 	asm("stmfd sp!, {r4-r10,lr} ");		// save r4-r10,lr
 	__EH_FRAME_PUSH2(r4-r10,lr)
 	asm("ldmia r0, {r4,r5,r6} ");		// r4=count, r5=iEntries, r6=iEntrySize
@@ -644,16 +657,17 @@
 	asm("simple_find2_return: ");
 	asm("sub r0, r7, r4 ");				// index=count-r4
 	__POPRET("r4-r10,");
+	__EH_FNEND
 	}
 
-EXPORT_C __NAKED__ TInt RArrayBase::BinarySearchSigned(const TAny* /*anEntry*/, TInt& /*anIndex*/) const
+EXPORT_C TInt RArrayBase::BinarySearchSigned(const TAny* anEntry, TInt& anIndex) const
 	{
-	asm("mov r3, #0 ");
-	// fall through
+	return RArrayBase::BinarySearchSigned(anEntry, anIndex, 0);
 	}
 
 EXPORT_C __NAKED__ TInt RArrayBase::BinarySearchSigned(const TAny* /*anEntry*/, TInt& /*anIndex*/, TInt /*aMode*/) const
 	{
+	__EH_FNSTART
 	asm("stmfd sp!, {r4-r8,lr} ");
 	__EH_FRAME_PUSH2(r4-r8,lr)
 	asm("mov r8, r2 ");					// r8=&anIndex
@@ -709,16 +723,17 @@
 	asm("bne 3b ");						// if not, V=0 (left from subs), N=1 for last, 0 for first, Z=0 => LAST->LT FIRST->GT
 	asm("mov r2, r12 ");				// if so, r2 = mid
 	__JUMP(,lr);						// and return with r0 = 0
+	__EH_FNEND
 	}
 
-EXPORT_C __NAKED__ TInt RArrayBase::BinarySearchUnsigned(const TAny* /*anEntry*/, TInt& /*anIndex*/) const
+EXPORT_C TInt RArrayBase::BinarySearchUnsigned(const TAny* anEntry, TInt& anIndex) const
 	{
-	asm("mov r3, #0 ");
-	// fall through
+	return RArrayBase::BinarySearchUnsigned(anEntry, anIndex, 0);
 	}
 
 EXPORT_C __NAKED__ TInt RArrayBase::BinarySearchUnsigned(const TAny* /*anEntry*/, TInt& /*anIndex*/, TInt /*aMode*/) const
 	{
+	__EH_FNSTART
 	asm("stmfd sp!, {r4-r8,lr} ");
 	__EH_FRAME_PUSH2(r4-r8,lr)
 	asm("mov r8, r2 ");					// r8=&anIndex
@@ -775,10 +790,12 @@
 	asm("bne 3b ");						// if not ANY, branch back
 	asm("mov r2, r12 ");				// if ANY, r2 = mid
 	__JUMP(,lr);						// and return with r0 = 0
+	__EH_FNEND
 	}
 
 EXPORT_C __NAKED__ TInt RArrayBase::BinarySearch(const TAny* /*anEntry*/, TInt& /*anIndex*/, TGeneralLinearOrder /*anOrder*/, TInt /*aMode*/) const
 	{
+	__EH_FNSTART
 	asm("stmfd sp!, {r3-r11,lr} ");
 	// r3 is caller save
 	__EH_FRAME_ADDRESS(sp,4)
@@ -836,16 +853,17 @@
 	asm("2: ");
 	asm("mov r5, r8 ");					// if ANY, r8 = mid
 	__POPRET("r2,");					// and return with r0 = 0, Z=1
+	__EH_FNEND
 	}
 
-EXPORT_C __NAKED__ TInt RArrayBase::FindIsqSigned(const TAny* /*anEntry*/) const
+EXPORT_C TInt RArrayBase::FindIsqSigned(const TAny* anEntry) const
 	{
-	asm("mov r2, #0 ");
-	// fall through
+	return RArrayBase::FindIsqSigned(anEntry, 0);
 	}
 
 EXPORT_C __NAKED__ TInt RArrayBase::FindIsqSigned(const TAny* /*anEntry*/, TInt /*aMode*/) const
 	{
+	__EH_FNSTART
 #ifdef __EABI__
 	// sp needs to be aligned correctly
 	asm("stmfd sp!, {r4-r8,lr} ");
@@ -869,16 +887,17 @@
 #else
 	__POPRET("r4-r7,");
 #endif
+	__EH_FNEND
 	}
 
-EXPORT_C __NAKED__ TInt RArrayBase::FindIsqUnsigned(const TAny* /*anEntry*/) const
+EXPORT_C TInt RArrayBase::FindIsqUnsigned(const TAny* anEntry) const
 	{
-	asm("mov r2, #0 ");
-	// fall through
+	return RArrayBase::FindIsqUnsigned(anEntry, 0);
 	}
 
 EXPORT_C __NAKED__ TInt RArrayBase::FindIsqUnsigned(const TAny* /*anEntry*/, TInt /*aMode*/) const
 	{
+	__EH_FNSTART
 #ifdef __EABI__
 	// sp needs to be aligned correctly
 	asm("stmfd sp!, {r4-r8,lr} ");
@@ -902,16 +921,17 @@
 #else
 	__POPRET("r4-r7,");
 #endif
+	__EH_FNEND
 	}
 
-EXPORT_C __NAKED__ TInt RArrayBase::FindIsq(const TAny* /*anEntry*/, TGeneralLinearOrder /*anOrder*/) const
+EXPORT_C TInt RArrayBase::FindIsq(const TAny* anEntry, TGeneralLinearOrder anOrder) const
 	{
-	asm("mov r3, #0 ");
-	// fall through
+	return RArrayBase::FindIsq(anEntry, anOrder, 0);
 	}
 
 EXPORT_C __NAKED__ TInt RArrayBase::FindIsq(const TAny* /*anEntry*/, TGeneralLinearOrder /*anOrder*/, TInt /*aMode*/) const
 	{
+	__EH_FNSTART
 	asm("stmfd sp!, {r3-r11,lr} ");
 	// r3 is caller save
 	__EH_FRAME_ADDRESS(sp,4)
@@ -924,11 +944,13 @@
 	asm("bl BinarySearchEntries ");
 	asm("moveq r0, r5 ");				// if match r0=index
 	__POPRET("r3-r11,");
+	__EH_FNEND
 	}
 
 #ifndef __KERNEL_MODE__
 EXPORT_C __NAKED__ void RArrayBase::HeapSortSigned()
 	{
+	__EH_FNSTART
 #ifdef __EABI__
 	// need sp aligned correctly
 	asm("stmfd sp!, {r3-r11,lr} ");
@@ -1017,10 +1039,12 @@
 	asm("bl wordmove ");				// entry[0]=[sp]
 	asm("add sp, sp, r10 ");			// free temporary stack space
 	__JUMP(,r7);
+	__EH_FNEND
 	}
 
 EXPORT_C __NAKED__ void RArrayBase::HeapSortUnsigned()
 	{
+	__EH_FNSTART
 #ifdef __EABI__
 	// need sp aligned correctly
 	asm("stmfd sp!, {r3-r11,lr} ");
@@ -1109,10 +1133,12 @@
 	asm("bl wordmove ");				// entry[0]=[sp]
 	asm("add sp, sp, r10 ");			// free temporary stack space
 	__JUMP(,r7);
+	__EH_FNEND
 	}
 
 EXPORT_C __NAKED__ void RArrayBase::HeapSort(TGeneralLinearOrder anOrder)
 	{
+	__EH_FNSTART
 #ifdef __EABI__
 	// need sp aligned correctly
 	asm("stmfd sp!, {r3-r11,lr} ");
@@ -1204,6 +1230,7 @@
 	asm("bl wordmove ");				// entry[0]=[sp]
 	asm("ldr sp, [sp, r10] ");			// restore stack pointer, freeing temporary stack space
 	__POPRET("");
+	__EH_FNEND
 	}
 #endif	// __KERNEL_MODE__
 #endif	// __ARRAY_MACHINE_CODED__
--- a/kernel/eka/compsupp/gcce/gcce.h	Tue Jun 15 15:02:48 2010 +0100
+++ b/kernel/eka/compsupp/gcce/gcce.h	Tue Jun 15 19:10:20 2010 +0100
@@ -184,5 +184,8 @@
 	__EH_FRAME_ADDRESS(fp,offset) \
 	__ASM_GAS_SAVE_REG(reg)
 
+#define __EH_FNSTART asm(".fnstart");
+#define __EH_FNEND asm(".fnend");
+
 #endif
 
--- a/kernel/eka/compsupp/rvct.h	Tue Jun 15 15:02:48 2010 +0100
+++ b/kernel/eka/compsupp/rvct.h	Tue Jun 15 19:10:20 2010 +0100
@@ -176,5 +176,9 @@
     #define	__EH_FRAME_ADDRESS(reg,offset)  FRAME ADDRESS reg, offset
     #define __EH_FRAME_PUSH2(reg1,reg2)     FRAME PUSH {reg1, reg2}
     #define __EH_FRAME_SAVE1(reg,offset)    FRAME SAVE {reg}, offset
+
+	#define __EH_FNSTART
+	#define __EH_FNEND
+
 #endif
 
--- a/kernel/eka/compsupp/rvct2_1/rvct2_1.h	Tue Jun 15 15:02:48 2010 +0100
+++ b/kernel/eka/compsupp/rvct2_1/rvct2_1.h	Tue Jun 15 19:10:20 2010 +0100
@@ -191,4 +191,7 @@
 #define __EH_FRAME_PUSH2(reg1,reg2) FRAME PUSH {reg1, reg2}
 #define __EH_FRAME_SAVE1(reg,offset) FRAME SAVE {reg}, offset
 
+#define __EH_FNSTART
+#define __EH_FNEND
+
 #endif
--- a/kernel/eka/drivers/debug/rmdebug/d_rmd_stepping.cpp	Tue Jun 15 15:02:48 2010 +0100
+++ b/kernel/eka/drivers/debug/rmdebug/d_rmd_stepping.cpp	Tue Jun 15 19:10:20 2010 +0100
@@ -325,7 +325,13 @@
 
 	// determine the architecture
 	TUint32 cpuid;
+#if defined(__ARMCC__)
+	asm("mrc p15, 0, cpuid, c0, c0, 0 ");
+#elif defined(__GCCE__)
 	asm("mrc p15, 0, %[id], c0, c0, 0 " : [id] "=r" (cpuid));
+#else
+#error What compiler?
+#endif
 	LOG_MSG2("DRMDStepping::PCAfterInstructionExecutes() - cpuid = 0x%08x\n",cpuid);
 
 	cpuid >>= 8;
--- a/kernel/eka/kernel/arm/ckernel.cia	Tue Jun 15 15:02:48 2010 +0100
+++ b/kernel/eka/kernel/arm/ckernel.cia	Tue Jun 15 19:10:20 2010 +0100
@@ -271,7 +271,7 @@
 	asm(".word TheScheduler ");
 #endif
 	asm("__IpcExcHandler: ");
-	asm(".word %a0" : : "i" ((TInt)DThread::IpcExcHandler));
+	asm(".word %a0" : : "i" (DThread::IpcExcHandler));
 	asm("__default_exc_trap_handler: ");
 	asm("mov r1, #%a0" : : "i" ((TInt)KErrBadDescriptor));	// r0 already contains pointer to TExcTrap
 	// fall through