Rizin
unix-like reverse engineering framework and cli tools
elf.c
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: 2021 08A <08A@riseup.net>
2 // SPDX-FileCopyrightText: 2008-2020 nibble <nibble.ds@gmail.com>
3 // SPDX-FileCopyrightText: 2008-2020 pancake <pancake@nopcode.org>
4 // SPDX-FileCopyrightText: 2008-2020 alvaro_fe <alvaro.felipe91@gmail.com>
5 // SPDX-License-Identifier: LGPL-3.0-only
6 
7 #include "elf.h"
8 
9 static const char *sdb_elf_p_type_cparse = "enum elf_p_type {PT_NULL=0,PT_LOAD=1,PT_DYNAMIC=2,"
10  "PT_INTERP=3,PT_NOTE=4,PT_SHLIB=5,PT_PHDR=6,PT_LOOS=0x60000000,"
11  "PT_HIOS=0x6fffffff,PT_LOPROC=0x70000000,PT_HIPROC=0x7fffffff};";
12 
13 static const char *sdb_elf_p_flags_cparse = "enum elf_p_flags {PF_None=0,PF_Exec=1,"
14  "PF_Write=2,PF_Write_Exec=3,PF_Read=4,PF_Read_Exec=5,PF_Read_Write=6,"
15  "PF_Read_Write_Exec=7};";
16 
17 static const char *sdb_elf_type_cparse = "enum elf_type { ET_NONE=0, ET_REL=1,"
18  " ET_EXEC=2, ET_DYN=3, ET_CORE=4, ET_LOOS=0xfe00, ET_HIOS=0xfeff,"
19  " ET_LOPROC=0xff00, ET_HIPROC=0xffff };";
20 
21 static const char *sdb_elf_machine_cparse = "enum elf_machine {EM_NONE=0, EM_M32=1,"
22  " EM_SPARC=2, EM_386=3, EM_68K=4, EM_88K=5, EM_IAMCU=6, EM_860=7, EM_MIPS=8,"
23  " EM_S370=9, EM_MIPS_RS3_LE=10, EM_RS6000=11, EM_PARISC=15, EM_nCUBE=16,"
24  " EM_VPP500=17, EM_SPARC32PLUS=18, EM_960=19, EM_PPC=20, EM_PPC64=21, EM_S390=22,"
25  " EM_SPU=23, EM_V800=36, EM_FR20=37, EM_RH32=38, EM_RCE=39, EM_ARM=40,"
26  " EM_ALPHA=41, EM_SH=42, EM_SPARCV9=43, EM_TRICORE=44, EM_ARC=45, EM_H8_300=46,"
27  " EM_H8_300H=47, EM_H8S=48, EM_H8_500=49, EM_IA_64=50, EM_MIPS_X=51,"
28  " EM_COLDFIRE=52, EM_68HC12=53, EM_MMA=54, EM_PCP=55, EM_NCPU=56, EM_NDR1=57,"
29  " EM_STARCORE=58, EM_ME16=59, EM_ST100=60, EM_TINYJ=61, EM_X86_64=62, EM_PDSP=63,"
30  " EM_PDP10=64, EM_PDP11=65, EM_FX66=66, EM_ST9PLUS=67, EM_ST7=68, EM_68HC16=69,"
31  " EM_68HC11=70, EM_68HC08=71, EM_68HC05=72, EM_SVX=73, EM_ST19=74, EM_VAX=75,"
32  " EM_CRIS=76, EM_JAVELIN=77, EM_FIREPATH=78, EM_ZSP=79, EM_MMIX=80, EM_HUANY=81,"
33  " EM_PRISM=82, EM_AVR=83, EM_FR30=84, EM_D10V=85, EM_D30V=86, EM_V850=87,"
34  " EM_M32R=88, EM_MN10300=89, EM_MN10200=90, EM_PJ=91, EM_OPENRISC=92,"
35  " EM_ARC_COMPACT=93, EM_XTENSA=94, EM_VIDEOCORE=95, EM_TMM_GPP=96, EM_NS32K=97,"
36  " EM_TPC=98, EM_SNP1K=99, EM_ST200=100, EM_IP2K=101, EM_MAX=102, EM_CR=103,"
37  " EM_F2MC16=104, EM_MSP430=105, EM_BLACKFIN=106, EM_SE_C33=107, EM_SEP=108,"
38  " EM_ARCA=109, EM_UNICORE=110, EM_EXCESS=111, EM_DXP=112, EM_ALTERA_NIOS2=113,"
39  " EM_CRX=114, EM_XGATE=115, EM_C166=116, EM_M16C=117, EM_DSPIC30F=118, EM_CE=119,"
40  " EM_M32C=120, EM_TSK3000=131, EM_RS08=132, EM_SHARC=133, EM_ECOG2=134,"
41  " EM_SCORE7=135, EM_DSP24=136, EM_VIDEOCORE3=137, EM_LATTICEMICO32=138,"
42  " EM_SE_C17=139, EM_TI_C6000=140, EM_TI_C2000=141, EM_TI_C5500=142,"
43  " EM_TI_ARP32=143, EM_TI_PRU=144,"
44  " EM_MMDSP_PLUS=160, EM_CYPRESS_M8C=161, EM_R32C=162, EM_TRIMEDIA=163,"
45  " EM_QDSP6=164, EM_8051=165, EM_STXP7X=166, EM_NDS32=167,"
46  " EM_ECOG1X=168, EM_MAXQ30=169, EM_XIMO16=170, EM_MANIK=171, EM_CRAYNV2=172,"
47  " EM_RX=173, EM_METAG=174, EM_MCST_ELBRUS=175, EM_ECOG16=176, EM_CR16=177,"
48  " EM_ETPU=178, EM_SLE9X=179, EM_L10M=180, EM_K10M=181, EM_AARCH64=183,"
49  " EM_AVR32=185, EM_STM8=186, EM_TILE64=187, EM_TILEPRO=188, EM_CUDA=190,"
50  " EM_TILEGX=191, EM_CLOUDSHIELD=192, EM_COREA_1ST=193, EM_COREA_2ND=194,"
51  " EM_ARC_COMPACT2=195, EM_OPEN8=196, EM_RL78=197, EM_VIDEOCORE5=198,"
52  " EM_78KOR=199, EM_56800EX=200, EM_BA1=201, EM_BA2=202, EM_XCORE=203,"
53  " EM_MCHP_PIC=204, EM_INTEL205=205, EM_INTEL206=206, EM_INTEL207=207,"
54  " EM_INTEL208=208, EM_INTEL209=209, EM_KM32=210, EM_KMX32=211, EM_KMX16=212,"
55  " EM_KMX8=213, EM_KVARC=214, EM_CDP=215, EM_COGE=216, EM_COOL=217, EM_NORC=218,"
56  " EM_CSR_KALIMBA=219, EM_AMDGPU=224, EM_RISCV=243, EM_LANAI=244, EM_BPF=247,"
57  " EM_CSKY=252, EM_KVX=256}";
58 
59 static const char *sdb_elf_class_cparse = "enum elf_class {ELFCLASSNONE=0, ELFCLASS32=1, ELFCLASS64=2};";
60 
61 static const char *sdb_elf_data_cparse = "enum elf_data {ELFDATANONE=0, ELFDATA2LSB=1, ELFDATA2MSB=2};";
62 
63 static const char *sdb_elf_hdr_version_cparse = "enum elf_hdr_version {EV_NONE=0, EV_CURRENT=1};";
64 
65 static const char *sdb_elf_obj_version_cparse = "enum elf_obj_version {EV_NONE=0, EV_CURRENT=1};";
66 
67 static const char *sdb_elf_ident_format = "[4]z[1]E[1]E[1]E.::"
68  " magic (elf_class)class (elf_data)data (elf_hdr_version)version";
69 
70 static const char *sdb_elf_s_type_cparse = "enum elf_s_type {SHT_NULL=0,SHT_PROGBITS=1,"
71  "SHT_SYMTAB=2,SHT_STRTAB=3,SHT_RELA=4,SHT_HASH=5,SHT_DYNAMIC=6,SHT_NOTE=7,"
72  "SHT_NOBITS=8,SHT_REL=9,SHT_SHLIB=10,SHT_DYNSYM=11,SHT_LOOS=0x60000000,"
73  "SHT_HIOS=0x6fffffff,SHT_LOPROC=0x70000000,SHT_HIPROC=0x7fffffff};";
74 
75 #if RZ_BIN_ELF64
76 static const char *sdb_elf_phdr_format = "[4]E[4]Eqqqqqq (elf_p_type)type (elf_p_flags)flags"
77  " offset vaddr paddr filesz memsz align";
78 
79 static const char *sdb_elf_s_flags_64_cparse = "enum elf_s_flags_64 {SF64_None=0,SF64_Exec=1,"
80  "SF64_Alloc=2,SF64_Alloc_Exec=3,SF64_Write=4,SF64_Write_Exec=5,"
81  "SF64_Write_Alloc=6,SF64_Write_Alloc_Exec=7};";
82 
83 static const char *sdb_elf_shdr_format = "x[4]E[8]Eqqqxxqq name (elf_s_type)type"
84  " (elf_s_flags_64)flags addr offset size link info addralign entsize";
85 
86 static const char *sdb_elf_header_format = "?[2]E[2]E[4]EqqqxN2N2N2N2N2N2"
87  " (elf_ident)ident (elf_type)type (elf_machine)machine (elf_obj_version)version"
88  " entry phoff shoff flags ehsize phentsize phnum shentsize shnum shstrndx";
89 #else
90 static const char *sdb_elf_phdr_format = "[4]Exxxxx[4]Ex (elf_p_type)type offset vaddr paddr"
91  " filesz memsz (elf_p_flags)flags align";
92 
93 static const char *sdb_elf_s_flags_32_cparse = "enum elf_s_flags_32 {SF32_None=0,SF32_Exec=1,"
94  "SF32_Alloc=2,SF32_Alloc_Exec=3,SF32_Write=4,SF32_Write_Exec=5,"
95  "SF32_Write_Alloc=6,SF32_Write_Alloc_Exec=7};";
96 
97 static const char *sdb_elf_shdr_format = "x[4]E[4]Exxxxxxx name (elf_s_type)type"
98  " (elf_s_flags_32)flags addr offset size link info addralign entsize";
99 
100 static const char *sdb_elf_header_format = "?[2]E[2]E[4]ExxxxN2N2N2N2N2N2"
101  " (elf_ident)ident (elf_type)type (elf_machine)machine (elf_obj_version)version"
102  " entry phoff shoff flags ehsize phentsize phnum shentsize shnum shstrndx";
103 #endif
104 
105 static bool in_virtual_phdr(RzBinElfSegment *segment, ut64 addr) {
106  return addr >= segment->data.p_vaddr && addr < segment->data.p_vaddr + segment->data.p_filesz;
107 }
108 
109 static bool in_physical_phdr(RzBinElfSegment *segment, ut64 addr) {
110  return addr >= segment->data.p_offset && addr < segment->data.p_offset + segment->data.p_filesz;
111 }
112 
113 static bool init_phdr_sdb(ELFOBJ *bin) {
114  return sdb_num_set(bin->kv, "elf_phdr.offset", bin->ehdr.e_phoff, 0) &&
115  sdb_num_set(bin->kv, "elf_phdr.size", sizeof(Elf_(Phdr)), 0) &&
116  sdb_set(bin->kv, "elf_p_flags.cparse", sdb_elf_p_flags_cparse, 0) &&
117  sdb_set(bin->kv, "elf_p_type.cparse", sdb_elf_p_type_cparse, 0) &&
118  sdb_set(bin->kv, "elf_phdr.format", sdb_elf_phdr_format, 0);
119 }
120 
123  if (!bin->segments) {
124  return false;
125  }
126 
127  return init_phdr_sdb(bin);
128 }
129 
131  if (!bin->ehdr.e_phnum) {
132  RZ_LOG_WARN("There is no program header.\n");
133  return;
134  }
135 
136  if (!init_phdr_aux(bin, sections, options)) {
137  RZ_LOG_WARN("Failed to initialize program header.\n");
138  }
139 }
140 
141 static bool init_ehdr_sdb(ELFOBJ *bin) {
142  return sdb_num_set(bin->kv, "elf_header.offset", 0, 0) &&
143  sdb_num_set(bin->kv, "elf_header.size", sizeof(Elf_(Ehdr)), 0) &&
144  sdb_set(bin->kv, "elf_class.cparse", sdb_elf_class_cparse, 0) &&
145  sdb_set(bin->kv, "elf_data.cparse", sdb_elf_data_cparse, 0) &&
146  sdb_set(bin->kv, "elf_hdr_version.cparse", sdb_elf_hdr_version_cparse, 0) &&
147  sdb_set(bin->kv, "elf_header.format", sdb_elf_header_format, 0) &&
148  sdb_set(bin->kv, "elf_ident.format", sdb_elf_ident_format, 0) &&
149  sdb_set(bin->kv, "elf_machine.cparse", sdb_elf_machine_cparse, 0) &&
150  sdb_set(bin->kv, "elf_obj_version.cparse", sdb_elf_obj_version_cparse, 0) &&
151  sdb_set(bin->kv, "elf_type.cparse", sdb_elf_type_cparse, 0);
152 }
153 
154 static bool init_ehdr(ELFOBJ *bin) {
155  if (!Elf_(rz_bin_elf_get_ehdr)(bin)) {
156  return false;
157  }
158 
159  return init_ehdr_sdb(bin);
160 }
161 
162 static bool init_shdr_sdb(ELFOBJ *bin) {
163  return sdb_num_set(bin->kv, "elf_shdr.offset", bin->ehdr.e_shoff, 0) &&
164  sdb_num_set(bin->kv, "elf_shdr.size", sizeof(Elf_(Shdr)), 0) &&
165 #if RZ_BIN_ELF64
166  sdb_set(bin->kv, "elf_s_flags_64.cparse", sdb_elf_s_flags_64_cparse, 0) &&
167 #else
168  sdb_set(bin->kv, "elf_s_flags_32.cparse", sdb_elf_s_flags_32_cparse, 0) &&
169 #endif
170  sdb_set(bin->kv, "elf_s_type.cparse", sdb_elf_s_type_cparse, 0) &&
171  sdb_set(bin->kv, "elf_shdr.format", sdb_elf_shdr_format, 0);
172 }
173 
176  if (!bin->sections) {
177  return false;
178  }
179 
180  return init_shdr_sdb(bin);
181 }
182 
184  if (!init_shdr_aux(bin, options, sections)) {
185  RZ_LOG_WARN("Failed to initialize section header.\n");
186  }
187 }
188 
190  return sdb_num_set(bin->kv, "elf_shstrtab.offset", offset, 0) &&
191  sdb_num_set(bin->kv, "elf_shstrtab.size", size, 0);
192 }
193 
195  if (!sections) {
196  return true;
197  }
198 
199  Elf_(Shdr) *section = rz_vector_index_ptr(sections, bin->ehdr.e_shstrndx);
200  if (!section) {
201  RZ_LOG_WARN("Invalid ELF header e_shstrndx value.\n");
202  return false;
203  }
204 
205  bin->shstrtab = Elf_(rz_bin_elf_strtab_new)(bin, section->sh_offset, section->sh_size);
206  if (!bin->shstrtab) {
207  return false;
208  }
209 
210  return init_shstrtab_sdb(bin, section->sh_offset, section->sh_size);
211 }
212 
214  if (!init_shstrtab_aux(bin, sections)) {
215  RZ_LOG_WARN("Failed to initialize section string table.\n");
216  }
217 }
218 
220  switch (Elf_(rz_bin_elf_has_relro)(bin)) {
222  return sdb_set(bin->kv, "elf.relro", "full", 0);
224  return sdb_set(bin->kv, "elf.relro", "partial", 0);
225  default:
226  return sdb_set(bin->kv, "elf.relro", "no", 0);
227  }
228 
229  return false;
230 }
231 
233  bin->dt_dynamic = Elf_(rz_bin_elf_dt_dynamic_new)(bin);
234  if (!bin->dt_dynamic) {
235  return false;
236  }
237 
238  return init_dt_dynamic_sdb(bin);
239 }
240 
241 static void init_dt_dynamic(ELFOBJ *bin) {
242  if (!init_dt_dynamic_aux(bin)) {
243  RZ_LOG_INFO("Failed to initialize ELF DT_DYNAMIC.\n");
244  }
245 }
246 
247 static bool init_dynstr_sdb(ELFOBJ *bin, ut64 strtab_addr, Elf_(Xword) strtab_size) {
248  return sdb_num_set(bin->kv, "elf_dynstr.offset", strtab_addr, 0) &&
249  sdb_num_set(bin->kv, "elf_dynstr.size", strtab_size, 0);
250 }
251 
252 static bool init_dynstr_aux(ELFOBJ *bin) {
253  ut64 addr;
254  ut64 size;
255 
257  RZ_LOG_INFO("DT_STRTAB or DT_STRSZ key not found.\n");
258  return false;
259  }
260 
262  if (offset == UT64_MAX) {
263  RZ_LOG_INFO("Failed to convert DT_STRTAB to a physical offset.\n");
264  return false;
265  }
266 
268  if (!bin->dynstr) {
269  return false;
270  }
271 
272  return init_dynstr_sdb(bin, offset, size);
273 }
274 
275 static void init_dynstr(ELFOBJ *bin) {
276  if (!init_dynstr_aux(bin)) {
277  RZ_LOG_INFO("Failed to initialize string table for dynamic linking.\n");
278  }
279 }
280 
283  if (!info) {
284  return false;
285  }
286 
287  return sdb_ns_set(bin->kv, "versioninfo", info);
288 }
289 
290 static void init_symbols_info(ELFOBJ *bin) {
291  if (!init_symbols_info_aux(bin)) {
292  RZ_LOG_INFO("Failed to initialize GNU symbols information.\n")
293  }
294 }
295 
297  /* bin is not an ELF */
298  if (!init_ehdr(bin)) {
299  return false;
300  }
301 
303  if (options->elf_load_sections) {
305  }
306 
309  }
310 
313  init_dynstr(bin);
315  }
316 
317  if (bin->ehdr.e_type != ET_CORE) {
318  bin->baddr = Elf_(rz_bin_elf_get_baddr)(bin);
321  }
322 
323  bin->boffset = Elf_(rz_bin_elf_get_boffset)(bin);
324 
325  bin->relocs = Elf_(rz_bin_elf_relocs_new)(bin);
326  bin->reloc_targets_map_base = Elf_(rz_bin_elf_get_targets_map_base)(bin);
327 
328  bin->notes = Elf_(rz_bin_elf_notes_new)(bin);
329 
330  bin->symbols = Elf_(rz_bin_elf_symbols_new)(bin);
331  bin->bits = Elf_(rz_bin_elf_get_bits)(bin);
332  bin->imports = Elf_(rz_bin_elf_analyse_imports)(bin);
333 
335 
336  return true;
337 }
338 
341 
342  ELFOBJ *bin = RZ_NEW0(ELFOBJ);
343  if (!bin) {
344  return NULL;
345  }
346 
347  bin->b = rz_buf_ref(buf);
348  bin->kv = sdb_new0();
349 
350  bin->size = rz_buf_size(buf);
351 
352  if (!init(bin, options)) {
354  return NULL;
355  }
356 
357  return bin;
358 }
359 
368 
369  rz_buf_free(bin->b);
370  rz_buf_free(bin->buf_patched);
371 
372  sdb_free(bin->kv);
373 
374  rz_vector_free(bin->segments);
375  rz_vector_free(bin->sections);
376 
377  Elf_(rz_bin_elf_dt_dynamic_free)(bin->dt_dynamic);
378 
379  Elf_(rz_bin_elf_strtab_free)(bin->dynstr);
380  Elf_(rz_bin_elf_strtab_free)(bin->shstrtab);
381 
382  rz_vector_free(bin->relocs);
383 
384  rz_vector_free(bin->notes);
385 
386  rz_vector_free(bin->symbols);
387  rz_vector_free(bin->imports);
388 
389  free(bin);
390 }
391 
402 
405  return bin->baddr + paddr;
406  }
407 
408  return UT64_MAX;
409  }
410 
411  RzBinElfSegment *segment;
412  rz_bin_elf_foreach_segments(bin, segment) {
413  if (segment->data.p_type == PT_LOAD && in_physical_phdr(segment, paddr)) {
414  return segment->data.p_vaddr + paddr - segment->data.p_offset;
415  }
416  }
417 
418  return UT64_MAX;
419 }
420 
431 
433  if (Elf_(rz_bin_elf_is_relocatable)(bin) && vaddr > bin->baddr) {
434  return vaddr - bin->baddr;
435  }
436 
437  return UT64_MAX;
438  }
439 
440  RzBinElfSegment *segment;
441  rz_bin_elf_foreach_segments(bin, segment) {
442  if (segment->data.p_type == PT_LOAD && in_virtual_phdr(segment, vaddr)) {
443  return segment->data.p_offset + vaddr - segment->data.p_vaddr;
444  }
445  }
446 
447  return UT64_MAX;
448 }
RzBinInfo * info(RzBinFile *bf)
Definition: bin_ne.c:86
RzList * sections(RzBinFile *bf)
Definition: bin_ne.c:110
#define NULL
Definition: cris-opc.c:27
static void init_phdr(ELFOBJ *bin, RzVector *sections, RzBinObjectLoadOptions *options)
Definition: elf.c:130
static void init_shdr(ELFOBJ *bin, RzBinObjectLoadOptions *options, RzVector *sections)
Definition: elf.c:183
static bool init_ehdr_sdb(ELFOBJ *bin)
Definition: elf.c:141
static void init_dynstr(ELFOBJ *bin)
Definition: elf.c:275
static bool init_phdr_sdb(ELFOBJ *bin)
Definition: elf.c:113
static bool init_dt_dynamic_aux(ELFOBJ *bin)
Definition: elf.c:232
static const char * sdb_elf_s_flags_32_cparse
Definition: elf.c:93
ut64 Elf_() rz_bin_elf_p2v(RZ_NONNULL ELFOBJ *bin, ut64 paddr)
Convert a physical address to the virtual address.
Definition: elf.c:400
static const char * sdb_elf_ident_format
Definition: elf.c:67
static bool init_ehdr(ELFOBJ *bin)
Definition: elf.c:154
static bool init(ELFOBJ *bin, RzBinObjectLoadOptions *options)
Definition: elf.c:296
static const char * sdb_elf_header_format
Definition: elf.c:100
static bool init_shdr_sdb(ELFOBJ *bin)
Definition: elf.c:162
static void init_shstrtab(ELFOBJ *bin, RzVector *sections)
Definition: elf.c:213
static bool init_shstrtab_aux(ELFOBJ *bin, RzVector *sections)
Definition: elf.c:194
static bool init_dt_dynamic_sdb(ELFOBJ *bin)
Definition: elf.c:219
static bool init_shdr_aux(ELFOBJ *bin, RzBinObjectLoadOptions *options, RzVector *sections)
Definition: elf.c:174
static bool init_dynstr_sdb(ELFOBJ *bin, ut64 strtab_addr, Elf_(Xword) strtab_size)
Definition: elf.c:247
static const char * sdb_elf_phdr_format
Definition: elf.c:90
static const char * sdb_elf_data_cparse
Definition: elf.c:61
static const char * sdb_elf_p_type_cparse
Definition: elf.c:9
void Elf_() rz_bin_elf_free(RZ_NONNULL ELFOBJ *bin)
Free the elf binary.
Definition: elf.c:366
static bool init_symbols_info_aux(ELFOBJ *bin)
Definition: elf.c:281
static void init_dt_dynamic(ELFOBJ *bin)
Definition: elf.c:241
static bool init_dynstr_aux(ELFOBJ *bin)
Definition: elf.c:252
static const char * sdb_elf_shdr_format
Definition: elf.c:97
static const char * sdb_elf_hdr_version_cparse
Definition: elf.c:63
RZ_OWN ELFOBJ *Elf_() rz_bin_elf_new_buf(RZ_NONNULL RzBuffer *buf, RZ_NONNULL RzBinObjectLoadOptions *options)
Definition: elf.c:339
static bool init_phdr_aux(ELFOBJ *bin, RzVector *sections, RzBinObjectLoadOptions *options)
Definition: elf.c:121
static const char * sdb_elf_machine_cparse
Definition: elf.c:21
static const char * sdb_elf_p_flags_cparse
Definition: elf.c:13
static bool in_virtual_phdr(RzBinElfSegment *segment, ut64 addr)
Definition: elf.c:105
static const char * sdb_elf_type_cparse
Definition: elf.c:17
static void init_symbols_info(ELFOBJ *bin)
Definition: elf.c:290
static bool in_physical_phdr(RzBinElfSegment *segment, ut64 addr)
Definition: elf.c:109
static const char * sdb_elf_obj_version_cparse
Definition: elf.c:65
static const char * sdb_elf_class_cparse
Definition: elf.c:59
static bool init_shstrtab_sdb(ELFOBJ *bin, ut64 offset, ut64 size)
Definition: elf.c:189
ut64 Elf_() rz_bin_elf_v2p(RZ_NONNULL ELFOBJ *bin, ut64 vaddr)
Convert a virtual address to the physical address.
Definition: elf.c:429
static const char * sdb_elf_s_type_cparse
Definition: elf.c:70
RZ_OWN RzVector *Elf_() rz_bin_elf_relocs_new(RZ_NONNULL ELFOBJ *bin)
Definition: elf_relocs.c:202
#define rz_bin_elf_foreach_segments(bin, segment)
Definition: elf.h:26
RZ_OWN Sdb *Elf_() rz_bin_elf_get_symbols_info(RZ_NONNULL ELFOBJ *bin)
Definition: elf_info.c:1301
bool Elf_() rz_bin_elf_get_ehdr(RZ_NONNULL ELFOBJ *bin)
Definition: elf_ehdr.c:182
bool Elf_() rz_bin_elf_is_static(RZ_NONNULL ELFOBJ *bin)
Check if the binary is statically-linked library.
Definition: elf_info.c:1674
RzBinElfSegment
Definition: elf.h:131
#define RZ_BIN_ELF_FULL_RELRO
Definition: elf.h:22
#define ELFOBJ
Definition: elf.h:24
void Elf_() rz_bin_elf_dt_dynamic_free(RzBinElfDtDynamic *ptr)
Definition: elf_dynamic.c:135
RZ_OWN RzBinElfDtDynamic *Elf_() rz_bin_elf_dt_dynamic_new(RZ_NONNULL ELFOBJ *bin)
Definition: elf_dynamic.c:98
ut64 Elf_() rz_bin_elf_get_baddr(RZ_NONNULL ELFOBJ *bin)
Compute the base address of the binary.
Definition: elf_info.c:1772
RZ_OWN RzVector *Elf_() rz_bin_elf_symbols_new(RZ_NONNULL ELFOBJ *bin)
Definition: elf_symbols.c:523
ut64 Elf_() rz_bin_elf_get_targets_map_base(ELFOBJ *bin)
Definition: elf_map.c:44
RZ_OWN RzVector *Elf_() rz_bin_elf_sections_new(RZ_NONNULL ELFOBJ *bin)
Definition: elf_sections.c:378
RZ_OWN RzBinElfStrtab *Elf_() rz_bin_elf_strtab_new(RZ_NONNULL ELFOBJ *bin, ut64 offset, ut64 size)
Definition: elf_strtab.c:18
void Elf_() rz_bin_elf_strtab_free(RzBinElfStrtab *ptr)
Definition: elf_strtab.c:72
bool Elf_() rz_bin_elf_get_dt_info(RZ_NONNULL ELFOBJ *bin, ut64 key, RZ_OUT ut64 *info)
Definition: elf_dynamic.c:120
RZ_OWN RzVector *Elf_() rz_bin_elf_segments_new(RZ_NONNULL ELFOBJ *bin, RzVector *sections, RZ_NONNULL RzBinObjectLoadOptions *options)
Definition: elf_segments.c:133
#define RZ_BIN_ELF_PART_RELRO
Definition: elf.h:21
RZ_OWN RzVector *Elf_() rz_bin_elf_analyse_imports(RZ_NONNULL ELFOBJ *bin)
Definition: elf_imports.c:329
int Elf_() rz_bin_elf_get_bits(RZ_NONNULL ELFOBJ *bin)
Return the elf bits.
Definition: elf_info.c:1697
RZ_OWN RzVector *Elf_() rz_bin_elf_notes_new(RZ_NONNULL ELFOBJ *bin)
Definition: elf_notes.c:218
RZ_OWN RzVector *Elf_() rz_bin_elf_convert_sections(RZ_NONNULL ELFOBJ *bin, RZ_NONNULL RzBinObjectLoadOptions *options, RzVector *sections)
Definition: elf_sections.c:362
bool Elf_() rz_bin_elf_has_segments(RZ_NONNULL ELFOBJ *bin)
Definition: elf_segments.c:149
bool Elf_() rz_bin_elf_is_relocatable(RZ_NONNULL ELFOBJ *bin)
Check if the elf binary is relocatable.
Definition: elf_info.c:1662
ut64 Elf_() rz_bin_elf_get_boffset(RZ_NONNULL ELFOBJ *bin)
Compute the base offset of the binary.
Definition: elf_info.c:1795
int Elf_() rz_bin_elf_has_relro(RZ_NONNULL ELFOBJ *bin)
Analyse if the elf binary has relro or partial relro.
Definition: elf_info.c:1733
#define Elf_(name)
Definition: elf_specs.h:32
RZ_API void Ht_() free(HtName_(Ht) *ht)
Definition: ht_inc.c:130
voidpf void uLong size
Definition: ioapi.h:138
voidpf uLong offset
Definition: ioapi.h:144
voidpf void * buf
Definition: ioapi.h:138
#define ET_CORE
Definition: common.h:92
#define PT_LOAD
Definition: common.h:303
#define DT_STRSZ
Definition: common.h:547
#define DT_STRTAB
Definition: common.h:542
static const char struct stat static buf struct stat static buf static vhangup int options
Definition: sflib.h:145
RZ_API int sdb_ns_set(Sdb *s, const char *name, Sdb *r)
Definition: ns.c:156
RZ_API int sdb_num_set(Sdb *s, const char *key, ut64 v, ut32 cas)
Definition: num.c:25
#define rz_return_if_fail(expr)
Definition: rz_assert.h:100
#define rz_return_val_if_fail(expr, val)
Definition: rz_assert.h:108
RZ_API RzBuffer * rz_buf_ref(RzBuffer *b)
Increment the reference count of the buffer.
Definition: buf.c:668
RZ_API void rz_buf_free(RzBuffer *b)
Free all internal data hold by the buffer and the buffer.
Definition: buf.c:1253
RZ_API ut64 rz_buf_size(RZ_NONNULL RzBuffer *b)
Return the size of the buffer.
Definition: buf.c:1225
#define RZ_LOG_INFO(fmtstr,...)
Definition: rz_log.h:54
#define RZ_LOG_WARN(fmtstr,...)
Definition: rz_log.h:56
#define RZ_OWN
Definition: rz_types.h:62
#define RZ_NEW0(x)
Definition: rz_types.h:284
#define RZ_NONNULL
Definition: rz_types.h:64
#define UT64_MAX
Definition: rz_types_base.h:86
static void * rz_vector_index_ptr(RzVector *vec, size_t index)
Definition: rz_vector.h:88
RZ_API void rz_vector_free(RzVector *vec)
Definition: vector.c:75
RZ_API int sdb_set(Sdb *s, const char *key, const char *val, ut32 cas)
Definition: sdb.c:611
RZ_API Sdb * sdb_new0(void)
Definition: sdb.c:43
RZ_API bool sdb_free(Sdb *s)
Definition: sdb.c:206
Definition: malloc.c:26
Definition: sdb.h:63
ut64(WINAPI *w32_GetEnabledXStateFeatures)()
static int addr
Definition: z80asm.c:58