Skip to contentSkip to conversation

Linux process ABI broken in 2.6?

DISCUSSION Tjernlund 3 participants 3 messages Dec 8, 2005 – Dec 9, 2005

lore
Share & tools
lore

Tjernlund

author
#0 lore raw

Seems like ppc32 kernel pass the application entry point address in r7 and MSR in r8 when starting the application. The source might be ret_from_syscall, in entry.S:

	...
	lwz	r7,_NIP(r1)
 	lwz	r8,_MSR(r1)
 	FIX_SRR1(r8, r0)
 	lwz	r2,GPR2(r1)
	lwz	r1,GPR1(r1)
	mtspr	SPRN_SRR0,r7
	mtspr	SPRN_SRR1,r8
	SYNC
	RFI

I am not convinced this is the source, but a non zero r7 breaks static apps in uClibc.

Is this on purpose and why?

Secion 8.4.1 in
http://refspecs.freestandards.org/LSB_3.1.0/LSB-Core-PPC32/LSB-Core-PPC32.html#PROCESSINITIALIZATION

says:
"Contrary to what is stated in the Registers part of chapter 3 of the System V Application Binary Interface PowerPC Processor Supplement there are no values set in registers r3, r4, r5, r6 and r7. Instead the values specified to appear in all of those registers except r7 are placed on the stack. The value to be placed into register r7, the termination function pointer is not passed to the process."

How do one not pass a termination function in r7 other than setting r7 to zero?

Jocke

#1 lore raw
Quoted 21 lines · Tjernlund

Seems like ppc32 kernel pass the application entry point address in r7 and MSR in r8 when starting the application. The source might be ret_from_syscall, in entry.S:

	...
	lwz	r7,_NIP(r1)
(quoted diff) +0 -0
 	lwz	r8,_MSR(r1)
 	FIX_SRR1(r8, r0)
 	lwz	r2,GPR2(r1)
	lwz	r1,GPR1(r1)
	mtspr	SPRN_SRR0,r7
	mtspr	SPRN_SRR1,r8
	SYNC
	RFI

I am not convinced this is the source, but a non zero r7 breaks static apps in uClibc.

Is this on purpose and why?

Secion 8.4.1 in
http://refspecs.freestandards.org/LSB_3.1.0/LSB-Core-PPC32/LSB-Core-PPC32.html#PROCESSINITIALIZATION

Quoted 8 lines

says:
"Contrary to what is stated in the Registers part of chapter 3 of the System V Application Binary Interface PowerPC Processor Supplement there are no values set in registers r3, r4, r5, r6 and r7. Instead the values specified to appear in all of those registers except r7 are placed on the stack. The value to be placed into register r7, the termination function pointer is not passed to the process."

How do one not pass a termination function in r7 other than setting r7 to zero?

Just ignore those registers on entry. The semantics of a syscall are to clobber all volatile registers and there is no point doing anything else.

Ben.

#2 lore raw
In reply to Tjernlund
Quoted 11 lines · Tjernlund

Secion 8.4.1 in
http://refspecs.freestandards.org/LSB_3.1.0/LSB-Core-PPC32/LSB-Core-PPC32.html#PROCESSINITIALIZATION

says:
"Contrary to what is stated in the Registers part of chapter 3 of the System V Application Binary Interface PowerPC Processor Supplement there are no values set in registers r3, r4, r5, r6 and r7. Instead the values specified to appear in all of those registers except r7 are placed on the stack. The value to be placed into register r7, the termination function pointer is not passed to the process."

How do one not pass a termination function in r7 other than setting r7 to zero?

"Not passed" means that there is no value provided in any register or word of memory that should be taken to be the address of a termination function.

Paul.