Oracle® Solaris 11.2 Linkers and Libraries Guide

Exit Print View

Updated: July 2014
 
 

Section Compression

The SHF_COMPRESSED section flag identifies a section containing compressed data. SHF_COMPRESSED applies only to non-allocable sections, and cannot be used in conjunction with SHF_ALLOC. In addition, SHF_COMPRESSED cannot be applied to sections of type SHT_NOBITS.

Any relocations that must be applied to a compressed section specify offsets to the uncompressed section data. It is therefore necessary to uncompress section data before relocations can be applied. Each compressed section specifies the algorithm independently. Different sections in a given ELF object can employ different compression algorithms.

Compressed sections start with a compression header structure that identifies the compression algorithm.

typedef struct {
        Elf32_Word      ch_type;
        Elf32_Word      ch_size;
        Elf32_Word      ch_addralign;
} Elf32_Chdr;

typedef struct {
        Elf64_Word      ch_type;
        Elf64_Word      ch_reserved;
        Elf64_Xword     ch_size;
        Elf64_Xword     ch_addralign;
} Elf64_Chdr;
ch_type

Specifies the compression algorithm. Supported algorithms and their descriptions are listed in Table 12–10.

ch_size

The size in bytes of the uncompressed data. See sh_size.

ch_addralign

Required alignment for the uncompressed data. See sh_addralign.

The sh_size and sh_addralign fields of the section header for a compressed section reflect the requirements of the compressed section. The ch_size and ch_addralign fields of the compression header provide the corresponding values for the uncompressed data, thereby supplying the values that sh_size and sh_addralign would have if the section had not been compressed.

The layout and interpretation of the data that follows the compression header is specific to each algorithm. This layout may contain algorithm specific parameters and alignment padding in addition to compressed data bytes.

A compression header's ch_type member specifies the compression algorithm employed, as shown in the following table.

Table 12-10  ELF Compression Types, ch_type
Name
Value
ELFCOMPRESS_ZLIB
1
ELFCOMPRESS_LOOS
0x60000000
ELFCOMPRESS_HIOS
0x6fffffff
ELFCOMPRESS_LOPROC
0x70000000
ELFCOMPRESS_HIPROC
0x7fffffff
ELFCOMPRESS_ZLIB

The section data is compressed with the ZLIB compression algorithm. The compressed ZLIB data bytes begin with the byte immediately following the compression header, and extend to the end of the section. Documentation for ZLIB may be found at http://www.zlib.net/.

ELFCOMPRESS_LOOS - ELFCOMPRESS_HIOS

Values in this inclusive range are reserved for operating system-specific semantics.

ELFCOMPRESS_LOPROC - ELFCOMPRESS_HIPROC

Values in this inclusive range are reserved for processor-specific semantics.