as: Ld Sections
1
1 4.2 Linker Sections
1 ===================
1
1 'ld' deals with just four kinds of sections, summarized below.
1
1 *named sections*
1 *text section*
1 *data section*
1 These sections hold your program. 'as' and 'ld' treat them as
1 separate but equal sections. Anything you can say of one section
1 is true of another. When the program is running, however, it is
1 customary for the text section to be unalterable. The text section
1 is often shared among processes: it contains instructions,
1 constants and the like. The data section of a running program is
1 usually alterable: for example, C variables would be stored in the
1 data section.
1
1 *bss section*
1 This section contains zeroed bytes when your program begins
1 running. It is used to hold uninitialized variables or common
1 storage. The length of each partial program's bss section is
1 important, but because it starts out containing zeroed bytes there
1 is no need to store explicit zero bytes in the object file. The
1 bss section was invented to eliminate those explicit zeros from
1 object files.
1
1 *absolute section*
1 Address 0 of this section is always "relocated" to runtime address
1 0. This is useful if you want to refer to an address that 'ld'
1 must not change when relocating. In this sense we speak of
1 absolute addresses being "unrelocatable": they do not change during
1 relocation.
1
1 *undefined section*
1 This "section" is a catch-all for address references to objects not
1 in the preceding sections.
1
1 An idealized example of three relocatable sections follows. The
1 example uses the traditional section names '.text' and '.data'. Memory
1 addresses are on the horizontal axis.
1
1 +-----+----+--+
1 partial program # 1: |ttttt|dddd|00|
1 +-----+----+--+
1
1 text data bss
1 seg. seg. seg.
1
1 +---+---+---+
1 partial program # 2: |TTT|DDD|000|
1 +---+---+---+
1
1 +--+---+-----+--+----+---+-----+~~
1 linked program: | |TTT|ttttt| |dddd|DDD|00000|
1 +--+---+-----+--+----+---+-----+~~
1
1 addresses: 0 ...
1