We have a 3.9 release, update builds.pm
[maemo-rb.git] / utils / sbtools / elf.h
blobb145bfffc52f9eedf69cfc02a452f5bb88f8424b
1 #include <stdio.h>
2 #include <stdint.h>
3 #include <string.h>
4 #include <stdbool.h>
5 #include <stdlib.h>
6 #include <unistd.h>
8 /**
9 * API
11 enum elf_section_type_t
13 EST_LOAD,
14 EST_FILL
17 struct elf_section_t
19 uint32_t addr;
20 uint32_t size;
21 enum elf_section_type_t type;
22 /* <union> */
23 void *section;
24 uint32_t pattern;
25 /* </union> */
26 struct elf_section_t *next;
27 /* Internal to elf_write_file */
28 uint32_t offset;
31 struct elf_params_t
33 bool has_start_addr;
34 uint32_t start_addr;
35 struct elf_section_t *first_section;
36 struct elf_section_t *last_section;
39 typedef bool (*elf_read_fn_t)(void *user, uint32_t addr, void *buf, size_t count);
40 /* write function manages it's own error state */
41 typedef void (*elf_write_fn_t)(void *user, uint32_t addr, const void *buf, size_t count);
42 typedef void (*elf_printf_fn_t)(void *user, bool error, const char *fmt, ...);
44 void elf_init(struct elf_params_t *params);
45 void elf_add_load_section(struct elf_params_t *params,
46 uint32_t load_addr, uint32_t size, const void *section);
47 void elf_add_fill_section(struct elf_params_t *params,
48 uint32_t fill_addr, uint32_t size, uint32_t pattern);
49 void elf_write_file(struct elf_params_t *params, elf_write_fn_t write, void *user);
50 bool elf_read_file(struct elf_params_t *params, elf_read_fn_t read, elf_printf_fn_t printf,
51 void *user);
52 bool elf_is_empty(struct elf_params_t *params);
53 void elf_set_start_addr(struct elf_params_t *params, uint32_t addr);
54 bool elf_get_start_addr(struct elf_params_t *params, uint32_t *addr);
55 int elf_get_nr_sections(struct elf_params_t *params);
56 void elf_release(struct elf_params_t *params);