Oracle® Solaris 11.2 Linkers and Libraries Guide

Exit Print View

Updated: July 2014
 
 

Move Section

Typically, within ELF files, initialized data variables are maintained within the object file. If a data variable is very large, and contains only a small number of initialized (nonzero) elements, the entire variable is still maintained in the object file.

Objects that contain large partially initialized data variables, such as FORTRAN COMMON blocks, can result in a significant disk space overhead. The SHT_SUNW_move section provides a mechanism of compressing these data variables. This compression reduces the disk size of the associated object.

The SHT_SUNW_move section contains multiple entries of the type ELF32_Move or Elf64_Move. These entries allow data variables to be defined as tentative items (.bss). These items occupy no space in the object file, but contribute to the object's memory image at runtime. The move records establish how the memory image is initialized with data to construct the complete data variable.

ELF32_Move and Elf64_Move entries are defined as follows.

typedef struct {
        Elf32_Lword       m_value;
        Elf32_Word        m_info;
        Elf32_Word        m_poffset;
        Elf32_Half        m_repeat;
        Elf32_Half        m_stride;
} Elf32_Move;

#define ELF32_M_SYM(info)       ((info)>>8)
#define ELF32_M_SIZE(info)      ((unsigned char)(info))
#define ELF32_M_INFO(sym, size) (((sym)<<8)+(unsigned char)(size))

typedef struct {
        Elf64_Lword       m_value;
        Elf64_Xword       m_info;
        Elf64_Xword       m_poffset;
        Elf64_Half        m_repeat;
        Elf64_Half        m_stride;
} Elf64_Move;

#define ELF64_M_SYM(info)       ((info)>>8)
#define ELF64_M_SIZE(info)      ((unsigned char)(info))
#define ELF64_M_INFO(sym, size) (((sym)<<8)+(unsigned char)(size))

The elements of these structures are as follows.

m_value

The initialization value, which is the value that is moved into the memory image.

m_info

The symbol table index, with respect to which the initialization is applied, together with the size, in bytes, of the offset being initialized. The lower 8 bits of the member define the size, which can be 1, 2, 4 or 8. The upper bytes define the symbol index.

m_poffset

The offset relative to the associated symbol to which the initialization is applied.

m_repeat

A repetition count.

m_stride

The stride count. This value indicates the number of units that should be skipped when performing a repetitive initialization. A unit is the size of an initialization object as defined by m_info. An m_stride value of zero indicates that the initialization be performed contiguously for units.

The following data definition would traditionally consume 0x8000 bytes within an object file.

typedef struct {
        int     one;
        char    two;
} Data;

Data move[0x1000] = {
        {0, 0},       {1, '1'},     {0, 0},
        {0xf, 'F'},   {0xf, 'F'},   {0, 0},
        {0xe, 'E'},   {0, 0},       {0xe, 'E'}
};

A SHT_SUNW_move section can be used to describe this data. The data item is defined within the .bss section. The non-zero elements of the data item are initialized with the appropriate move entries.

$ elfdump -s data | fgrep move
    [17]    0x20868   0x8000  OBJT GLOB 0   .bss       move
$ elfdump -m data

Move Section:  .SUNW_move
  symndx     offset   size repeat stride            value  with respect to
    [17]       0x44      4      1      1       0x45000000  move
    [17]       0x40      4      1      1              0xe  move
    [17]       0x34      4      1      1       0x45000000  move
    [17]       0x30      4      1      1              0xe  move
    [17]       0x1c      4      2      1       0x46000000  move
    [17]       0x18      4      2      1              0xf  move
    [17]        0xc      4      1      1       0x31000000  move
    [17]        0x8      4      1      1              0x1  move

Move sections that are supplied from relocatable objects are concatenated and output in the object being created by the link-editor. However, the following conditions cause the link-editor to process the move entries. This processing expands the move entry contents into a traditional data item.

  • The output file is a static executable.

  • The size of the move entries is greater than the size of the symbol into which the move data would be expanded.

  • The –z nopartial option is in effect.