mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [BUG] Padding inserted by linker breaks magicvar linker array
@ 2019-11-04  7:42 Ahmad Fatoum
  2019-11-04  8:36 ` Ahmad Fatoum
  0 siblings, 1 reply; 2+ messages in thread
From: Ahmad Fatoum @ 2019-11-04  7:42 UTC (permalink / raw)
  To: barebox

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-11-04  8:37 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-04  7:42 [BUG] Padding inserted by linker breaks magicvar linker array Ahmad Fatoum
2019-11-04  8:36 ` Ahmad Fatoum

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox