Bump builds.pm so that Rockbox Utility notices 3.11
[maemo-rb.git] / utils / imxtools / elf.h
blob21668332761b16c15bcc03f3bfb76c14a3b522c3
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
10 * Copyright (C) 2011 Amaury Pouly
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
21 #ifndef __ELF_H__
22 #define __ELF_H__
24 #include <stdio.h>
25 #include <stdint.h>
26 #include <string.h>
27 #include <stdbool.h>
28 #include <stdlib.h>
29 #include <unistd.h>
31 /**
32 * API
34 enum elf_section_type_t
36 EST_LOAD,
37 EST_FILL
40 struct elf_section_t
42 uint32_t addr; /* virtual address */
43 uint32_t size; /* virtual size */
44 enum elf_section_type_t type;
45 /* <union> */
46 void *section; /* data */
47 uint32_t pattern; /* fill pattern */
48 /* </union> */
49 struct elf_section_t *next;
50 /* Internal to elf_write_file */
51 uint32_t offset;
54 struct elf_segment_t
56 uint32_t vaddr; /* virtual address */
57 uint32_t paddr; /* physical address */
58 uint32_t vsize; /* virtual size */
59 uint32_t psize; /* physical size */
60 struct elf_segment_t *next;
63 struct elf_params_t
65 bool has_start_addr;
66 uint32_t start_addr;
67 struct elf_section_t *first_section;
68 struct elf_section_t *last_section;
69 struct elf_segment_t *first_segment;
70 struct elf_segment_t *last_segment;
73 typedef bool (*elf_read_fn_t)(void *user, uint32_t addr, void *buf, size_t count);
74 /* write function manages it's own error state */
75 typedef void (*elf_write_fn_t)(void *user, uint32_t addr, const void *buf, size_t count);
76 typedef void (*elf_printf_fn_t)(void *user, bool error, const char *fmt, ...);
78 void elf_init(struct elf_params_t *params);
79 void elf_add_load_section(struct elf_params_t *params,
80 uint32_t load_addr, uint32_t size, const void *section);
81 void elf_add_fill_section(struct elf_params_t *params,
82 uint32_t fill_addr, uint32_t size, uint32_t pattern);
83 uint32_t elf_translate_virtual_address(struct elf_params_t *params, uint32_t addr);
84 void elf_translate_addresses(struct elf_params_t *params);
85 void elf_write_file(struct elf_params_t *params, elf_write_fn_t write, elf_printf_fn_t printf, void *user);
86 bool elf_read_file(struct elf_params_t *params, elf_read_fn_t read, elf_printf_fn_t printf,
87 void *user);
88 bool elf_is_empty(struct elf_params_t *params);
89 void elf_set_start_addr(struct elf_params_t *params, uint32_t addr);
90 bool elf_get_start_addr(struct elf_params_t *params, uint32_t *addr);
91 int elf_get_nr_sections(struct elf_params_t *params);
92 void elf_release(struct elf_params_t *params);
94 #endif /* __ELF_H__ */