Object files are produced both by the assembler as(CP) (may be called by the compiler internally) and by ld(CP). ld accepts relocatable object files as input and produces an output object file that may or may not be relocatable. Under certain special circumstances, the object files given to ld can also be executable files.
Files produced by compilation may contain
.text section contains the instruction text
initialized data variables, and
uninitialized data variables.
Consider the following fragment of C code:
1 char abc; 2 int i = 100; 3 4 i = 0;The uninitialized variable abc (line 1) is located in
.bss, the initialized variable i (line 2) is located in
.data, compiled code from the C assignment (line 4) is stored in
.initsection, if it exists, contains initialization code used in static shared libraries. The
.finisection, if it exists, contains finalization code used in static shared libraries. Sections with names other than these may be present in object files created by ld.