1 / 12

UEE0UQC122S3

UEE0UQC122S3. Special compilation problems for cross development. 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. The compilation process. cc –flags myfile.c thisfile.o.

Download Presentation

UEE0UQC122S3

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. UEE0UQC122S3 Special compilation problems for cross development

  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 Preprocessing Compilation Optimisation* Link/loading Assembler or Object format Relocatable Object file Executable Binary Text #includes .h header files #defines 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. Code Data BSS Heap Stack Program Segments 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 e_indent e_entry e_phoff e_phentsize e_phnum ‘E’ ‘L’ ‘F’ 0x8048090 52 52 2 PT_LOAD 0 0x804800 68532 68532 PF_R, PF_X p_type p_offset p_vaddr p_filesz p_memsz p_flags Physical Header p_type p_offset p_vaddr p_filesz p_memsz p_flags PT_LOAD 68536 0x8059BB8 2200 4248 PF_R, PF_W Physical Header CODE DATA

More Related