1. 16 Jan, 2019 1 commit
  2. 13 Jan, 2019 2 commits
    • Hugo Grostabussiat's avatar
      Drastically reduce the size of m4.bin · 4380f79c
      Hugo Grostabussiat authored
      This commit reduces the size of the output binary by the following
      1) enabling compiler optimization and requesting it to optimize for size
      2) using the -ffunction-sections and -fdata-sections compiler options in
         addition to the --gc-sections linker option.
      The -ffunction-sections and -fdata-sections compiler options causes the
      compiler to generate a new section for every function and object.
      Doing this enables the linker to move around individual function instead
      of full compilation units.
      The --gc-sections option instructs the linker to discard input sections
      which are not referenced by other sections in the output.
      Those two features combined allow the linker to discard all the
      functions which are unused, which can save a lot of space in the
      resulting binary.
      To know which sections are unused, the linker needs to be told at least
      one section it should keep, otherwise it would discard all the sections
      since the firmware does not have a standard entry point.
      In our case, the ldscript orders the linker to keep the m4_start.o
      .text section, as it is the one that contains the vectors table, which
      is the root from which all the useful code will be called.
      The size of the resulting m4.bin after thoses optimizations is about
      4.4 KiB vs. 11 KiB before.
    • Hugo Grostabussiat's avatar
      Fix various Makefile and ldscript issues · ab83de31
      Hugo Grostabussiat authored
      1) Compile all the C files using the same compiler options
      Some C files were compiled in the recipe to link the final .elf, while
      the others were compiled using make implicit rules. This caused all the
      .o files specified in the OBJS variable to be compiled without the
      -fno-zero-initialized-in-bss option, potentially leading to the use of
      uninitialized memory.
      This commit puts all the C-compiler-specific options in the CFLAGS
      variable, as well as clearly separating the compilation and linking
      phases, relying on implicit make rules for the compilation part.
      2) Explcitly put the output of m4_start.S first in the output .elf
      The .text section of m4_start.o was output at the lowest address only
      because the file was placed first in the OBJS variable.
      This commit changes the ldscript to always place the .text section of
      m4_start.o first in the output, no matter the order of the input files
      on the command line.
      3) Move all data in .bss sections into the .data section
      Since the final .elf is linked with -nostartfiles, the .bss section is
      not initialized, causing code expecting data to be initialized to 0 to
      use uninitialized memory.
      This commit changes the ldscript to put the common symbols, which were
      previously put in the .bss section, in the .data section to ensure the
      data is initialized. This has the side-effect of allocating the space
      for that data in the binary, increasing its size by 54 bytes.
      4) Group all common linker options in the LDFLAGS variable
      Most linker options were duplicated in the recipes for m4_tcm.elf and
      This commit puts all the common linker options in the LDFLAGS variable
      for the sake of clarity, in addition to other minor cosmetic changes.
  3. 10 Jun, 2018 15 commits
  4. 02 Apr, 2018 1 commit
  5. 27 Mar, 2018 1 commit
  6. 22 Mar, 2018 1 commit
  7. 19 Mar, 2018 1 commit
  8. 16 Mar, 2018 1 commit
  9. 14 Mar, 2018 2 commits