Skip to content

Makefile updates

Bitbucket Importer requested to merge bitbucket/merged-pr-747 into branch/unified

Created originally on Bitbucket by niklastisk (Niklas)

Was already merged in Bitbucket before import, marked as merged by the import user

  • MAKE: Do not use -fshort-double when GCC version is 6+

This is a quick fix to add support for compiling with GCC 6+. By suggestion from a1ex, [http://www.magiclantern.fm/forum/index.php?topic=17630.msg170414#msg170414] the flag could be removed completely in the future since it "was just an old trick to keep binary small".


  • MAKE: remove duplicate objcopy

Duplicate call to objcopy, for seemingly no reason. The rule is introduced by g3gg0 in changeset 12366:73431f3c980e on branch autoexec-checksum, and seems to be a typo.


  • MAKE: do not page align segments in autoexec
  • MAKE: skip page align for autoexec-fir target

This commit fixes a bug that increases the size of autoexec.bin through unnecessary zero padding. It also makes it appear as if later versions of gcc/binutils produce unjustifiably larger binaries. Depending on the version the size difference can be 32-64 kB.

From what I can tell, this is what happens:

By default, arm-none-eabi-ld align segments to the page size in order for the loader to be able to set correct RWE flags for the segments, which it does by padding one page size of zeroes between the segments. In some binutils this page size is 0x10000 and in some it is 0x8000. This makes the linker pad the space between rodata and data in autoexec with zeroes that are not actually needed. The behavior can be removed with the -N (--omagic) flag, which is already used when linking magiclantern(.bin), probably for the same reason.

Build info for 100D.100A:

[Ubuntu/gcc-4.8.3/binutils-2.24.51/32-bit host]

#!

$ ls -l autoexec pr/autoexec
[...] 470246 Aug 11 13:36 autoexec
[...] 437638 Aug 11 13:36 pr/autoexec

$ arm-none-eabi-readelf -a pr/autoexec | grep 'Flags:'
Flags: 0x5000202, has entry point, Version5 EABI, soft-float ABI

$ arm-none-eabi-readelf -l autoexec
[...]
Program Headers:
  Type           Offset   VirtAddr   PhysAddr   FileSiz MemSiz  Flg Align
  LOAD           0x008000 0x40800000 0x40800000 0x69ec9 0x69ec9 R E 0x8000
  LOAD           0x071ee0 0x40871ee0 0x40871ee0 0x00040 0x00040 RW  0x8000

 Section to Segment mapping:
  Segment Sections...
   00     .text .rodata 
   01     .data 

$ arm-none-eabi-readelf -l pr/autoexec
[...]
Program Headers:
  Type           Offset   VirtAddr   PhysAddr   FileSiz MemSiz  Flg Align
  LOAD           0x000060 0x40800000 0x40800000 0x69f60 0x69f60 RWE 0x20

 Section to Segment mapping:
  Segment Sections...
   00     .text .rodata .data 

[Arch Linux/gcc-6.1.1/binutils-2.27/64-bit host]

#!

$ ls -l autoexec pr/autoexec
[...] 498776 Aug 11 23:52 autoexec
[...] 433336 Aug 11 23:51 pr/autoexec

$ arm-none-eabi-readelf -a pr/autoexec | grep 'Flags:'
Flags: 0x5000200, Version5 EABI, soft-float ABI

$ arm-none-eabi-readelf -l autoexec
[...]
Program Headers:
  Type           Offset   VirtAddr   PhysAddr   FileSiz MemSiz  Flg Align
  LOAD           0x010000 0x40800000 0x40800000 0x69259 0x69259 R E 0x10000
  LOAD           0x079260 0x40879260 0x40879260 0x00040 0x00040 RW  0x10000

 Section to Segment mapping:
  Segment Sections...
   00     .text .rodata 
   01     .data 
   
$ arm-none-eabi-readelf -l pr/autoexec
[...]
Program Headers:
  Type           Offset   VirtAddr   PhysAddr   FileSiz MemSiz  Flg Align
  LOAD           0x000060 0x40800000 0x40800000 0x692a0 0x692a0 RWE 0x20

 Section to Segment mapping:
  Segment Sections...
   00     .text .rodata .data 

Merge request reports