Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

Fundamentally, there may be no basis for anything.


devel / comp.arch.embedded / IAR ARM Cortex-M compiler does not align stack on 8-byte boundary

SubjectAuthor
* IAR ARM Cortex-M compiler does not align stack on 8-byte boundaryStateMachineCOM
`* Re: IAR ARM Cortex-M compiler does not align stack on 8-byte boundaryRichard Damon
 `* Re: IAR ARM Cortex-M compiler does not align stack on 8-byte boundaryStateMachineCOM
  `* Re: IAR ARM Cortex-M compiler does not align stack on 8-byte boundaryDavid Brown
   `* Re: IAR ARM Cortex-M compiler does not align stack on 8-byte boundaryStateMachineCOM
    `* Re: IAR ARM Cortex-M compiler does not align stack on 8-byte boundaryDavid Brown
     `- Re: IAR ARM Cortex-M compiler does not align stack on 8-byte boundaryRichard Damon

1
IAR ARM Cortex-M compiler does not align stack on 8-byte boundary

<567e5f34-021c-4516-9ebb-5893ba0f5051n@googlegroups.com>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=1020&group=comp.arch.embedded#1020

 copy link   Newsgroups: comp.arch.embedded
X-Received: by 2002:a05:622a:15d4:b0:35c:dda3:7bc5 with SMTP id d20-20020a05622a15d400b0035cdda37bc5mr6032147qty.676.1663532773077;
Sun, 18 Sep 2022 13:26:13 -0700 (PDT)
X-Received: by 2002:a25:5142:0:b0:691:e8f5:e582 with SMTP id
f63-20020a255142000000b00691e8f5e582mr11362104ybb.586.1663532772895; Sun, 18
Sep 2022 13:26:12 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.arch.embedded
Date: Sun, 18 Sep 2022 13:26:12 -0700 (PDT)
Injection-Info: google-groups.googlegroups.com; posting-host=2600:1700:6b1:41c0:5591:120d:a3ef:e3de;
posting-account=7ZnwMAoAAABOb8gyUtR22TprWIPNIMMK
NNTP-Posting-Host: 2600:1700:6b1:41c0:5591:120d:a3ef:e3de
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <567e5f34-021c-4516-9ebb-5893ba0f5051n@googlegroups.com>
Subject: IAR ARM Cortex-M compiler does not align stack on 8-byte boundary
From: statemac...@gmail.com (StateMachineCOM)
Injection-Date: Sun, 18 Sep 2022 20:26:13 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 1777
 by: StateMachineCOM - Sun, 18 Sep 2022 20:26 UTC

ARM ABI says that the stack should be 8-byte aligned, but I see cases where the stack is aligned only to 4-byte boundary.

For example, I have the following simple busy-delay function:

<pre>
void delay(int iter) {
int volatile counter = 0;
while (counter < iter) { // delay loop
++counter;
}
} </pre>

This compiles with IAR EWARM 9.10.2 on ARM Cortex-M to the following disassembly:

<pre>
SUB SP, SP, #0x4
....
ADD SP, SP, #0x4
BX LR
</pre>

The problem is that after SUB SP,SP,4 the stack is misaligned (is aligned only to 4-byte boundary).

Why is this happening? Is this compliant with the ARM ABI? Are there any compiler options to control that?

Re: IAR ARM Cortex-M compiler does not align stack on 8-byte boundary

<4tLVK.212468$PRW4.123582@fx11.iad>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=1021&group=comp.arch.embedded#1021

 copy link   Newsgroups: comp.arch.embedded
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx11.iad.POSTED!not-for-mail
MIME-Version: 1.0
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0)
Gecko/20100101 Thunderbird/91.13.0
Subject: Re: IAR ARM Cortex-M compiler does not align stack on 8-byte boundary
Content-Language: en-US
Newsgroups: comp.arch.embedded
References: <567e5f34-021c-4516-9ebb-5893ba0f5051n@googlegroups.com>
From: Rich...@Damon-Family.org (Richard Damon)
In-Reply-To: <567e5f34-021c-4516-9ebb-5893ba0f5051n@googlegroups.com>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Lines: 32
Message-ID: <4tLVK.212468$PRW4.123582@fx11.iad>
X-Complaints-To: abuse@easynews.com
Organization: Forte - www.forteinc.com
X-Complaints-Info: Please be sure to forward a copy of ALL headers otherwise we will be unable to process your complaint properly.
Date: Sun, 18 Sep 2022 16:46:56 -0400
X-Received-Bytes: 1954
 by: Richard Damon - Sun, 18 Sep 2022 20:46 UTC

On 9/18/22 4:26 PM, StateMachineCOM wrote:
> ARM ABI says that the stack should be 8-byte aligned, but I see cases where the stack is aligned only to 4-byte boundary.
>
> For example, I have the following simple busy-delay function:
>
> <pre>
> void delay(int iter) {
> int volatile counter = 0;
> while (counter < iter) { // delay loop
> ++counter;
> }
> }
> </pre>
>
> This compiles with IAR EWARM 9.10.2 on ARM Cortex-M to the following disassembly:
>
> <pre>
> SUB SP, SP, #0x4
> ...
> ADD SP, SP, #0x4
> BX LR
> </pre>
>
> The problem is that after SUB SP,SP,4 the stack is misaligned (is aligned only to 4-byte boundary).
>
> Why is this happening? Is this compliant with the ARM ABI? Are there any compiler options to control that?

I think, that as long as the function doesn't call another function it
doesn't need to respect that ABI, since it knows it isn't going to do
the operations that need the 8-byte alignment.

If it isn't *I*nterfacing with anything, the ABI doesn't apply.

Re: IAR ARM Cortex-M compiler does not align stack on 8-byte boundary

<fca6cc0a-8481-4eb6-b4b6-ddf6ee9ebdc8n@googlegroups.com>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=1022&group=comp.arch.embedded#1022

 copy link   Newsgroups: comp.arch.embedded
X-Received: by 2002:ad4:5dc8:0:b0:4ac:7fff:4360 with SMTP id m8-20020ad45dc8000000b004ac7fff4360mr12399272qvh.69.1663546249139;
Sun, 18 Sep 2022 17:10:49 -0700 (PDT)
X-Received: by 2002:a25:bc02:0:b0:695:652e:72b5 with SMTP id
i2-20020a25bc02000000b00695652e72b5mr12684775ybh.21.1663546248788; Sun, 18
Sep 2022 17:10:48 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.arch.embedded
Date: Sun, 18 Sep 2022 17:10:48 -0700 (PDT)
In-Reply-To: <4tLVK.212468$PRW4.123582@fx11.iad>
Injection-Info: google-groups.googlegroups.com; posting-host=2600:1700:6b1:41c0:5591:120d:a3ef:e3de;
posting-account=7ZnwMAoAAABOb8gyUtR22TprWIPNIMMK
NNTP-Posting-Host: 2600:1700:6b1:41c0:5591:120d:a3ef:e3de
References: <567e5f34-021c-4516-9ebb-5893ba0f5051n@googlegroups.com> <4tLVK.212468$PRW4.123582@fx11.iad>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <fca6cc0a-8481-4eb6-b4b6-ddf6ee9ebdc8n@googlegroups.com>
Subject: Re: IAR ARM Cortex-M compiler does not align stack on 8-byte boundary
From: statemac...@gmail.com (StateMachineCOM)
Injection-Date: Mon, 19 Sep 2022 00:10:49 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 2609
 by: StateMachineCOM - Mon, 19 Sep 2022 00:10 UTC

Yes, the simple delay() function does not call anything. But still, interrupts can preempt it, which is quite likely because a function like this runs for a long time by design (and consumes a significant percentage of the CPU time).

In fact, I've checked it, and an interrupt preempting delay() must re-align the stack by using the "stack aligner". So the simple (no FPU) Cortex-M exception stack frame of 8 registers (32 bytes) becomes the bigger stack frame of 9 registers (36 bytes). Please note that the Cortex-M CPU deals with it just fine and the program runs. But in the case of RTOS or some other assembly code dealing with interrupts could break the system by making assumptions about the stack alignment. I thought that the compatibility with interrupts is the primary reason why the ARM ABI stipulates 8-byte stack alignment.

Also, I've just checked ARM/KEIL Compiler 6 (based on LLVM), and that compiler generated 8-byte aligned code for delay():

<pre>
SUB SP, SP, #0x8
....
ADD SP, SP, #0x8
BX LR
</pre>

Now, I don't have the time to investigate all compilers and various optimization levels. I thought that standards, like the ARM ABI, are supposed to settle things like that. I'm just a bit perplexed and couldn't find much information about that.

Re: IAR ARM Cortex-M compiler does not align stack on 8-byte boundary

<tg980r$11dtu$1@dont-email.me>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=1023&group=comp.arch.embedded#1023

 copy link   Newsgroups: comp.arch.embedded
Path: i2pn2.org!i2pn.org!usenet.goja.nl.eu.org!weretis.net!feeder8.news.weretis.net!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: david.br...@hesbynett.no (David Brown)
Newsgroups: comp.arch.embedded
Subject: Re: IAR ARM Cortex-M compiler does not align stack on 8-byte boundary
Date: Mon, 19 Sep 2022 10:07:55 +0200
Organization: A noiseless patient Spider
Lines: 55
Message-ID: <tg980r$11dtu$1@dont-email.me>
References: <567e5f34-021c-4516-9ebb-5893ba0f5051n@googlegroups.com>
<4tLVK.212468$PRW4.123582@fx11.iad>
<fca6cc0a-8481-4eb6-b4b6-ddf6ee9ebdc8n@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Mon, 19 Sep 2022 08:07:55 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="2c18923bcab73a389166ebd2fbd8f337";
logging-data="1095614"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19268Urbnc18Yht3L+IKkBV7cFQm4Tkb5E="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101
Thunderbird/91.9.1
Cancel-Lock: sha1:23zjC8YhMZtanwAW2zP0XGWCXEU=
In-Reply-To: <fca6cc0a-8481-4eb6-b4b6-ddf6ee9ebdc8n@googlegroups.com>
Content-Language: en-GB
 by: David Brown - Mon, 19 Sep 2022 08:07 UTC

(Please get a real newsreader and a real newsserver, rather than using
the google groups crapware. Google groups is fine for searching old
posts, but makes a mess of posts - it ruins line endings, code
formatting, attributions, and generally breaks every Usenet posting
convention it can. If you /must/ use google groups, please make the
effort to get attributions right and to quote appropriate parts of the
earlier posts. And if you are including code snippets, fix the line
endings of your post. news.eternal-september.org is a free newsserver,
and Thunderbird is one of many free newsreaders.)

On 19/09/2022 02:10, StateMachineCOM wrote:
> Yes, the simple delay() function does not call anything. But still, interrupts can preempt it, which is quite likely because a function like this runs for a long time by design (and consumes a significant percentage of the CPU time).
>
> In fact, I've checked it, and an interrupt preempting delay() must re-align the stack by using the "stack aligner". So the simple (no FPU) Cortex-M exception stack frame of 8 registers (32 bytes) becomes the bigger stack frame of 9 registers (36 bytes). Please note that the Cortex-M CPU deals with it just fine and the program runs. But in the case of RTOS or some other assembly code dealing with interrupts could break the system by making assumptions about the stack alignment. I thought that the compatibility with interrupts is the primary reason why the ARM ABI stipulates 8-byte stack alignment.
>

The hardware has to be able to cope with interrupts occurring while
stacks are not 8-byte aligned. It's possible that it is marginally
slower or results in a bigger stack frame, but it has to work.

The key reason for stack alignment is efficiency. It makes a bigger
difference when you have caches and big internal buses, and an even
bigger difference when this is combined with multiple cores. It's also
possible that some vector and SIMD units require higher alignments. For
embedded Cortex-M devices, it would not have made much difference (I
believe the old EABI required 4 byte alignment), but requiring 8 byte
alignment is a very minor cost that makes future compatibility much
simpler. Getting it right early on avoids the kind of dog's dinner you
see in the x86 world where the 64-bit Windows stack alignment is too
small for the needs of SIMD instructions.

> Also, I've just checked ARM/KEIL Compiler 6 (based on LLVM), and that compiler generated 8-byte aligned code for delay():
>
> <pre>
> SUB SP, SP, #0x8
> ...
> ADD SP, SP, #0x8
> BX LR
> </pre>
>
> Now, I don't have the time to investigate all compilers and various optimization levels. I thought that standards, like the ARM ABI, are supposed to settle things like that. I'm just a bit perplexed and couldn't find much information about that.

A leaf function can be fine with 4 byte stack alignment. A quick test
shows gcc aligns on 8 bytes, while clang aligns at 4 bytes for a leaf
function.

An extremely useful tool for investigating this kind of thing is the
online compiler at <https://godbolt.org>. It does not include many
commercial compilers (though it has MSVC), but supports C, C++, and lots
of languages on a very wide range of compilers and targets. Here you
can see your code compiled for gcc and clang Cortex-M4 :

<https://godbolt.org/z/cc6bf6oGe>

Re: IAR ARM Cortex-M compiler does not align stack on 8-byte boundary

<2774ac88-db8f-4fb9-8054-2b10dab43a1dn@googlegroups.com>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=1024&group=comp.arch.embedded#1024

 copy link   Newsgroups: comp.arch.embedded
X-Received: by 2002:a05:622a:1014:b0:35c:e8ef:a406 with SMTP id d20-20020a05622a101400b0035ce8efa406mr4927074qte.306.1663603779718;
Mon, 19 Sep 2022 09:09:39 -0700 (PDT)
X-Received: by 2002:a25:bc02:0:b0:695:652e:72b5 with SMTP id
i2-20020a25bc02000000b00695652e72b5mr15287450ybh.21.1663603779486; Mon, 19
Sep 2022 09:09:39 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.arch.embedded
Date: Mon, 19 Sep 2022 09:09:39 -0700 (PDT)
In-Reply-To: <tg980r$11dtu$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=2600:1700:6b1:41c0:8dc0:977e:e3c5:6861;
posting-account=7ZnwMAoAAABOb8gyUtR22TprWIPNIMMK
NNTP-Posting-Host: 2600:1700:6b1:41c0:8dc0:977e:e3c5:6861
References: <567e5f34-021c-4516-9ebb-5893ba0f5051n@googlegroups.com>
<4tLVK.212468$PRW4.123582@fx11.iad> <fca6cc0a-8481-4eb6-b4b6-ddf6ee9ebdc8n@googlegroups.com>
<tg980r$11dtu$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <2774ac88-db8f-4fb9-8054-2b10dab43a1dn@googlegroups.com>
Subject: Re: IAR ARM Cortex-M compiler does not align stack on 8-byte boundary
From: statemac...@gmail.com (StateMachineCOM)
Injection-Date: Mon, 19 Sep 2022 16:09:39 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 2339
 by: StateMachineCOM - Mon, 19 Sep 2022 16:09 UTC

Hi David,
Thanks for your help.

> Please get a real newsreader and a real newsserver...

I'd like to do this, but I use this newsgroup so infrequently that I don't want to buy and install anything special. Is there some online tool you'd recommend?

> An extremely useful tool for investigating this kind of thing is the online compiler

Yes, thank you. It seems indeed as a useful tool for a quick look at the generated assembly.

But regarding the stack alignment requirements, The "ARM Procedure Call Standard for the ARM Architecture" (ARM IHI 0042E) says in Section 5.2.1.1 "Universal stack constraints" that "SP mod 4 = 0, The stack must at all times be aligned at word boundary". Later in the next Section 5.2.1.2 "Stack constraints at a public interface" it strengthens the requirements to: "SP mod 8 = 0. The stack must be double-word aligned".

So the question now is: what do they mean by "public interface"?

Re: IAR ARM Cortex-M compiler does not align stack on 8-byte boundary

<tgabl6$179dk$1@dont-email.me>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=1025&group=comp.arch.embedded#1025

 copy link   Newsgroups: comp.arch.embedded
Path: i2pn2.org!i2pn.org!aioe.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: david.br...@hesbynett.no (David Brown)
Newsgroups: comp.arch.embedded
Subject: Re: IAR ARM Cortex-M compiler does not align stack on 8-byte boundary
Date: Mon, 19 Sep 2022 20:16:06 +0200
Organization: A noiseless patient Spider
Lines: 57
Message-ID: <tgabl6$179dk$1@dont-email.me>
References: <567e5f34-021c-4516-9ebb-5893ba0f5051n@googlegroups.com>
<4tLVK.212468$PRW4.123582@fx11.iad>
<fca6cc0a-8481-4eb6-b4b6-ddf6ee9ebdc8n@googlegroups.com>
<tg980r$11dtu$1@dont-email.me>
<2774ac88-db8f-4fb9-8054-2b10dab43a1dn@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Mon, 19 Sep 2022 18:16:06 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="9b23b23ffe9df84c158b07831dca3265";
logging-data="1287604"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19tE3iEawOCnvOJdQ+wBQC+3yoCbMSMc80="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101
Thunderbird/91.9.1
Cancel-Lock: sha1:BrcvmdouSMCmxdIid0HrEBqr3f8=
Content-Language: en-GB
In-Reply-To: <2774ac88-db8f-4fb9-8054-2b10dab43a1dn@googlegroups.com>
 by: David Brown - Mon, 19 Sep 2022 18:16 UTC

On 19/09/2022 18:09, StateMachineCOM wrote:
> Hi David, Thanks for your help.
>
>> Please get a real newsreader and a real newsserver...
>
> I'd like to do this, but I use this newsgroup so infrequently that I
> don't want to buy and install anything special. Is there some online
> tool you'd recommend?
>

Thunderbird is free - as are any of a dozen different newsreaders,
depending on preferences and OS. Many other email programs also support
Usenet. There are several free Usenet servers, at least for non-binary
groups like those in comp.* news.eternal-september.org is a popular
one. Your ISP might also provide the service, as it used to be a
standard part of any internet access package.

I don't know of any free online interfaces other than google groups,
which is barely worth the price (although as always with google, it's
good for searching). There are several paid-for services, mostly
targeting binary groups (which used to be a popular way to spread
pirated software and media, before bittorrent).

Technical groups are all text posts, and most have relatively few posts.
Even if you start your newsreader once a month, it will take no more
than a few seconds to download all posts in comp.arch.embedded to bring
it up to date.

>> An extremely useful tool for investigating this kind of thing is
>> the online compiler
>
> Yes, thank you. It seems indeed as a useful tool for a quick look at
> the generated assembly.
>

I use it all the time, for looking at code on different targets,
comparing different options, checking complicated syntax (such as
testing C++ features in the latest standards, newer than the compilers I
have online), comparing the output of different compilers, sharing code
with others via links, checking if the code I write gives exactly the
assembly I want, amongst other things.

> But regarding the stack alignment requirements, The "ARM Procedure
> Call Standard for the ARM Architecture" (ARM IHI 0042E) says in
> Section 5.2.1.1 "Universal stack constraints" that "SP mod 4 = 0, The
> stack must at all times be aligned at word boundary". Later in the
> next Section 5.2.1.2 "Stack constraints at a public interface" it
> strengthens the requirements to: "SP mod 8 = 0. The stack must be
> double-word aligned".
>
> So the question now is: what do they mean by "public interface"?

I guess that means when calling code, or being called from code, that is
independently compiled. When it is within the same compiled code, you
don't have to follow the standard ABI at all - you (meaning "the
compiler") can make your own rules regarding parameter passing, volatile
/ non-volatile registers, etc.

Re: IAR ARM Cortex-M compiler does not align stack on 8-byte boundary

<5_8WK.196836$9Yp5.77390@fx12.iad>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=1026&group=comp.arch.embedded#1026

 copy link   Newsgroups: comp.arch.embedded
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx12.iad.POSTED!not-for-mail
MIME-Version: 1.0
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0)
Gecko/20100101 Thunderbird/91.13.0
Subject: Re: IAR ARM Cortex-M compiler does not align stack on 8-byte boundary
Content-Language: en-US
Newsgroups: comp.arch.embedded
References: <567e5f34-021c-4516-9ebb-5893ba0f5051n@googlegroups.com>
<4tLVK.212468$PRW4.123582@fx11.iad>
<fca6cc0a-8481-4eb6-b4b6-ddf6ee9ebdc8n@googlegroups.com>
<tg980r$11dtu$1@dont-email.me>
<2774ac88-db8f-4fb9-8054-2b10dab43a1dn@googlegroups.com>
<tgabl6$179dk$1@dont-email.me>
From: Rich...@Damon-Family.org (Richard Damon)
In-Reply-To: <tgabl6$179dk$1@dont-email.me>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Lines: 40
Message-ID: <5_8WK.196836$9Yp5.77390@fx12.iad>
X-Complaints-To: abuse@easynews.com
Organization: Forte - www.forteinc.com
X-Complaints-Info: Please be sure to forward a copy of ALL headers otherwise we will be unable to process your complaint properly.
Date: Mon, 19 Sep 2022 21:48:48 -0400
X-Received-Bytes: 3209
 by: Richard Damon - Tue, 20 Sep 2022 01:48 UTC

On 9/19/22 2:16 PM, David Brown wrote:
> On 19/09/2022 18:09, StateMachineCOM wrote:
>> But regarding the stack alignment requirements, The "ARM Procedure
>> Call Standard for the ARM Architecture" (ARM IHI 0042E) says in
>> Section 5.2.1.1 "Universal stack constraints" that "SP mod 4 = 0, The
>> stack must at all times be aligned at word boundary". Later in the
>> next Section 5.2.1.2 "Stack constraints at a public interface" it
>> strengthens the requirements to: "SP mod 8 = 0. The stack must be
>> double-word aligned".
>>
>> So the question now is: what do they mean by "public interface"?
>
> I guess that means when calling code, or being called from code, that is
> independently compiled.  When it is within the same compiled code, you
> don't have to follow the standard ABI at all - you (meaning "the
> compiler") can make your own rules regarding parameter passing, volatile
> / non-volatile registers, etc.

Yes, the Standard API defines what functions are allowed to presume when
they are called by "unknown" code. That is what is allowed at a "Public
API", being public, anyone can call it.

Since routines are allowed to assume they are entered with a stack
pointer aligned to a multiple of 8, the caller needs to assure that (at
least if their entry at a public API also had the stack pointer properly
aligned).

The purpose of this is that some common instructions require their
source/destination to be so aligned, and it is a bit awkward to write a
subroutine that might be called with a stack pointer that isn't so
aligned to make the pointer so aligned (it typically costs a register to
hold the old SP), so the ABI requires the stack to be so aligned.

If a piece of code doesn't call any outside routines, then this isn't a
problem, so the ABI doesn't restrict the stack pointer at those times.
This is important, as it isn't uncommon to want to temporarily push a
single word onto the stack for a bit, and it the stack pointer needed to
be kept at an alignment of 8, that operation would need to use up extra
stack memory.

1
server_pubkey.txt

rocksolid light 0.9.7
clearnet tor