Date: Sun, 27 Apr 2014 13:00:46 -0500 From: Richard Pennington <rich@...nware.com> To: musl@...ts.openwall.com CC: Rich Felker <dalias@...c.org> Subject: Re: Bare metal progress and an oddity. On 04/27/2014 01:00 PM, Rich Felker wrote: > On Sun, Apr 27, 2014 at 12:37:13PM -0500, Richard Pennington wrote: >> As part of my quixotic quest to run musl on ARM bare metal I've >> started to handle interrupts and an ARM timer to implement the >> clock_* functions to prepare for pre-emptive scheduling of >> pthread_create'd threads. The current sources are here: >> http://ellcc.org/viewvc/svn/ellcc/trunk/baremetal/arm/ >> >> An oddity: If I use printf() to print out values in an interrupt >> handler it sort of works. The format string prints perfectly, but it >> seems that the va_arg values are getting messed up. The stack is >> large enough, fp and sp are sane. Am I missing something in >> pop_arg() that is causing this? Come to think of it, do I have to >> insure a certain stack alignment, for example? Most of the messed up >> values are "long long". >> >> Any thoughts appreciated. > Yes, ARM EABI requires the stack to be aligned to at least an 8-byte > boundary (maybe 16 but I think 8 is all that's required). If your > stack is only aligned to 4 bytes, this will mess things up badly. > > Rich Rich, You're absolutely right. As I was writing my initial email I thought of the stack alignment. It turns out that my idle thread pushed 12 bytes on the stack making it unaligned. The idle thread is a leaf function (of course) so I guess clang didn't feel the need to keep the stack aligned. After fixing the alignment, interrupt printf() works fine. -Rich
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.