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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
|
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Samsung Exynos SoC series dsp driver
*
* Copyright (c) 2019 Samsung Electronics Co., Ltd.
* http://www.samsung.com/
*/
#ifndef __DL_DSP_ELF_LOADER_H__
#define __DL_DSP_ELF_LOADER_H__
#include "dl/dsp-common.h"
#include "dl/dsp-hash.h"
#include "dl/dsp-list.h"
struct dsp_lib;
enum {
EI_MAG0 = 0,
EI_MAG1 = 1,
EI_MAG2 = 2,
EI_MAG3 = 3,
EI_CLASS = 4,
EI_DATA = 5,
EI_VERSION = 6,
EI_OSABI = 7,
EI_ABIVERSION = 8,
EI_PAD = 9,
EI_NIDENT = 16
};
#pragma pack(push, 4)
struct dsp_elf32_hdr {
unsigned char e_ident[EI_NIDENT];
unsigned short e_type;
unsigned short e_machine;
unsigned int e_version;
unsigned int e_entry;
unsigned int e_phoff;
unsigned int e_shoff;
unsigned int e_flags;
unsigned short e_ehsize;
unsigned short e_phentsize;
unsigned short e_phnum;
unsigned short e_shentsize;
unsigned short e_shnum;
unsigned short e_shstrndx;
};
struct dsp_elf32_shdr {
unsigned int sh_name;
unsigned int sh_type;
unsigned int sh_flags;
unsigned int sh_addr;
unsigned int sh_offset;
unsigned int sh_size;
unsigned int sh_link;
unsigned int sh_info;
unsigned int sh_addralign;
unsigned int sh_entsize;
};
struct dsp_elf32_sym {
unsigned int st_name;
unsigned int st_value;
unsigned int st_size;
unsigned char st_info;
unsigned char st_other;
unsigned short st_shndx;
};
struct dsp_elf32_rela {
unsigned int r_offset;
unsigned int r_info;
unsigned int r_addend;
};
struct dsp_elf32_idx_node {
int idx;
struct dsp_list_node node;
};
struct dsp_elf32_rela_node {
int idx;
struct dsp_elf32_rela *rela;
size_t rela_num;
struct dsp_list_node node;
};
struct dsp_elf32_mem {
struct dsp_list_head robss;
struct dsp_list_head rodata;
struct dsp_list_head bss;
struct dsp_list_head data;
struct dsp_list_head rela;
};
struct dsp_elf32_text {
struct dsp_list_head text;
struct dsp_list_head rela;
};
struct dsp_elf32 {
char *data;
size_t size;
struct dsp_elf32_hdr *hdr;
struct dsp_elf32_shdr *shdr;
size_t shdr_num;
char *shstrtab;
char *strtab;
struct dsp_elf32_sym *symtab;
size_t symtab_num;
struct dsp_hash_tab symhash;
struct dsp_list_head bss_sym;
struct dsp_list_head extern_sym;
struct dsp_elf32_mem DMb;
struct dsp_elf32_mem DMb_local;
struct dsp_elf32_mem TCMb;
struct dsp_elf32_mem TCMb_local;
struct dsp_elf32_mem DRAMb;
struct dsp_elf32_mem SFRw;
struct dsp_elf32_text text;
};
#pragma pack(pop)
unsigned int dsp_elf32_rela_get_sym_idx(struct dsp_elf32_rela *rela);
unsigned int dsp_elf32_rela_get_rule_idx(struct dsp_elf32_rela *rela);
int dsp_elf32_load(struct dsp_elf32 *elf, struct dsp_dl_lib_file *file);
void dsp_elf32_free(struct dsp_elf32 *elf);
unsigned int dsp_elf32_get_text_size(struct dsp_elf32 *elf);
unsigned int dsp_elf32_get_mem_size(struct dsp_elf32_mem *mem,
struct dsp_elf32 *elf);
void dsp_elf32_print(struct dsp_elf32 *elf);
void dsp_elf32_hdr_print(struct dsp_elf32 *elf);
void dsp_elf32_shdr_print(struct dsp_elf32 *elf);
void dsp_elf32_symtab_print(struct dsp_elf32 *elf);
void dsp_elf32_bss_sym_print(struct dsp_elf32 *elf);
void dsp_elf32_extern_sym_print(struct dsp_elf32 *elf);
void dsp_elf32_symhash_print(struct dsp_elf32 *elf);
void dsp_elf32_text_print(struct dsp_elf32 *elf);
void dsp_elf32_DMb_print(struct dsp_elf32 *elf);
void dsp_elf32_DMb_local_print(struct dsp_elf32 *elf);
void dsp_elf32_DRAMb_print(struct dsp_elf32 *elf);
void dsp_elf32_TCMb_print(struct dsp_elf32 *elf);
void dsp_elf32_TCMb_local_print(struct dsp_elf32 *elf);
void dsp_elf32_SFRw_print(struct dsp_elf32 *elf);
int dsp_elf32_load_libs(struct dsp_dl_lib_info *infos,
struct dsp_lib **libs, int libs_size);
#endif
|