From: Xi Ruoyao <xry111@xry111.site>
To: Bob Plantz <rgplantz@outlook.com>,
"gcc-help@gcc.gnu.org" <gcc-help@gcc.gnu.org>
Subject: Re: Arm AARCH64 string alignment in .rodata
Date: Sun, 25 Sep 2022 02:55:58 +0800 [thread overview]
Message-ID: <e473a0e2b54de73e68b341392c06971eadbee61c.camel@xry111.site> (raw)
In-Reply-To: <SN6PR04MB46723B9470BF2D38119A70BFD4509@SN6PR04MB4672.namprd04.prod.outlook.com>
On Sat, 2022-09-24 at 18:24 +0000, Bob Plantz via Gcc-help wrote:
> On 64-bit Raspberry Pi OS, gcc aligns strings in the .rodata section
> on 64-bit boundaries:
>
> .text
> .section .rodata
> .align 3
> .LC0:
> .string "Enter a number: "
> .align 3
> .LC1:
> .string "%i"
> .align 3
> .LC2:
> .string "Result: %i\n"
> .text
> .align 2
> .global main
> .type main, %function
> main:
>
> I understand the 32-bit boundary for the .text (32-bit instructions),
> but the element in a string is a byte. Arm documentation says that
> array addresses should be aligned at the element size. Why align the
> first character at a 64-bit boundary? Does this have to do with cache
> alignment?
In gcc/config/aarch64/aarch64.h:110:
/* Align definitions of arrays, unions and structures so that
initializations and copies can be made more efficient. This is not
ABI-changing, so it only affects places where we can see the
definition. Increasing the alignment tends to introduce padding,
so don't do this when optimizing for size/conserving stack space. */
If you use -Os, ".align 2" won't show up.
--
Xi Ruoyao <xry111@xry111.site>
School of Aerospace Science and Technology, Xidian University
prev parent reply other threads:[~2022-09-24 18:56 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-24 18:24 Bob Plantz
2022-09-24 18:55 ` Xi Ruoyao [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=e473a0e2b54de73e68b341392c06971eadbee61c.camel@xry111.site \
--to=xry111@xry111.site \
--cc=gcc-help@gcc.gnu.org \
--cc=rgplantz@outlook.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).