|
|
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
sections called .text, .data,
.bss,
.init and .fini.
The .text section contains the instruction text
(executable instructions), .data contains
initialized data variables, and .bss contains
uninitialized data variables.
Consider the following fragment of C code:
1 char abc[200]; 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
.text.
The .init section, if it exists, contains initialization
code used in static shared libraries.
The .fini section, 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.