[U-Boot] sunxi: Build issue with Bananapi_M2_Ultra
Chen-Yu Tsai
wens at csie.org
Tue Apr 25 09:59:43 UTC 2017
On Tue, Apr 25, 2017 at 4:46 PM, Chen-Yu Tsai <wens at csie.org> wrote:
> Hi,
>
> On Tue, Apr 25, 2017 at 1:56 PM, Jagan Teki <jagannadh.teki at gmail.com> wrote:
>> Hi,
>>
>> We're unable to build with buildman with gcc-4.9.x
>>
>> arm: + Bananapi_M2_Ultra
>> +arm-unknown-linux-gnueabi-ld.bfd: u-boot-spl section `.rodata' will
>> not fit in region `.sram'
>> +arm-unknown-linux-gnueabi-ld.bfd: region `.sram' overflowed by 716 bytes
>> +make[2]: *** [spl/u-boot-spl] Error 1
>> +make[1]: *** [spl/u-boot-spl] Error 2
>>
>> Any inputs?
>
> CC-ing Andre as he's probably interested in this as well.
>
> I normally build my stuff with Debian's 6.3 cross compiler. It seems
> that people don't always use the latest stuff, So I did a comparison
> between Linaro's 2016.02 5.3 and 2016.11 6.2.1 toolchains. I don't
> have a 4.x toolchain at the moment.
>
> Long story short, the latter builds successfully, while the former fails.
> However, the object file sizes don't vary much between the two. I think
> the real difference is that the 6.2.1 toolchain comes with the GOLD linker.
> It probably does a much better job at pruning out dead code.
>
> Appended is a list of object file sizes for the 5.3 toolchain, with
> total sizes for the 6.2.1 toolchain for comparison.
>
> A few things pop up:
>
> - spl/arch/arm/lib/interrupts.o
> We are not using interrupts at all. Is this even necessary?
> IIRC there was a patch to get rid of this from Tom (CC-ed).
>
> - spl/common/dlmalloc.o
> Why do we still need this when we have SYS_MALLOC_SIMPLE
> enabled?
>
> - spl/common/image.o
> Almost half of this is description strings for U-boot legacy
> images, which probably isn't used in SPL? Could we somehow
> use macros to get rid of them?
Digging a bit deeper, I found that interrupts and dlmalloc were
discarded by the linker. As far as C strings go, GCC 5.3 just
dumps them all in the same section, which basically means all of
them will get included, regardless of whether they are actually
used or referenced. GCC 6 does a good job of splitting them by
function, so all the C strings in one function get allocated to
one section. If a function isn't used, it's text and rodata
sections get dropped.
In a project I worked on in the past, a solution (or workaround)
for this was to use named array (not pointer) symbols for each
string. Each string would get tied to a symbol, and -fdata-sections
would work properly with these.
IMHO upgrading to a newer toolchain is easier though.
ChenYu
> Now I've seen people do some cool stuff to get code size down,
> like using fixed size arrays for string tables, which saves a
> pointer. We probably don't need to go there.
>
>
> Regards
> ChenYu
>
>
> text data bss dec hex filename
> 296 0 0 296 128 spl/drivers/gpio/sunxi_gpio.o
> 1566 0 192 1758 6de spl/drivers/mmc/sunxi_mmc.o
> 575 28 8 611 263 spl/drivers/mmc/mmc_legacy.o
> 5383 0 4 5387 150b spl/drivers/mmc/mmc.o
> 922 0 0 922 39a spl/drivers/power/axp221.o
> 795 0 0 795 31b spl/drivers/block/blk_legacy.o
> 641 0 0 641 281 spl/drivers/i2c/i2c_core.o
> 921 44 0 965 3c5 spl/drivers/i2c/mvtwsi.o
> 230 0 0 230 e6 spl/drivers/serial/ns16550.o
> 608 240 0 848 350 spl/drivers/serial/serial_ns16550.o
> 619 0 8 627 273 spl/drivers/serial/serial.o
> 22 0 0 22 16 spl/arch/arm/lib/eabi_compat.o
> 32 0 0 32 20 spl/arch/arm/lib/lshrdi3.o
> 93 0 0 93 5d spl/arch/arm/lib/cache.o
> 2 200 0 202 ca spl/arch/arm/lib/spl.o
> 378 0 0 378 17a spl/arch/arm/lib/cache-cp15.o
> 160 0 0 160 a0 spl/arch/arm/lib/memset.o
> 32 0 0 32 20 spl/arch/arm/lib/ashrdi3.o
> 84 0 0 84 54 spl/arch/arm/lib/reloc_arm_efi.o
> 4 0 0 4 4 spl/arch/arm/lib/div0.o
> 1273 0 0 1273 4f9 spl/arch/arm/lib/interrupts.o
> 0 0 0 0 0 spl/arch/arm/lib/sections.o
> 96 0 0 96 60 spl/arch/arm/lib/vectors.o
> 372 0 0 372 174 spl/arch/arm/lib/crt0_arm_efi.o
> 100 0 0 100 64 spl/arch/arm/lib/crt0.o
> 57 0 0 57 39 spl/arch/arm/lib/reset.o
> 768 0 0 768 300 spl/arch/arm/lib/lib1funcs.o
> 108 0 0 108 6c spl/arch/arm/lib/zimage.o
> 260 0 0 260 104 spl/arch/arm/lib/div64.o
> 60 0 0 60 3c spl/arch/arm/lib/muldi3.o
> 392 0 0 392 188 spl/arch/arm/lib/uldivmod.o
> 736 0 0 736 2e0 spl/arch/arm/lib/memcpy.o
> 32 0 0 32 20 spl/arch/arm/lib/ashldi3.o
> 504 0 0 504 1f8 spl/arch/arm/lib/psci-dt.o
> 22 0 0 22 16 spl/arch/arm/lib/stack.o
> 95 0 0 95 5f spl/arch/arm/mach-sunxi/cpu_info.o
> 756 0 0 756 2f4 spl/arch/arm/mach-sunxi/clock_sun6i.o
> 131 0 0 131 83 spl/arch/arm/mach-sunxi/dram_helpers.o
> 106 0 0 106 6a spl/arch/arm/mach-sunxi/clock.o
> 289 36 0 325 145 spl/arch/arm/mach-sunxi/board.o
> 106 0 0 106 6a spl/arch/arm/mach-sunxi/clock.o
> 289 36 0 325 145 spl/arch/arm/mach-sunxi/board.o
> 52 0 0 52 34 spl/arch/arm/mach-sunxi/prcm.o
> 384 0 0 384 180 spl/arch/arm/mach-sunxi/rsb.o
> 750 64 4 818 332 spl/arch/arm/mach-sunxi/usb_phy.o
> 142 4 0 146 92 spl/arch/arm/mach-sunxi/pmic_bus.o
> 2144 0 0 2144 860 spl/arch/arm/mach-sunxi/dram_sun8i_h3.o
> 304 0 0 304 130 spl/arch/arm/mach-sunxi/pinmux.o
> 246 0 0 246 f6 spl/arch/arm/cpu/armv7/cache_v7.o
> 64 0 0 64 40 spl/arch/arm/cpu/armv7/cpu.o
> 672 0 0 672 2a0 spl/arch/arm/cpu/armv7/psci.o
> 344 0 0 344 158 spl/arch/arm/cpu/armv7/cache_v7_asm.o
> 28 16 0 44 2c spl/arch/arm/cpu/armv7/psci-common.o
> 176 0 0 176 b0 spl/arch/arm/cpu/armv7/start.o
> 320 0 0 320 140 spl/arch/arm/cpu/armv7/nonsec_virt.o
> 28 0 0 28 1c spl/arch/arm/cpu/armv7/lowlevel_init.o
> 184 0 0 184 b8 spl/arch/arm/cpu/armv7/sunxi/timer.o
> 100 0 0 100 64 spl/arch/arm/cpu/armv7/sunxi/fel_utils.o
> 264 0 0 264 108 spl/arch/arm/cpu/armv7/virt-v7.o
> 36 0 0 36 24 spl/arch/arm/cpu/armv7/syslib.o
> 60 0 0 60 3c spl/arch/arm/cpu/armv7/virt-dt.o
> 12 0 0 12 c spl/arch/arm/cpu/armv7/cp15.o
> 931 4 0 935 3a7 spl/cmd/nvedit.o
> 468 0 1025 1493 5d5 spl/common/cli_readline.o
> 982 16 0 998 3e6 spl/common/env_common.o
> 2941 1040 64 4045 fcd spl/common/dlmalloc.o
> 114 0 0 114 72 spl/common/malloc_simple.o
> 150 0 0 150 96 spl/common/memsize.o
> 468 0 0 468 1d4 spl/common/s_record.o
> 861 0 0 861 35d spl/common/command.o
> 208 0 0 208 d0 spl/common/cli.o
> 4923 4 38 4965 1365 spl/common/image.o
> 1126 0 8 1134 46e spl/common/console.o
> 1715 0 1076 2791 ae7 spl/common/xyzModem.o
> 643 80 4 727 2d7 spl/common/spl/spl.o
> 584 36 0 620 26c spl/common/spl/spl_mmc.o
> 792 0 1025 1817 719 spl/common/cli_simple.o
> 396 12 88 496 1f0 spl/common/stdio.o
> 32 0 0 32 20 spl/common/init/board_init.o
> 1000 0 4 1004 3ec spl/lib/string.o
> 76 0 0 76 4c spl/lib/linux_string.o
> 66 0 0 66 42 spl/lib/hang.o
> 736 0 0 736 2e0 spl/lib/tiny-printf.o
> 342 0 0 342 156 spl/lib/time.o
> 911 0 0 911 38f spl/lib/display_options.o
> 1873 0 0 1873 751 spl/lib/hashtable.o
> 256 0 0 256 100 spl/lib/ctype.o
> 576 0 0 576 240 spl/lib/strto.o
> 66 8 0 74 4a spl/lib/linux_compat.o
> 1214 0 0 1214 4be spl/lib/crc32.o
> 920 0 0 920 398 spl/lib/div64.o
> 62 0 0 62 3e spl/lib/panic.o
> 2059 0 0 2059 80b spl/lib/slre.o
> 890 0 0 890 37a spl/lib/membuff.o
> 517 0 0 517 205 spl/lib/uuid.o
> 26 0 0 26 1a spl/lib/tables_csum.o
> 0 0 4 4 4 spl/lib/errno.o
> 6888 40 37 6965 1b35 spl/disk/part_efi.o
> 2526 0 0 2526 9de spl/disk/part.o
> 1484 24 0 1508 5e4 spl/disk/part_dos.o
> 1358 24 2048 3430 d66 spl/disk/part_iso.o
> 1142 0 0 1142 476 spl/board/sunxi/board.o
> 68152 1920 5637 75709 127bd (TOTALS)
> 68076 1920 5637 75633 12771 (TOTALS) (6.2.1)
>
> And sizes per component:
>
> text data bss dec hex filename
> 12556 312 212 13080 3318 spl/drivers/built-in.o
> 296 0 0 296 128 spl/drivers/gpio/built-in.o
> 7524 28 204 7756 1e4c spl/drivers/mmc/built-in.o
> 922 0 0 922 39a spl/drivers/power/built-in.o
> 795 0 0 795 31b spl/drivers/block/built-in.o
> 1562 44 0 1606 646 spl/drivers/i2c/built-in.o
> 1457 240 8 1705 6a9 spl/drivers/serial/built-in.o
> 3557 200 0 3757 ead spl/arch/arm/lib/built-in.o
> 5153 104 4 5261 148d spl/arch/arm/mach-sunxi/built-in.o
> 2358 16 0 2374 946 spl/arch/arm/cpu/armv7/built-in.o
> 284 0 0 284 11c spl/arch/arm/cpu/armv7/sunxi/built-in.o
> 931 4 0 935 3a7 spl/cmd/built-in.o
> 15144 1072 3324 19540 4c54 spl/common/built-in.o
> 1227 116 4 1347 543 spl/common/spl/built-in.o
> 32 0 0 32 20 spl/common/init/built-in.o
> 11590 8 8 11606 2d56 spl/lib/built-in.o
> 12256 88 2085 14429 385d spl/disk/built-in.o
> 1142 0 0 1142 476 spl/board/sunxi/built-in.o
> 78786 2232 5849 86867 15353 (TOTALS)
> 78720 2232 5849 86801 15311 (TOTALS) (6.2.1)
More information about the U-Boot
mailing list