This patch modifies the newlib and Contiki C and C++ compiler flags to
omit exception handling unwind tables (see
http://wiki.dwarfstd.org/index.php?title=Exception_Handling).
Removing these tables saves space in debug builds and has not caused
any readily-apparent functional changes.
Here is the size listing for an example program built without this
patch:
text data bss dec hex filename
76002 1508 21224 98734 181ae all-timers.galileo
Here is the size listing for the same program with this patch:
text data bss dec hex filename
72918 1508 21224 95650 175a2 all-timers.galileo
The primary motivation for this patch is to help enable UEFI support.
The .eh_frame and .eh_frame_hdr sections that are otherwise generated
are treated as code sections by the EDK2 GenFw program, since they are
read-only alloc sections. They get grouped with the actual code
sections, ahead of the data sections. This perturbs symbols and
complicates debugging.
This patch adds -ffunction-sections and -fdata-sections to the
'release' CFLAGS so each function and data is place into its
own section in the output file. It also adds --gc-section to
the 'release' LDFLAGS so the linker removes the sections which
are not referenced.
This patch also adds -ffunction-sections and -fdata-sections
options to CFLAGS from build_newlib.sh. This increases newlib
static libraries size, however, the Contiki image shrinks even
more since --gc-section removes "dead code" from newlib.
As a practical effect, all unused function and data (as well as
sections such as .eh_frame) are striped out from the final elf
binary. This shrinks our release binary drastically.
Finally, to prevent --gc-section from removing .multiboot section,
this patch adds KEEP(*(.multiboot)) to quarkX1000.ld.
This patch enhances build_newlib.sh to create Makefile.libc so that
the main Galileo makefile can attempt to include Makefile.libc and
instruct the developer to run build_newlib.sh first if the definition
within Makefile.libc is not detected.
Ubuntu enables GCC's stack protector by default (see
https://wiki.ubuntu.com/Security/Features). This causes link errors
like the following:
...undefined reference to `__stack_chk_fail'
To avoid these errors, this patch adds the "-fno-stack-protector" flag
to both the CFLAGS used by the Contiki build process and the CFLAGS
used by the newlib build process.
This patch creates the platform/galileo/bsp directory. This directory
contain all files related to Galileo's Board Support Package (BSP). For
now, the BSP consists of libc and bootloader.
Within the BSP directory, we have the scripts build_newlib.sh and build_
grub.sh. These scripts provide an easy and quick way to build the newlib
and the grub for the Galileo platform.