From: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
To: Artur Rojek <contact@artur-rojek.eu>
Cc: Yoshinori Sato <ysato@users.sourceforge.jp>,
Rich Felker <dalias@libc.org>,
Daniel Lezcano <daniel.lezcano@linaro.org>,
Thomas Gleixner <tglx@linutronix.de>,
Uros Bizjak <ubizjak@gmail.com>,
Geert Uytterhoeven <geert+renesas@glider.be>,
"D . Jeff Dionne" <jeff@coresemi.io>,
Rob Landley <rob@landley.net>,
linux-sh@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/2] sh: align .bss section padding to 8-byte boundary
Date: Wed, 12 Mar 2025 09:21:55 +0100 [thread overview]
Message-ID: <967e29681c8bc39edfdd9c645d943f17d341c2ae.camel@physik.fu-berlin.de> (raw)
In-Reply-To: <433bc8a0732bf8a63c64c4bf0e6ad4a7@artur-rojek.eu>
Hi Artur,
On Wed, 2025-03-12 at 00:40 +0100, Artur Rojek wrote:
> On 2025-03-11 18:28, John Paul Adrian Glaubitz wrote:
> > Hi Artur,
>
> Hey Adrian,
> thanks for looking into this patch.
Sure. I just want to understand what's going on before signing it with "Reviewed-by",
I wouldn't dare that without fully understanding what the proposed change does ;-).
> > What this effectively does is removing ". = ALIGN(sbss_align);" first
> > from BSS_SECTION().
> >
> > Then it inserts ". = ALIGN(PAGE_SIZE);" after the "SBSS(0)".
> >
> > If I understand this correctly, SBSS() inserts a zero-padding and if
> > I'm not mistaken,
> > inserting ". = ALIGN(PAGE_SIZE);" will cause this padding to grow to at
> > least PAGE_SIZE
> > due the alignment.
> >
> > Is this correct?
> >
> > > + .bss : AT(ADDR(.bss) - LOAD_OFFSET) {
> > > + BSS_FIRST_SECTIONS
> > > + . = ALIGN(PAGE_SIZE);
> > > + *(.bss..page_aligned)
> > > + . = ALIGN(PAGE_SIZE);
> > > + *(.dynbss)
> > > + *(BSS_MAIN)
> > > + *(COMMON)
> > > + . = ALIGN(8);
> >
> > If my understanding above is correct, why do we will need an additional
> > ". = ALIGN(8)"
> > here?
>
> I'll tackle both of the above questions at once.
> I'm by no means an expert at GNU Linker syntax, but the intention of
> this patch is to put . = ALIGN(8) inside the .bss : { ... } section
> definition, so that the section itself grows by the requested padding.
Makes sense.
> In the original BSS_SECTION(0, PAGE_SIZE, 4), the last argument inserts
> a 4 byte padding after the closing brace of .bss section definition,
> causing the __bss_stop symbol offset to grow, but not the .bss section
> itself:
>
> #define BSS_SECTION(sbss_align, bss_align, stop_align) \
> . = ALIGN(sbss_align); \
> __bss_start = .; \
> SBSS(sbss_align) \
> BSS(bss_align) \
> . = ALIGN(stop_align); \
> __bss_stop = .;
OK, that's really odd. So, the __bss_stop would be moved to the desired
position but the section itself still remains small? What exactly does the
linker fill the region with? Sounds very strange.
> TurtleBoard loader is only concerned with the .bss section size - it
> doesn't care about any symbol offsets - and hence this seemingly cryptic
> change (you can display the section size information with
> readelf -t kernel_image).
Looking at the actual kernel image with readelf is a very good suggestion!
> The rest of the changes are simply to "inline" the BSS() macro (as I
> needed to access that closing brace), and the former sbss_align,
> bss_align (that's your PAGE_SIZE) and stop_align arguments are passed
> accordingly, the same way they used to be passed before. The only
> visible effect should be the move of ALIGN(stop_align) inside of .bss
> section definition, and the change of stop_align value from 4 to 8.
OK. FWIW, do you understand what SBSS is for? I couldn't find any explanation
for it.
> Arguably the TurtleBoard loader should read the __bss_stop symbol offset
> instead, but in this patch I'm trying to solve the issue from kernel's
> point of view.
That's absolutely sensible as this avoids having to update the firmware.
Adrian
--
.''`. John Paul Adrian Glaubitz
: :' : Debian Developer
`. `' Physicist
`- GPG: 62FF 8A75 84E0 2956 9546 0006 7426 3B37 F5B5 F913
next prev parent reply other threads:[~2025-03-12 8:22 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-16 17:55 [PATCH 0/2] J2 Turtle Board fixes Artur Rojek
2025-02-16 17:55 ` [PATCH 1/2] sh: align .bss section padding to 8-byte boundary Artur Rojek
2025-02-18 12:41 ` Rob Landley
2025-03-11 17:28 ` John Paul Adrian Glaubitz
2025-03-11 23:40 ` Artur Rojek
2025-03-12 8:06 ` Geert Uytterhoeven
2025-03-13 10:36 ` John Paul Adrian Glaubitz
2025-03-12 8:21 ` John Paul Adrian Glaubitz [this message]
2025-03-12 8:32 ` Uros Bizjak
2025-03-12 8:44 ` John Paul Adrian Glaubitz
2025-03-12 9:47 ` Geert Uytterhoeven
2025-03-12 9:55 ` Uros Bizjak
2025-03-13 9:38 ` David Laight
2025-04-05 17:38 ` John Paul Adrian Glaubitz
2025-02-16 17:55 ` [PATCH 2/2] irqchip: clocksource: fix jcore-pit irq request Artur Rojek
2025-02-17 7:14 ` Uros Bizjak
2025-02-18 12:43 ` Rob Landley
2025-02-19 14:43 ` Daniel Lezcano
2025-02-19 14:50 ` Geert Uytterhoeven
2025-02-19 14:52 ` Daniel Lezcano
2025-02-27 7:52 ` [PATCH 0/2] J2 Turtle Board fixes John Paul Adrian Glaubitz
2025-02-28 3:03 ` Rob Landley
2025-02-28 8:34 ` John Paul Adrian Glaubitz
2025-02-28 22:19 ` Rob Landley
2025-02-28 22:34 ` John Paul Adrian Glaubitz
2025-03-01 3:20 ` Rob Landley
2025-04-08 15:23 ` John Paul Adrian Glaubitz
2025-04-11 11:25 ` Rob Landley
2025-06-09 10:01 ` John Paul Adrian Glaubitz
2025-06-10 20:22 ` Rob Landley
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=967e29681c8bc39edfdd9c645d943f17d341c2ae.camel@physik.fu-berlin.de \
--to=glaubitz@physik.fu-berlin.de \
--cc=contact@artur-rojek.eu \
--cc=dalias@libc.org \
--cc=daniel.lezcano@linaro.org \
--cc=geert+renesas@glider.be \
--cc=jeff@coresemi.io \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sh@vger.kernel.org \
--cc=rob@landley.net \
--cc=tglx@linutronix.de \
--cc=ubizjak@gmail.com \
--cc=ysato@users.sourceforge.jp \
/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 NNTP newsgroup(s).