From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Subject: [BUG] Padding inserted by linker breaks magicvar linker array
Date: Mon, 4 Nov 2019 08:42:58 +0100 [thread overview]
Message-ID: <2c00f789-0630-5dca-d0a6-3aa33b03e1ce@pengutronix.de> (raw)
Hi,
I run into a crash with barebox master[1] when running the magicvar command.
The culprit seems to be 8 bytes of padding inserted between
__barebox_magicvar_start and OPTARG, the first array element:
0x0000000000061918 __barebox_magicvar_start = .
*(SORT_BY_NAME(.barebox_magicvar*))
=> *fill* 0x0000000000061918 0x8
.barebox_magicvar_OPTARG
0x0000000000061920 0x10 common/built-in.o
0x0000000000061920 __barebox_magicvar_OPTARG
The 8 byte *fill*er aligns the .barebox_magicvar_OPTARG section to 16 bytes.
Via addition and removal of dummy initcalls, we can shift the magicvars around
until we no longer straddle the 16 bit boundary:
0x0000000000061910 __barebox_magicvar_start = .
*(SORT_BY_NAME(.barebox_magicvar*))
.barebox_magicvar_OPTARG
0x0000000000061910 0x10 common/built-in.o
0x0000000000061910 __barebox_magicvar_OPTARG
Now running magicvar no longer crashes. We can achieve the alignment reliably by
adding . = ALIGN(16) at the start of the BAREBOX_MAGICVARS definition in
include/asm-generic/barebox.lds.h.
Does someone know what controls this 16 byte (or maybe 32 byte?) alignment?
Do we need to explicitly align the other linker array start symbols as well or
is there a better way?
Interestingly, the barebox_cmd array which I would've expected to behave the same
doesn't:
0x0000000000061638 __barebox_cmd_start = .
*(SORT_BY_NAME(.barebox_cmd*))
.barebox_cmd_2048
0x0000000000061638 0x8 commands/built-in.o
0x0000000000061638 barebox_cmd_2048
Here the 8 byte alignment is deemed ok by the linker...
Thoughts?
Cheers,
Ahmad
[1]: master at time of writing is 27ee6010 "console_simple: fix linking error when
ARCH_HAS_CTRLC enabled". To reproduce the issue I've added a single dummy initcall.
I can provide defconfig if requested.
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next reply other threads:[~2019-11-04 7:44 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-04 7:42 Ahmad Fatoum [this message]
2019-11-04 8:36 ` Ahmad Fatoum
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=2c00f789-0630-5dca-d0a6-3aa33b03e1ce@pengutronix.de \
--to=a.fatoum@pengutronix.de \
--cc=barebox@lists.infradead.org \
/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