Presentation is loading. Please wait.

Presentation is loading. Please wait.

UEE072HM Embedded Control Systems. Breaking down the compilation process Compilation is made up of a number of phases –Preprocessing –Compilation Can.

Similar presentations


Presentation on theme: "UEE072HM Embedded Control Systems. Breaking down the compilation process Compilation is made up of a number of phases –Preprocessing –Compilation Can."— Presentation transcript:

1 UEE072HM Embedded Control Systems

2 Breaking down the compilation process Compilation is made up of a number of phases –Preprocessing –Compilation Can be a number of passes –Optimisation –Link/loading

3 The compilation process cc –flags myfile.c thisfile.o PreprocessingCompilationOptimisation*Link/loading #includes.h header files #defines Text Assembler or Object format Relocatable Object file Executable Binary Object files Library file Start-up code *optional

4 Preprocessing ccp is the C preprocessor –Really a text editor – text input and output –Uses in #include file ( /usr/include in UNIX) –Related to libraries & systems calls through prototypes and struct definitions –Deals with macros and constants –Can get output Cc –E file.c

5 Compilation This is often called c1 or cl –Can be 1 or 2 passes –Creates either intermediate object format or assembler file –Can contain the optimisation phase turned on/off by a command line flag –Several/separate files can be compiled to object files cc –c file.c creates file.o

6 Optimisation Can be a separate phase or part of main C compiler Is optional – quite often turned off for cross development

7 Assembly If the compiler produces assembler code then this can be sent to the assembler It is worth noting –That the assembly code can be non-standard –Debugging may have to be done at assembly level –Can hand optimise –Helpful for understanding ALP/HLL linkage

8 Link Loading Normally the program ld, gld, l1 Can link together various object and library file Controlled by a linker language Produces map and symbol table output Very important for cross development

9 Program Segments Code Data BSS Stack Heap char strng=“hello”; int count, this, that; main() { int i, j, k; char *sp; …….. for (i=0;i != 100;i++) …… sp= (char*) malloc(sizeof(i));

10 Executable formats There are a number of different exectuable formats –A.out is the traditional UNIX format –Elf – executable and linking format –COFF – common object format –Plus lots of others

11 Variable initialisation Some is done by the compiler –.data instructions Some by the linker And some by the operating system

12 Elf format p_type p_offset p_vaddr p_filesz p_memsz p_flags p_type p_offset p_vaddr p_filesz p_memsz p_flags CODE DATA ‘E’ ‘L’ ‘F’ 0x8048090 52 2 e_indent e_entry e_phoff e_phentsize e_phnum PT_LOAD 0 0x804800 68532 PF_R, PF_X PT_LOAD 68536 0x8059BB8 2200 4248 PF_R, PF_W Physical Header Physical Header


Download ppt "UEE072HM Embedded Control Systems. Breaking down the compilation process Compilation is made up of a number of phases –Preprocessing –Compilation Can."

Similar presentations


Ads by Google