[BUG] Padding inserted by linker breaks magicvar linker array

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/barebox



[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux