() causes the library to recalculate the structure of an ELF object and optionally write out the image of the object to file.
File Layout
If the
ELF_F_LAYOUT flag has been set on the ELF descriptor, the application assumes full responsibility for the layout of the ELF object. If this flag is not set, the ELF library will compute the layout of the file from its associated section descriptors.
It is the application's responsibility to manage the the following structure members in the ELF file:
-
Executable Header
-
The ELF executable header is described in elf(5). The following members of the ELF executable header are the application's responsibility:
-
e_entry
-
Set to the desired entry address for executables.
-
e_flags
-
Set to the desired processor specific flags.
-
e_ident[EI_DATA]
-
Must be set to one of ELFDATA2LSB or ELFDATA2MSB.
-
e_ident[EI_OSABI]
-
Set to the OS ABI desired. For FreeBSD executables, this field should be set to ELFOSABI_FREEBSD.
-
e_machine
-
Set to the desired machine architecture, one of the EM_* values in <sys/elf_common.h>.
-
e_phoff
-
If the application is managing the object's layout, it must set this field to the file offset of the ELF program header table.
-
e_shoff
-
If the application is managing the object's layout, it must set this field to the file offset of the ELF section header table.
-
e_shstrndx
-
Set to the index of the string table containing section names.
-
e_type
-
Set to the type of the ELF object, one of the ET_* values in <sys/elf_common.h>.
-
e_version
-
Set to the desired version of the ELF object.
-
Program Header
-
All fields of the entries in the program header table are under application control.
-
Section Header
-
The ELF section header is described in elf(5). The following members of the ELF section header are the application's responsibility:
-
sh_addr
-
Set to the physical memory address where the section should reside.
-
sh_addralign
-
If the application is managing the file layout, it must set this field to the desired alignment for the section's contents. This value must be a power of two.
-
sh_entsize
-
Set to the size of each entry, for sections containing fixed size elements, or set to zero for sections without fixed size elements. If the application is not managing file layout, it may leave this field as zero for those sections whose types known to the library.
-
sh_flags
-
Set to the desired section flags.
-
sh_info
-
Set as described in elf(5).
-
sh_link
-
Set as described in elf(5).
-
sh_name
-
Set to the index of the section's name in the string table containing section names.
-
sh_offset
-
If the application is managing the file layout, it must set this field to the file offset of the section's contents.
-
sh_size
-
If the application is managing the file layout, it must set this field to the file size of the section's contents.
-
sh_type
-
Set to the type of the section.
Gaps in the coverage of the file's contents will be set to the fill value specified by elf_fill(3).
If the application has requested full control over the file's layout by setting the ELF_F_LAYOUT flag on the ELF descriptor, it should ensure that there are no gaps in the coverage of the file's contents.
All pointers to Elf_Scn and Elf_Data descriptors associated with descriptor elf should be considered as invalid after a call to elf_update().