summaryrefslogtreecommitdiff
path: root/other/burneye2/datahandler.h
blob: c2cae51e292d01fc70ab711cebe1ca53e8d0ad2f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/* datahandler.h - burneye2 .rodata/.data handling functions, include file
 *
 * by scut
 */

#ifndef	DATAHANDLER_H
#define	DATAHANDLER_H

typedef struct data_item {
	struct data_item *	next;	/* next linked list element or NULL */

	int		dangling;	/* 1 for "uncovered" space */
	int		endunsure;	/* 1 when the end is guessed */

	unsigned int	offset;	/* relative offset to section begin */
	unsigned int	length;	/* length of complete item */

	unsigned char *	data;	/* when non-NULL, its content */

	/* TODO: add other xref in here, also allow in-function jumps to branch
	 * level, for switch tables.
	 */
} data_item;


/* dh_item_new
 *
 * create a new data_item structure
 *
 * return pointer to new structure
 */

data_item *
dh_item_new (void);


/* dh_item_list_create_bysymreloc
 *
 * create an approximated item list of data section `datasec'. to do this,
 * first consult information from the symbol table given with `base', then
 * examine the relocation table `rel' for this section to find more subtile
 * data items within the section (switch tables, compile emitted constructs,
 * for which no symbol table entry is present).
 *
 * return root list element of data_item list on success
 * return NULL on failure
 */

data_item *
dh_item_list_create_bysymreloc (elf_base *base, elf_section *datasec,
	elf_rel_list *rel);


/* dh_carve
 *
 * carve the data object ranging `length' bytes from offset `offset' with its
 * data at `data' from the data item list `dh'. the space cut must be in
 * dangling state, else we will bail. assume the list going from `dh' is
 * sorted by dh_sort, with offset-ascending order.
 *
 * return new root data_item list item
 */

data_item *
dh_carve (data_item *dh, unsigned int offset, unsigned int length,
	unsigned char *data);

#endif