From 9b92536e6c51b66406d593745a938975e226f95e Mon Sep 17 00:00:00 2001 From: Timothy Pearson Date: Sat, 27 Dec 2014 08:13:20 -0600 Subject: Initial import --- src/libr-ro.h | 62 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 src/libr-ro.h (limited to 'src/libr-ro.h') diff --git a/src/libr-ro.h b/src/libr-ro.h new file mode 100644 index 0000000..8b8e41a --- /dev/null +++ b/src/libr-ro.h @@ -0,0 +1,62 @@ +#ifndef __LIBRRO_H +#define __LIBRRO_H + +/* For file handle support */ +#include + +/* For integer types with set bit-sizes */ +#include + +/* + * NOTE: Packing the enum uses the smallest number of bytes + * possible to represent the value. This packing does not + * guarantee that a "short enum" will be 8 bits, however, + * for the small enumerations in the ELF specification this + * IS the case (no enum requires more than 8 bits). + */ +#define SHORT_ENUM __attribute__ ((__packed__)) + +/* Type of byte-packing (endian) */ +typedef enum SHORT_ENUM { + ELFDATANONE, /* Invalid */ + ELFDATA2LSB, /* Least Significant Byte First */ + ELFDATA2MSB, /* Most Significant Byte First */ + ELFDATAMAX, /* Invalid */ +} eEncoding; + +/* Type of target processor */ +typedef enum SHORT_ENUM { + ELFCLASSNONE, /* Invalid */ + ELFCLASS32, /* 32-bit Field Alignment */ + ELFCLASS64, /* 64-bit Field Alignment */ + ELFCLASSMAX, /* Invalid */ +} eClass; + +#ifndef DOXYGEN_SHOULD_SKIP_THIS + +#define ELFSTRING_MAX 200 +typedef struct _libr_section { + uint64_t size; + uint64_t data_offset; + uint32_t name_offset; + char name[ELFSTRING_MAX]; +} libr_section; + +typedef struct _libr_file { + FILE *handle; + char *filename; + eEncoding endian; + eClass byte_size; + libr_access_t access; + libr_section *secdata; + unsigned long total_sections; +} libr_file; + +#endif /* DOXYGEN_SHOULD_SKIP_THIS */ + +/* for a clean internal API */ +typedef void libr_data; + +#define enum_valid(val, name) (val > name##NONE && val < name##MAX) + +#endif /* __LIBRRO_H */ -- cgit v1.2.1