Next: Parsing procedures, Previous: Record constructors, Up: r6rs-elf API [Contents][Index]
There are two types of single-entry reading procedures. One type is raw byte reading into provided bytevectors; the other type will allocate its own bytevector and also parse, to return an ELF record (see Record constructors).
The former type of read procedures is named ‘read-*-bytes!’ and writes into its provided bytevector. These procedures are more space-efficient as the library user can reuse a single bytevector with them.
Both types of IO procedures expect the user to have navigated the port
to the exact point where the structure occurs before their use. Thus,
if the port position has advanced, you cannot use ‘read-elf-header’
to read the ELF header; you should first reposition the port (say, with
set-port-position!) to the beginning of the file where the ELF
header occurs.
For further convenience, there are also looping constructs which perform
IO. The user typically wishes to use those to e.g. process every
program header entry; or every note entry; and so on. These constructs
only work on ports with a port position available, because they
need to seek to various parts of the ELF file. To use them on pipes or
other ports with no port position available, first read enough of the
port into a bytevector, and create a new port from the bytevector with
open-bytevector-input-port.