This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Compiler: Object File Format, a.out, COFF, ELF. Microcontroller Execution of these file formats

Other Parts Discussed in Thread: TMS320F2812

Tool/software: TI C/C++ Compiler

Hi, 

My questions my look silly, so sorry in advance. Following are my questions.

a) Why Object files (a.out, COFF, ELF) are divided into logical sections like .text, .data, .bss etc. what is the reason behind it? why we need to have sections in Object files??

b) what was the need to all these file formats like if we had a.out format, why COFF format was developed, similarly ELF file format??? what factor forced the need of new FILE FORMAT???

c) How Microcontroller executes them, like if we have a.out file and we burn it to let say TMS320F2812 DSC flash, how will Microcontroller differentiate between different sections and how will it execute this a.out file?? what Microcontroller has to do with a.out headers that are usually required to create new process from Object file in PC.???

d) When an Object file is executed, how the addresses that linker assign to different sections/variable in Object file is satisfied in RAM e.g. if linker given addresses are from 0-to-MAX_SIZE, when this process is loaded into RAM by OS Loader at different pages frames not starting from location 0, then how this process expect addresses from 0-to-MAX_SIZE during execution?? is virtual address space or offset is used??

  • a- because while your program might intersperse the data and code, it does not make sense to do this in the machine. If you set aside a memory location for 'i' right before a loop, the compiler would have to branch around it. It makes sense for the compiler to keep everything separate so it can better keep track of things. Besides, if you are running from flash your variables can't be there anyway.

    b-because every OS designer thinks they can do it better. 8^)

    c- Often the controller does not care, it just loads the whole thing, starts execution at a specified point and lets the program figure it out.

    d- it depends on the OS, the processor and some other things. Note that in our case here there is *NO* OS. It is only your program. In C terms, it is a conforming freestanding implementation - though the debugger tends to fuzz that up a bit.
  • Rather then reply to your questions directly, I'll give you some related things to think about.

    For an overview of object file formats used by TI tools, please the wiki article A Brief History of TI Object File Formats.

    To see some code that works with the structures found in object files, take a look at the bootimage script in the cg_xml package.

    Thanks and regards,

    -George