[ Previous | Next | Table of Contents | Index | Library Home | Legal | Search ]

Technical Reference: Base Operating System and Extensions, Volume 1


elf_flagdata, elf_flagehdr, elf_flagelf, elf_flagphdr, elf_flagscn, elf_flagshdr Subroutine

Purpose

Manipulate flags

Library

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

Description

Syntax


unsigned elf_flagdata(elf_Data * data, elf_Cmd cmd, unsigned flags);
unsigned elf_flagehdr(Elf * elf, elf_Cmd cmd, unsigned flags);
unsigned elf_flagelf(Elf * elf, elf_Cmd cmd, unsigned flags);
unsigned elf_flagphdr(Elf * elf, elf_Cmd cmd, unsigned flags);
unsigned elf_flagscn(elf_Scn * scn, elf_Cmd cmd, unsigned flags);
unsigned elf_flagshdr(elf_Scn * scn, elf_Cmd cmd, unsigned flags);

Description

These functions manipulate the flags associated with various structures of an ELF file. Given an ELF descriptor elf, a data descriptor data, or a section descriptor scn, the functions may set or clear the associated status bits, returning the updated bits. A null descriptor is allowed, to simplify error handling; all functions return zero for this degenerate case.

Parameters


cmd Specifies the bit action to perform on flags.

ELF_C_CLR
Clears the bits are asserted in flags. Only non-zero bits in flags are cleared; zero bits do not change the status of the descriptor.

ELF_C_SET
Sets the bits that are asserted in flags. Only the non-zero bits in flags are set; zero bits do not change the status of the descriptor.
flags Can be set to any of the below.

ELF_F_DIRTY
Asserts that information added by a program to an ELF file must be written to the file. For example, a program that wished to update the ELF header of an existing file would call elf_flagehdr with this bit set in flags and cmd equal to ELF_C_SET. A later call to elf_update would write the marked header to the file.

ELF_F_LAYOUT
Normally, the library decides how to arrange an output file. That is, it automatically decides where to place sections, how to align them in the file, etc. If this bit is set for an ELF descriptor, the program assumes responsibility for determining all file positions. This bit is meaningful only for elf_flagelf and applies to the entire file associated with the descriptor.

When a flag bit is set for an item, it affects all the sub-items as well. Thus, for example, if the program sets the ELF_F_DIRTY bit with elf_flagelf, the entire logical file is dirty.

Examples

The following code fragment shows how to mark the ELF header is it is written to the output file.

   ehdr = elf32_getehdr(elf);
   /* dirty ehdr...*/
   elf_flagehdr(elf, ELF_C_SET, ELF_F_DIRTY);

Related Information

The elf_end subroutine, elf_getdata subroutine, elf32_getehdr subroutine, elf64_getehdr subroutine, elf_update subroutine.

Introduction to ELF Subroutines.


[ Previous | Next | Table of Contents | Index | Library Home | Legal | Search ]