Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Embedded systems header functions

Tags:

c

embedded

I am new to embedded systems and want to learn more,

I am currently optimizing a software with regards on the footprint for an ARM embedded system, and are wondering, the header files that you include in your source files. Where are they put?

Right now I am just using a software (OVP) to simulate the ARM hardware platform but in real hardware, you have to put the header files somewhere right? Like in gcc have the standard library on the hd. Do we have to insert this library in the embedded machine as well? Space is limited! And is there any way to minimize the size of the library? Thanks!

Example

#include <stdio.h>

#include <stdlib.h>

I am using the cross compiler arm-elf-gcc

Best Regards

Mr Gigu

like image 255
MrGigu Avatar asked May 31 '11 06:05

MrGigu


1 Answers

You appear to possess a few fundamental misunderstandings about compiled executable code. The following applies to embedded and desktop systems.

Header files are no more than sourcefiles like any other. The difference is that they are inserted into the compilation unit by the pre-processor rather than compiled directly. Also in most cases they contain declarative statements only, and do not generally contribute to the generated code in the sense of executable instructions or stored data.

At runtime none of your source code is required to exist on the target; it is the work of the compiler to generate native executable machine code from your source. It is this machine code that is stored and runs on the target.

A header file is not the same thing as a library. It is merely (generally) the declaration of library content (function prototypes and other symbol declarations such as constants, data, macros, enumerations). The library takes the form of pre-compiled/assembled object code stored in a combined archive. It is the job of the linker to combine the required library code with the object code generated from compilation of your own source. It is this linked executable that is stored and executed on the target, not the original source code.

An exception regarding header files containing declarative code only is when they contain in-line code or executable code in a macro. However such code only occupies space in your application if explicitly called by the application.

When library code is linked, only those library object code components required to resolve references in the application code are linked, not the entire library (unless the entire library is composed of only a single object file).

like image 90
Clifford Avatar answered Oct 01 '22 20:10

Clifford