Program Sections

Program sections are labeled collections of program objects. The simplest program sections are .text, .data, .rodata, and .bss. The .text section holds program code. The .data section holds external variables with explicitly initialized values such as int i=1;. The .rodata section holds compiler generated constants and read-only variables. The .bss section holds variables which are not explicitly initialized. In most systems, the runtime or operating system initializes the .bss section to all zeros. This zero initialization is required by the C and C++ languages.

The compiler assigns various data and text objects to the appropriate sections at compile-time. The linker's job is to collect all data for each named section and to locate that section in memory. In doing this, it is guided by a user-supplied or default linker section map. The section map specifies the desired location of each section and also the order of the sections in the final output file.

In addition to the above sections, you can create sections and assign them to specific regions of memory. You can also assign variables to the user-defined sections. You have the flexibility to position variables and other program objects in memory.

The linker provides definitions for several symbols which, if referenced and not defined, are given certain addresses corresponding to the final image. These symbols are constructed by prepending the strings _ _ghsbegin and _ _ghsend to the name of each section in the final image, with any period (.) in the section names changed to underscores (_). For example, for a section named .text, the symbols _ _ghsbegin_text and _ _ghsend_text would revert to the virtual start and end addresses of that section, respectively.


Previous

Next



Copyright © 1999, Green Hills Software. All rights reserved.