Next: GNU Free Documentation License, Previous: Introduction, Up: R6RS-Elf [Contents][Index]
The r6rs-elf API is named ‘(parser elf)’. We describe the naming scheme for the procedures in the library. Procedures such as ‘read-*-bytes!’ will read an ELF structure into a bytevector. Procedures such as ‘parse-*’ will parse a Scheme record out of the data in a bytevector. For convenience and at the cost of some temporary extra memory, the two can be combined with ‘read-*’ which will allocate its own bytevector and parse the read data. The number of bytes to be read or parsed by these procedures is given by ‘parse-*-len’, which takes a class parameter determining the architecture, i.e. ‘ELFCLASS32’ for 32-bit and ‘ELFCLASS64’ for 64-bit. All the relevant constants are defined in ‘(parser elf enums)’. Finally, there are the ‘for-each-*’ procedures that will iterate over all instances of a given kind of ELF structure, reading and parsing them one by one and then apply a given procedure on each. Note that in order for these for-each procedures to work, the port must support positioning (seeking).
A typical usage of this library would open a file as a binary input port; read its ELF header with ‘read-elf-header’, then iterate over either the program headers (with ‘for-each-program-header’) or the section headers (with ‘for-each-section-header’), collecting those of interest, and then it would operate on the header entries with procedures such as ‘for-each-rel’ (for relocation entries), ‘for-each-note’ (for ELF notes) and so on.