elf_flag(3E) MISC. REFERENCE MANUAL PAGES elf_flag(3E)
NAME
elfflagdata, elfflagehdr, elfflagelf, elfflagphdr,
elfflagscn, elfflagshdr - manipulate flags
SYNOPSIS
cc [flag ...] file ... -lelf [library ...]
#include <libelf.h>
unsigned elfflagdata(ElfData *data, ElfCmd cmd, unsigned flags);
unsigned elfflagehdr(Elf *elf, ElfCmd cmd, unsigned flags);
unsigned elfflagelf(Elf *elf, ElfCmd cmd, unsigned flags);
unsigned elfflagphdr(Elf *elf, ElfCmd cmd, unsigned flags);
unsigned elfflagscn(ElfScn *scn, ElfCmd cmd, unsigned flags);
unsigned elfflagshdr(ElfScn *scn, ElfCmd 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. cmd may have the following values.
ELFCCLR The functions clear the bits that are
asserted in flags. Only the non-zero bits
in flags are cleared; zero bits do not
change the status of the descriptor.
ELFCSET The functions set 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. Descrip-
tions of the defined flags bits appear
below.
ELFFDIRTY When the program intends to write an ELF
file, this flag asserts the associated
information needs to be written to the
file. Thus, for example, a program that
wished to update the ELF header of an
existing file would call elfflagehdr with
this bit set in flags and cmd equal to
ELFCSET. A later call to elfupdate
would write the marked header to the file.
ELFFLAYOUT Normally, the library decides how to
arrange an output file. That is, it
automatically decides where to place
Last change: ELF Library 1
elf_flag(3E) MISC. REFERENCE MANUAL PAGES elf_flag(3E)
sections, how to align them in the file,
etc. If this bit is set for an ELF
descriptor, the program assumes responsi-
bility for determining all file positions.
This bit is meaningful only for
elfflagelf and applies to the entire file
associated with the descriptor. When a
flag bit is set for an item, it affects
all the subitems as well. Thus, for exam-
ple, if the program sets the ELFFDIRTY
bit with elfflagelf, the entire logical
file is ``dirty.''
EXAMPLE
The following fragment shows how one might mark the ELF
header to be written to the output file.
ehdr = elf32getehdr(elf);
/* dirty ehdr ... */
elfflagehdr(elf, ELFCSET, ELFFDIRTY);
SEE ALSO
elf(3E), elfend(3E), elfgetdata(3E), elfgetehdr(3E),
elfupdate(3E).
Last change: ELF Library 2