FreeBSD arm EABI5 documentation?
Ian Lepore
ian at freebsd.org
Thu Jul 11 18:44:30 UTC 2019
On Thu, 2019-07-11 at 17:50 +0000, adr wrote:
> > > > Curious about 32-bit arm stack alignment requirements in netbsd
> > > > (based on a FreeBSD thread making claims that user space allows
> > > > 4-byte stack alignment), I went looking around some in NetBSD
>
> Whooow... I don't know what on earth I'm missing, or what I said that
> make you contact NetBSD developers talking about "claims".
>
> Just write some ugly assembler:
> ======================================
> .arch armv7-a
> .syntax unified
> .data
> str1:
> .string "1-6: %d, %d, %d, %d, %d, %d\n"
> .align
> .text
> .global main
> main:
> push {r0} @ stack is not 8byte align anymore
> mov r8, 10
> loop:
> ldr r0, =str1
> mov r1, 1
> mov r2, 2
> mov r3, 3
> mov r4, 4
> mov r5, 5
> mov r6, 6
> push { r4-r6 } @ alignment will change in the loop
> bl printf
> subs r8, r8, 1
> bne loop
> end:
> b end
> =====================================================
> as -a -o test.o test.s > test.l
> cc -o test test.o
>
> And it works. In fact it works in FreeBSD with clang.
> But a more complex code, as a said before, calling
> SDL2 to use graphics works without any problem on NetBSD
> and Linux, but not on FreeBSD.
>
> In fact I like that it doesn't work in FreeBSD, because
> that made me correct my code.
>
> That is all I was saying, and now I'm going to just shut the * up.
Oh, so it's not that netbsd and linux have different stack alignment
requirements, it's just that you accidentally never called a function
with an unaligned stack where the misalignment caused a problem. There
are only a few instructions that really require 64-bit data alignment
when the strict alignment enforcement flag is off (it's off in all 3
OSes we're talking about). You could probably call most of the C
library functions and luck out on the alignment.
-- Ian
More information about the freebsd-arm
mailing list