ELF Library
(require elf) | package: elf |
1 Introduction
This library can read and write files in the exectuable and linking format common among unix like systems.
Due to the nature of overlapping binary data in ELF files, the library is strict in terms of write offsets and lengths. It is therefor the users responsibility to ensure that the length and offset fields in the headers are adjusted properly should the length of binary data be changed.
See the ELF man page elf(5) for more general information on the executable and linking format.
2 Reference
struct
(struct elf-header ( class data version abi abiver type machine entry prog-headers section-headers flags header-size prog-header-size prog-header-count sec-header-size sec-header-count sec-index)) class : integer? data : integer? version : integer? abi : integer? abiver : integer? type : integer? machine : integer? entry : integer? prog-headers : integer? section-headers : integer? flags : integer? header-size : integer? prog-header-size : integer? prog-header-count : integer? sec-header-size : integer? sec-header-count : integer? sec-index : integer?
struct
(struct program-header ( type offset v-addr p-addr file-size mem-size flags align data)) type : integer? offset : integer? v-addr : integer? p-addr : integer? file-size : integer? mem-size : integer? flags : integer? align : integer? data : bytes?
struct
(struct section-header ( name type flags addr offset size link info addralign entsize data)) name : integer? type : integer? flags : integer? addr : integer? offset : integer? size : integer? link : integer? info : integer? addralign : integer? entsize : integer? data : bytes?
The data field is unused currently.
Returns a list consisting of an ELF header datastructure, a list of program-header, a list of section-header and 3 remaining elements of byte-string. One for data following the ELF header, another for data after the program headers and finally one for everything after the section headers.
Endianess and data (32 or 64 bit) should be set in the respective header fields, if someone needs to change them explictly.
procedure
(read-elf-program-header stream [ size endianess]) → program-header? stream : (file-stream-port?) size : (boolean?) = false endianess : (boolean?) = false
procedure
stream : (file-stream-port?) size : (boolean?) = false endianess : (boolean?) = false
procedure
(write-section-header section-header stream [ data-size endianess]) → void? section-header : (section-header?) stream : (output-port?) data-size : (boolean?) = false endianess : (boolean?) = false
3 Copyright and contact
Writen by "Code_Man". Send feedback to Code_Man_AT_Cybnet.ch. See code_man.cybnet.ch for more stuff of mine.
No implied warranties or liability of any kind, use at own risk.