3
votes

I was looking head-common.S

at the __mmap_switched:

.long   init_thread_union + THREAD_START_SP @ sp //for stack pointer

THREAD_START_SP is defined THREAD_SIZE(8192) - 8 in "thread+info.h"

set stack size 8KB(8129) and minus 8byte.

why minus 8byte?

i suspect, i think DA(decrement after) right?

1
Rather, Decrement Before (Fully Descending - FD) - the ARM push / pop mnemonics are implemented as stmfd sp!, ... and ldmfd sp!, ... so it's decrement-before on pushes, increment-after on pops. But since words on ARM are only four bytes, that difference wouldn't explain why it keeps eight in reserve. My guess is an initial fp/lr pair, but would need to look up the eABI to validate that. - FrankH.
FrankH.//Thank you for comment :) - csms

1 Answers

2
votes

The 8 bytes aligned is the requirement in APCS.

In APCS, the chapter 5.2.1 The Stack,

The stack must also conform to the following constraint at a public interface:

SP mod 8 = 0. The stack must be double-word aligned.

http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.subset.swdev.abi/index.html