User Tools

Site Tools


solaris:elf_compress.3elf

elf_compress


NAME

elf_compress, elf_compress_gnu - compress/decompress section data

SYNOPSIS

cc [ flag … ] file-lelf [ library … ]
#include <libelf.h>

int elf_compress(Elf_Scn *scn, uint_t type, uint_t flags);

int elf_compress_gnu(Elf_Scn *scn, int inflate, uint_t flags);

DESCRIPTION

elf_compress() is used to compress or decompress an ELF section. The type argument specifies the desired compression type, and can be one of the following.

0

Decompress any compressed content.

ELF_COMPRESS_ZLIB

ZLIB compression, ELF ABI format.

elf_compress_gnu() is used to compress or decompress an ELF section using the original GNU compression format. inflate is set to 1 to decompress, and 0 to compress.

The flags argument is used to specify compression options. The flags argument can be 0, or can be set to the following value.

ELF_CHF_FORCE

In rare cases, compression algorithms can produce data larger than the original uncompressed data. The default behavior of elf_compress() and elf_compress_gnu() are to compress a given section only if the resulting section is reduced in size. Set ELF_CHF_FORCE to require that the section always be compressed.

RETURN VALUES

If an error occurs, elf_compress() and elf_compress_gnu() return -1 and set elf_errno().

If the section was not compressed because the resulting data would be larger than the original, 0 is returned and the section is unaltered.

If the section is successfully compressed, elf_compress() and elf_compress_gnu() update the section header, and the original data associated with the section is replaced. Any information previously returned for the section by elf32_getshdr(), elf64_shdr(), or elf_getdata(), is invalidated, and should no longer be referenced by the caller. The caller should defer calling those functions until after calling elf_compress() or elf_compress_gnu(), or should call them again afterwards in order to obtain the new information.

ATTRIBUTES

See attributes(7) for descriptions of the following attributes:

SEE ALSO

elf(3ELF), elf32_getchdr(3ELF), elf32_getshdr(3ELF), elf32_xlatetof(3ELF), elf64_getchdr(3ELF), elf64_getshdr(3ELF), elf64_xlatetof(3ELF), elf_errno(3ELF), elf_flagshdr(3ELF), elf_getdata(3ELF), elf_getscn(3ELF), elf_update(3ELF), libelf(3LIB), attributes(7)

NOTES

elf_compress() and elf_compress_gnu() do not set the the ELF_F_DIRTY flag for the section. The caller must explicitly call elf_flagshdr() in order to keep the changes when elf_update() is used.

elf_compress() and elf_compress_gnu() will reject a compression attempt for a section that is already compressed. The caller must first decompress the section, and then compress it into the desired format.

elf_compress() and elf_compress_gnu() will reject a decompression attempt for a section that is already uncompressed.

The original GNU compression format is deprecated. elf_compress_gnu() is provided in order to support existing objects. The use of elf_compress() when creating new objects is recommended. The original GNU compression format can only be applied to sections with names that start with .debug. On compression, that type requires the name to be altered to start with .zdebug. elf_compress_gnu() does not provide the replacement name. The caller is responsible for providing the replacement name.


solaris/elf_compress.3elf.txt · Last modified: 2023/07/19 08:57 by A User Not Logged in