HP-UX Reference (11i v2 04/09) - 3 Library Functions A-M (vol 6)

e
elf_update(3E) elf_update(3E)
p_memsz
p_flags
p_align
Member Notes
sh_name
sh_type
sh_flags
sh_addr
sh_offset Only when ELF_F_LAYOUT
asserted
Section Header sh_size Only when ELF_F_LAYOUT
asserted
sh_link
sh_info
sh_addralign Only when ELF_F_LAYOUT
asserted
sh_entsize
Member Notes
d_buf
d_type
d_size
Data Descriptor d_off Only when ELF_F_LAYOUT
asserted
d_align
d_version
Note the program is responsible for two particularly important members (among others) in the ELF
header. The e_version member controls the version of data structures written to the file. If the ver-
sion is EV_NONE, the library uses its own internal version. The e_ident[EI_DATA]
entry controls the
data encoding used in the file. As a special case, the value may be
ELFDATANONE
to request the native
data encoding for the host machine. An error occurs in this case if the native encoding doesn’t match a
file encoding known by the library.
Further note that the program is responsible for the
sh_entsize
section header member. Although the
library sets it for sections with known types, it cannot reliably know the correct value for all sections.
Consequently, the library relies on the program to provide the values for unknown section type. If the
entry size is unknown or not applicable, the value should be set to zero.
When deciding how to build the output file,
elf_update obeys the alignments of individual data buffers
to create output sections. A section’s most strictly aligned data buffer controls the section’s alignment.
The library also inserts padding between buffers, as necessary, to ensure the proper alignment of each
buffer.
NOTICES
As mentioned above, the
ELF_C_WRITE commands translate data as necessary, before writing them to
the file. This translation is not always transparent to the application program. If a program has
obtained pointers to data associated with a file (for example, see elf_getehdr (3E) and elf_getdata (3E)), the
program should reestablish the pointers after calling elf_update.
As elf_begin (3E) describes, a program may ‘‘update a COFF file to make the image consistent for ELF.
(COFF is an object file format that preceded ELF on some computer architectures (Intel, for example).
When a program calls elf_begin on a COFF file, the library translates COFF structures to their ELF
equivalents, allowing programs to read (but not to write) a COFF file as if it were ELF. This conversion
happens only to the memory image and not to the file itself.) The
ELF_C_NULL command updates only
the memory image; one can use the ELF_C_WRITE command to modify the file as well. Absolute execut-
able files (a.out files) require special alignment, which cannot normally be preserved between COFF
and ELF. Consequently, one may not update an executable COFF file with the ELF_C_WRITE command
(though ELF_C_NULL is allowed).
SEE ALSO
elf(3E), elf_begin(3E), elf_flag(3E), elf_fsize(3E), elf_getdata(3E), elf_getehdr(3E), elf_getshdr(3E),
elf_xlate(3E).
HP-UX 11i Version 2: September 2004 2 Hewlett-Packard Company Section 3267