- int num_sections; /* number of sections contained in the image */
- image_section_t *sections; /* array of sections */
- int base_address_set; /* whether the image has a base address set (for relocation purposes) */
- int base_address; /* base address, if one is set */
- int start_address_set; /* whether the image has a start address (entry point) associated */
- u32 start_address; /* start address, if one is set */
- char error_str[IMAGE_MAX_ERROR_STRING];
-} image_t;
-
-typedef struct image_binary_s
-{
- fileio_t fileio;
-} image_binary_t;
-
-typedef struct image_ihex_s
-{
- fileio_t fileio;
- u8 *buffer;
-} image_ihex_t;
-
-typedef struct image_memory_s
-{
- target_t *target;
- u8 *cache;
- u32 cache_address;
-} image_memory_t;
-
-typedef struct fileio_elf_s
-{
- fileio_t fileio;
- Elf32_Ehdr *header;
- Elf32_Phdr *segments;
- u32 segment_count;
- u8 endianness;
-} image_elf_t;
-
-typedef struct image_mot_s
-{
- fileio_t fileio;
- u8 *buffer;
-} image_mot_t;
-
-extern int image_open(image_t *image, char *url, char *type_string);
-extern int image_read_section(image_t *image, int section, u32 offset, u32 size, u8 *buffer, u32 *size_read);
-extern int image_close(image_t *image);
-extern int image_add_section(image_t *image, u32 base, u32 size, int flags, u8 *data);
+ unsigned int num_sections; /* number of sections contained in the image */
+ struct imagesection *sections; /* array of sections */
+ bool base_address_set; /* whether the image has a base address set (for relocation purposes) */
+ long long base_address; /* base address, if one is set */
+ bool start_address_set; /* whether the image has a start address (entry point) associated */
+ uint32_t start_address; /* start address, if one is set */
+};
+
+struct image_binary {
+ struct fileio *fileio;
+};
+
+struct image_ihex {
+ struct fileio *fileio;
+ uint8_t *buffer;
+};
+
+struct image_memory {
+ struct target *target;
+ uint8_t *cache;
+ uint32_t cache_address;
+};
+
+struct image_elf {
+ struct fileio *fileio;
+ bool is_64_bit;
+ union {
+ Elf32_Ehdr *header32;
+ Elf64_Ehdr *header64;
+ };
+ union {
+ Elf32_Phdr *segments32;
+ Elf64_Phdr *segments64;
+ };
+ uint32_t segment_count;
+ uint8_t endianness;
+};
+
+struct image_mot {
+ struct fileio *fileio;
+ uint8_t *buffer;
+};
+
+int image_open(struct image *image, const char *url, const char *type_string);
+int image_read_section(struct image *image, int section, target_addr_t offset,
+ uint32_t size, uint8_t *buffer, size_t *size_read);
+void image_close(struct image *image);
+
+int image_add_section(struct image *image, target_addr_t base, uint32_t size,
+ uint64_t flags, uint8_t const *data);
+
+int image_calculate_checksum(const uint8_t *buffer, uint32_t nbytes,
+ uint32_t *checksum);