Changes between Initial Version and Version 1 of GCI/Coding/AddPerSectionSupportToBSPs


Ignore:
Timestamp:
01/05/16 21:17:01 (8 years ago)
Author:
Joel Sherrill
Comment:

First draft of task

Legend:

Unmodified
Added
Removed
Modified
  • GCI/Coding/AddPerSectionSupportToBSPs

    v1 v1  
     1= Add Per Function and Data Element Section Support to a BSP =
     2
     3[[TOC(GCI/Coding/AddPerSectionSupportToBSPs, depth=2)]]
     4
     5When a program is compiled and linked, the linker attempts to resolve all references to functions and data elements required by the program. By default, the GNU linker will place an entire object file into an application executable even if only one symbol is required by the application. This can lead to unused code in an executable. This is undesirable from both an application image size and code review perspective.
     6
     7The GNU tools, specifically GCC and GNU ld, have support for a special compilation and linking mode which results in only the referenced symbols being placed into an application executable. However, there are known cases where the application and supporting software are not 100% correct and all needed functions and data are not referenced in a way that results in GNU ld pulling in all needed methods and data.
     8
     9Although large parts of RTEMS are carefully implemented to have only one method per file, experiments with turning on this capability have shown reductions in RTEMS test programs and user applications of up to 50% in overall size.
     10
     11This task consists of turning on this capability for a specific BSP family. A BSP family is the collection of BSPs under a single directory such as c/src/lib/libbsp/CPU/BSP_FAMILY. The make/custom directory has a BSP.cfg file for each BSP which may be built. If the BSP Family supports multiple BSP variants, the BSP.cfg files may include either a shared ".inc" file or a base ".cfg" file with common settings.
     12
     13All BSPS for the SPARC architecture support this advanced capability. For an example, see the file c/src/lib/libbsp/sparc/erc32/make/custom/erc32.cfg. Note the following lines at the bottom of the file which turn on the advanced capabilities.
     14
     15{{{
     16# Add CFLAGS and LDFLAGS for compiling and linking with per item sections
     17CFLAGS_OPTIMIZE_V += -ffunction-sections -fdata-sections
     18LDFLAGS = -Wl,--gc-sections
     19}}}
     20
     21This is also a BSP Family with multiple BSP variants. The sis.cfg file includes erc32.cfg so editing one file impacts both BSPs.
     22
     23== Task Requirements ==
     24
     25In the description of this task, you were given a BSP Family to enable this capability for. The BSP Family will be named CPU/BSP_FAMILY which indicates its location in the source tree and implies a set of BSP variants as described above.
     26The task requires you to:
     27
     28Build a toolset for the CPU architecture per the instruction in the Hello World task. You likely did this for sparc/sis. In that case, sparc was the eCPU and sis was the BSP.
     29
     30Be prepared to generate a proper patch for your changes.
     31
     32Build each BSP in the BSP family with the configure option "--enable-tests=samples"
     33
     34Record the size of the sample executables as reported by the size command for this architecture. The build output has this information but it can be obtained by running a command similar to the following from the top of the build directory:
     35
     36{{{
     37find . -name "*.exe" | xargs -e CPU-rtems4.12-size
     38}}}
     39
     40Note that CPU will have to be replaced with the appropriate CPU architecture.
     41
     42Edit one or more .cfg and .inc files to add the appropriate options to CFLAGS_OPTIMIZE_V and LDFLAGS as shown in the previous section.
     43
     44Rebuild the BSP variants in the BSP Family and again note the size. If there is no reduction, something is not right. If the reduction is near 100%, then something is not right.
     45
     46If the BSP variant is one which can be tested on a simulator, then you need to test it.
     47
     48The commit message for your patch should be similar to the following:
     49
     50{{{
     51CPU/BSP_FAMILY: Add per-section compilation and linking support
     52
     53The size of the sample executables without this option were:
     54
     55FILL ME IN WITH BEFORE INFORMATION
     56
     57The size of the sample executables with this option enabled were:
     58
     59FILL ME IN WITH AFTER INFORMATION
     60}}}