Crate goblin [] [src]

libGoblin

say the right words

libgoblin is a cross-platform trifecta of binary parsing and loading fun. Currently, it only supports the ELF format, in both 32-bit and 64-bit variants (with especial bias towards 64-bit formats). The mach parser is in progress, and the PE format will follow. libgoblin is engineered to be tailored towards very different use-case scenarios, for example:

  • a "pure" mode which includes no io, no std, and no fun!
  • a non-endian fd reading mode (which reads in the host machines endianness, for loaders)
  • cfg switches to turn off unused binary formats (when relocation and binary size are important (ideally, in the future this won't be necessary if the compiler and/or linker can guarantee the unused symbols are dropped in the final artifact)

Using the features

For example, if you are writing a kernel, or just want a barebones C-like header interface which defines the structures, enable the pure feature, --cfg feature=\"pure\", which will turn off std and remove all extra methods defined on the structs.

Similarly, if you want to use host endianness loading via the various from_fd methods, --cfg feature=\"no_endian_fd\", which will not use the byteorder extern crate, and read the bytes from disk in the endianness of the host machine.

Modules

elf

Access ELF constants, other helper functions, which are independent of ELF bithood. Also provides simple parser which returns an Elf64 or Elf32 "pre-built" binary. WARNING: to use the automagic ELF datatype union parser, you must enable both elf and elf32 features - i.e., do not use no_elf NOR no_elf32, otherwise you'll get obscure errors about goblin::elf::from_fd missing.

elf32

The ELF 32-bit struct definitions and associated values

elf64

The ELF 64-bit struct definitions and associated values

mach

The mach module: Work in Progress!