Getting Started with GCC-ERC32: C/C++ Compilation System for Mission Critical Spacecraft Applications | ||
---|---|---|
Prev | Chapter 1. Basic Techniques | Next |
You have written five lines of C++, yet the size command says your program is over 12K bytes. What happened?
Answer: Your program has been linked with code from the ERC32 libraries. In addition to the application code, your five lines, the executable program contains the following:
The light-weight operating system kernel (art0), necessary to support interrupts and basic services
Object code from the library libgcc.a, as required to support the generated code
Object code from other libraries for functions called by the application program and given on the linker command line
The following command will give you a list of the object files that have been linked into your program.
$ erc-coff-gcc -o hello hello.c -Wl,-t /opt/gcc-erc32-1.7e/erc-coff/bin/ld: mode erc_ram art0.o (/opt/gcc-erc32-1.7e/lib/gcc-lib/erc-coff/2.8.1/art0.o) /tmp/ccEfQQUH1.o (/opt/gcc-erc32-1.7e/lib/gcc-lib/erc-coff/2.8.1/libc.a)printf.o (/opt/gcc-erc32-1.7e/lib/gcc-lib/erc-coff/2.8.1/libc.a)vsprintf.o (/opt/gcc-erc32-1.7e/lib/gcc-lib/erc-coff/2.8.1/libc.a)write.o (/opt/gcc-erc32-1.7e/lib/gcc-lib/erc-coff/2.8.1/libc.a)mblen.o (/opt/gcc-erc32-1.7e/lib/gcc-lib/erc-coff/2.8.1/libc.a)strlen.o (/opt/gcc-erc32-1.7e/lib/gcc-lib/erc-coff/2.8.1/libc.a)ctype.o (/opt/gcc-erc32-1.7e/lib/gcc-lib/erc-coff/2.8.1/libc.a)_dtoa.o (/opt/gcc-erc32-1.7e/lib/gcc-lib/erc-coff/2.8.1/libgcc.a)__divsi3.o (/opt/gcc-erc32-1.7e/lib/gcc-lib/erc-coff/2.8.1/libgcc.a)__modsi3.o