NAME elf_zscn_compressible SYNOPSIS cc [ flag ... ] file ... -lelf [ library ... ] #include int elf_zscn_compressible(Elf_Scn *scn, Elf_ZScn_Type ztype, const char *scn_name); DESCRIPTION elf_zscn_compressible is used to determine whether a given section can be compressed using a specified compression type. The ztype argument specifies the desired compression type, and can be one of the following. ELF_ZSCN_T_ZLIB ZLIB compression, ELF ABI format. ELF_ZSCN_T_ZLIB_GNU ZLIB compression, in the original GNU format. See NOTES. scn_name is the name of the section. It can be set to NULL under some circumstances, as described below. ELF sections that meet the following requirements can be compressed. Non-allocable The section must not have the SHF_ALLOC flag set. Type The section type must be SHT_PROGBITS, SHT_SUNW_DEBUGSTR, SHT_SUNW_DEBUG, or SHT_SUNW_ANNOTATE. Name The ELF_ZSCN_T_ZLIB_GNU compression type requires sections to have names starting with .debug. If ELF_ZSCN_T_ZLIB_GNU is specified, a non-NULL scn_name argument is required. ' For other compression types, it is convention that SHT_PROGBITS sections are only compressed if they have names that start with .compcom, .debug, .line, or .stab. if a non-NULL scn_name is provided, elf_zscn_compressible will check for these names. If scn_name is NULL, then then any non-allocable section with a valid section type is accepted. RETURN VALUE Upon failure, elf_zscn_compressible returns -1 and sets elf_errno. See elf_errno(3ELF). Otherwise, 1 is returned if the section can be compressed, and 0 if it cannot. If the section is already compressed, elf_zscn_compressible will return 1 if the section could be decompressed, and then recompressed into the desired format. EXAMPLES Example 1 Display compressible sections The following code fragment iterates over all the sections of an ELF object, and prints the section index and name for each section that can be compressed using the ELF_ZSCN_T_ZLIB compression type. The details of obtaining the section name, and error handling, are omitted in the interest of brevity. ndx = 1; for (scn = NULL; scn = elf_nextscn(elf, scn); ndx++) { scn_name = get_scn_name(...); status = elf_zscn_compressible(scn, ELF_ZSCN_T_ZLIB, scn_name); if (status == -1) error(...); if (status == 1) (void) printf("[%d] %s\n", ndx, scn_name); } NOTES The ELF_ZSCN_T_ZLIB_GNU compression type is deprecated, and is provided in order to support existing objects. The ELF_ZSCN_T_ZLIB type, which is not dependent on section name, is preferred. The ELF_ZSCN_T_ZLIB_GNU compression type can only be applied to sections with names that start with .debug. The scn_name argument is therefore required in order to determine if a section can be compressed in this type. If scn_name is NULL, elf_zscn_compressible will return 0. SEE ALSO elf_errno(3ELF), elf_zscn_compress(3ELF), elf_zscn_decompress(3ELF), elf_zscn_identify(3ELF), libelf(3LIB)