Rizin
unix-like reverse engineering framework and cli tools
elf.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: 2021 08A <08A@riseup.net>
2 // SPDX-FileCopyrightText: 2009 Nibble <nibble.ds@gmail.com>
3 // SPDX-FileCopyrightText: 2009 pancake <pancake@nopcode.org>
4 // SPDX-License-Identifier: LGPL-3.0-only
5 
6 #include <rz_types.h>
7 #include <rz_util.h>
8 #include <rz_lib.h>
9 #include <rz_bin.h>
10 
11 #include "elf_specs.h"
12 
13 #ifndef _INCLUDE_ELF_H_
14 #define _INCLUDE_ELF_H_
15 
16 #define RZ_BIN_ELF_SCN_IS_EXECUTABLE(x) x &SHF_EXECINSTR
17 #define RZ_BIN_ELF_SCN_IS_READABLE(x) x &SHF_ALLOC
18 #define RZ_BIN_ELF_SCN_IS_WRITABLE(x) x &SHF_WRITE
19 
20 #define RZ_BIN_ELF_NO_RELRO 0
21 #define RZ_BIN_ELF_PART_RELRO 1
22 #define RZ_BIN_ELF_FULL_RELRO 2
23 
24 #define ELFOBJ struct Elf_(rz_bin_elf_obj_t)
25 
26 #define rz_bin_elf_foreach_segments(bin, segment) \
27  if (Elf_(rz_bin_elf_has_segments)(bin)) \
28  rz_vector_foreach((bin)->segments, segment)
29 
30 #define rz_bin_elf_foreach_sections(bin, section) \
31  if (Elf_(rz_bin_elf_has_sections)(bin)) \
32  rz_vector_foreach((bin)->sections, section)
33 
34 #define rz_bin_elf_enumerate_sections(bin, section, i) \
35  if (Elf_(rz_bin_elf_has_sections)(bin)) \
36  rz_vector_enumerate((bin)->sections, section, i)
37 
38 #define rz_bin_elf_foreach_relocs(bin, reloc) \
39  if (Elf_(rz_bin_elf_has_relocs)(bin)) \
40  rz_vector_foreach((bin)->relocs, reloc)
41 
42 #define rz_bin_elf_foreach_notes_segment(bin, notes) \
43  if (Elf_(rz_bin_elf_has_notes)(bin)) \
44  rz_vector_foreach((bin)->notes, notes)
45 
46 #define rz_bin_elf_foreach_symbols(bin, symbol) \
47  if (Elf_(rz_bin_elf_has_symbols)(bin)) \
48  rz_vector_foreach(bin->symbols, symbol)
49 
50 #define rz_bin_elf_foreach_imports(bin, import) \
51  if (Elf_(rz_bin_elf_has_imports)(bin)) \
52  rz_vector_foreach(bin->imports, import)
53 
54 struct gnu_hash_table { // DT_GNU_HASH
55  Elf_(Word) nbuckets;
56  Elf_(Word) symoffset;
57  Elf_(Word) bloom_size;
58  Elf_(Word) bloom_shift;
59  // Elf_(Addr) boom[bloom_size];
60  // Elf_(Word) buckets[nbuckets];
61  // Elf_(Word) chains[];
62 };
63 
66  struct gnu_hash_table data;
68 
69 struct elf_hash_table { // DT_HASH
70  Elf_(Word) nbuckets;
71  Elf_(Word) nchains;
72  // Elf_(Word) buckets[nbuckets];
73  // Elf_(Word) chains[nchains];
74 };
75 
76 typedef struct rz_bin_elf_hash_table_ {
78  struct elf_hash_table data;
80 
82 typedef struct prstatus_layout_t {
84 
95 
98 
109 
110  // These NT_PRSTATUS notes hold much more than this, but it's not needed for us yet.
111  // If necessary, new members can be introduced here.
113 
114 typedef struct rz_bin_elf_section_t {
123  char *name;
124  bool is_valid;
126 
127 typedef struct Elf_(rz_bin_elf_segment_t) {
128  Elf_(Phdr) data;
129  bool is_valid;
130 }
132 
133 typedef struct rz_bin_elf_symbol_t {
138  const char *bind;
139  const char *type;
140  RZ_OWN char *name;
142 
143 typedef struct rz_bin_elf_reloc_t {
145  int type;
155 
156 typedef struct rz_bin_elf_dt_dynamic_t RzBinElfDtDynamic; // elf_dynamic.h
157 
159 typedef struct Elf_(rz_bin_elf_note_file_t) {
160  Elf_(Addr) start_vaddr;
161  Elf_(Addr) end_vaddr;
162  Elf_(Addr) file_off;
163  char *file;
164 }
166 
171  // Hint: there is more info in NT_PRSTATUS notes that could be parsed if needed.
173 
175 typedef struct Elf_(rz_bin_elf_note_t) {
176  Elf_(Word) type;
177  union {
178  RzBinElfNoteFile file; //< for type == NT_FILE
179  RzBinElfNotePrStatus prstatus; //< for type = NT_PRSTATUS
180  };
181 }
183 
184 typedef struct rz_bin_elf_strtab RzBinElfStrtab;
185 
186 struct Elf_(rz_bin_elf_obj_t) {
187  RzBuffer *b;
188 
189  RzBuffer *buf_patched;
190  bool relocs_patched;
192 
193  Sdb *kv;
194 
195  ut64 size;
196 
197  bool big_endian;
198  int bits;
199  ut64 baddr;
200  ut64 boffset;
201 
202  Elf_(Ehdr) ehdr;
203 
204  RzVector *segments; // should be use with elf_segments.c
205  RzVector *sections; // should be use with elf_sections.c
206 
207  RzBinElfDtDynamic *dt_dynamic; // should be use with elf_dynamic.c
208 
209  RzBinElfStrtab *dynstr; // should be use with elf_strtab.c
210  RzBinElfStrtab *shstrtab; // should be use with elf_strtab.c
211 
212  RzVector *relocs; // should be use with elf_relocs.c
213 
214  // This is RzVector of note segment reprensented as RzVector<RzBinElfNote>
215  RzVector *notes; // RzVector<RzVector<RzBinElfNote>>
216 
217  RzVector *symbols; // RzVector<RzBinElfSymbol>
218  RzVector *imports; // RzVector<RzBinElfSymbol>
219 };
220 
221 // elf.c
226 
227 // elf_arm.c
228 #define rz_bin_elf_fix_arm_thumb_object_dispatch(object) \
229  Elf_(rz_bin_elf_fix_arm_thumb_object)(&object->paddr, &object->vaddr, &object->bits)
230 
236 
237 // elf_corefile.c
239 
240 // elf_dynamic.c
246 
247 // elf_ehdr.c
264 
265 // elf_hash.c
270 
271 // elf_imports.c
275 
276 // elf_map.c
278 
279 // elf_info.c
308 
309 // elf_notes.c
313 
314 // elf_misc.c
315 bool Elf_(rz_bin_elf_check_array)(RZ_NONNULL ELFOBJ *bin, Elf_(Off) offset, Elf_(Off) length, Elf_(Off) entry_size);
326 #if RZ_BIN_ELF64
329 #else
332 #endif
333 bool Elf_(rz_bin_elf_add_addr)(Elf_(Addr) * result, Elf_(Addr) addr, Elf_(Addr) value);
334 bool Elf_(rz_bin_elf_add_off)(Elf_(Off) * result, Elf_(Off) addr, Elf_(Off) value);
335 bool Elf_(rz_bin_elf_mul_addr)(Elf_(Addr) * result, Elf_(Addr) addr, Elf_(Addr) value);
336 bool Elf_(rz_bin_elf_mul_off)(Elf_(Off) * result, Elf_(Off) addr, Elf_(Off) value);
337 
338 // elf_relocs.c
343 
344 // elf_segments.c
348 
349 // elf_sections.c
357 
358 // elf_strtab
364 
365 // elf_symbols.c
366 typedef bool (*RzBinElfSymbolFilter)(ELFOBJ *bin, Elf_(Sym) * entry, bool is_dynamic);
367 
368 Elf_(Word) Elf_(rz_bin_elf_get_number_of_dynamic_symbols)(RZ_NONNULL ELFOBJ *bin);
373 
374 #endif
static bool is_valid(arm_reg reg)
static ut64 baddr(RzBinFile *bf)
Definition: bin_any.c:58
RzBinInfo * info(RzBinFile *bf)
Definition: bin_ne.c:86
RzList * symbols(RzBinFile *bf)
Definition: bin_ne.c:102
RzList * imports(RzBinFile *bf)
Definition: bin_ne.c:106
RzList * sections(RzBinFile *bf)
Definition: bin_ne.c:110
RzList * relocs(RzBinFile *bf)
Definition: bin_ne.c:114
static ut64 boffset(RzBinFile *bf)
Definition: bin_ninds.c:39
int bits(struct state *s, int need)
Definition: blast.c:72
static int value
Definition: cmd_api.c:93
static static sync static getppid static getegid const char static filename char static len const char char static bufsiz static mask static vfork const void static prot static getpgrp const char static swapflags static arg static fd static protocol static who struct sockaddr static addrlen static backlog struct timeval struct timezone static tz const struct iovec static count static mode const void const struct sockaddr static tolen const char static pathname void static offset struct stat static buf void long static basep static whence static length const void static len key
Definition: sflib.h:118
static static sync static getppid static getegid const char static filename char static len const char char static bufsiz static mask static vfork const void static prot static getpgrp const char static swapflags static arg static fd static protocol static who struct sockaddr static addrlen static backlog struct timeval struct timezone static tz const struct iovec static count static mode const void const struct sockaddr static tolen const char static pathname void static offset struct stat static buf void long static basep static whence static length const void static len static semflg const void static shmflg const struct timespec struct timespec static rem const char static group const void length
Definition: sflib.h:133
uint16_t ut16
uint32_t ut32
RZ_OWN RzVector *Elf_() rz_bin_elf_relocs_new(RZ_NONNULL ELFOBJ *bin)
Definition: elf_relocs.c:202
bool Elf_() rz_bin_elf_is_big_endian(RZ_NONNULL ELFOBJ *bin)
Check the binary endianness.
Definition: elf_info.c:1757
RZ_OWN char *Elf_() rz_bin_elf_get_e_type_as_string(RZ_NONNULL ELFOBJ *bin)
Definition: elf_ehdr.c:170
bool(* RzBinElfSymbolFilter)(ELFOBJ *bin, Elf_(Sym) *entry, bool is_dynamic)
Definition: elf.h:366
size_t Elf_() rz_bin_elf_get_number_of_symbols_from_hash_table(RZ_NONNULL ELFOBJ *bin)
Definition: elf_hash.c:122
RZ_OWN Sdb *Elf_() rz_bin_elf_get_symbols_info(RZ_NONNULL ELFOBJ *bin)
Definition: elf_info.c:1301
size_t Elf_() rz_bin_elf_get_relocs_count(RZ_NONNULL ELFOBJ *bin)
Definition: elf_relocs.c:245
RZ_OWN char *Elf_() rz_bin_elf_get_e_ehsize_as_string(RZ_NONNULL ELFOBJ *bin)
Definition: elf_ehdr.c:82
RZ_BORROW RzBinElfSymbol *Elf_() rz_bin_elf_get_symbol(RZ_NONNULL ELFOBJ *bin, ut32 ordinal)
Definition: elf_symbols.c:473
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
bool Elf_() rz_bin_elf_is_stripped(RZ_NONNULL ELFOBJ *bin)
Check if the binary is stripped.
Definition: elf_info.c:1591
bool Elf_() rz_bin_elf_read_word_xword(RZ_NONNULL ELFOBJ *bin, RZ_NONNULL RZ_INOUT ut64 *offset, RZ_NONNULL RZ_OUT Elf_(Word) *result)
Definition: elf_misc.c:117
bool Elf_() rz_bin_elf_strtab_has_index(RZ_NONNULL RzBinElfStrtab *strtab, ut64 index)
Definition: elf_strtab.c:67
void Elf_() rz_bin_elf_fix_arm_thumb_symbol(RZ_NONNULL RzBinSymbol *symbol)
Definition: elf_arm.c:49
bool Elf_() rz_bin_elf_add_off(Elf_(Off) *result, Elf_(Off) addr, Elf_(Off) value)
Definition: elf_misc.c:146
RZ_OWN char *Elf_() rz_bin_elf_get_file_type(RZ_NONNULL ELFOBJ *bin)
Return a string representing the file type.
Definition: elf_info.c:1462
RzBinElfSegment
Definition: elf.h:131
RZ_BORROW RzBinElfSymbol *Elf_() rz_bin_elf_get_import(RZ_NONNULL ELFOBJ *bin, ut32 ordinal)
Definition: elf_imports.c:316
bool Elf_() rz_bin_elf_is_executable(RZ_NONNULL ELFOBJ *bin)
Check if the elf binary is executable.
Definition: elf_info.c:1648
bool Elf_() rz_bin_elf_get_gnu_hash_table(RZ_NONNULL ELFOBJ *bin, RzBinElfGnuHashTable *result)
Definition: elf_hash.c:64
RZ_OWN char *Elf_() rz_bin_elf_get_e_phnum_as_string(RZ_NONNULL ELFOBJ *bin)
Definition: elf_ehdr.c:134
bool Elf_() rz_bin_elf_mul_off(Elf_(Off) *result, Elf_(Off) addr, Elf_(Off) value)
Definition: elf_misc.c:162
RZ_OWN char *Elf_() rz_bin_elf_get_e_shstrndx_as_string(RZ_NONNULL ELFOBJ *bin)
Definition: elf_ehdr.c:164
bool Elf_() rz_bin_elf_has_dt_dynamic(RZ_NONNULL ELFOBJ *bin)
Definition: elf_dynamic.c:130
ut64 Elf_() rz_bin_elf_get_main_offset(RZ_NONNULL ELFOBJ *bin)
Compute the main offset of the binary.
Definition: elf_info.c:1886
ut64 Elf_() rz_bin_elf_p2v(RZ_NONNULL ELFOBJ *bin, ut64 paddr)
Convert a physical address to the virtual address.
Definition: elf.c:400
bool Elf_() rz_bin_elf_has_va(ELFOBJ *bin)
Check if the elf use virtual address.
Definition: elf_info.c:1637
bool Elf_() rz_bin_elf_read_addr(RZ_NONNULL ELFOBJ *bin, RZ_NONNULL RZ_INOUT ut64 *offset, RZ_NONNULL RZ_OUT Elf_(Addr) *result)
Definition: elf_misc.c:82
#define ELFOBJ
Definition: elf.h:24
RZ_OWN char *Elf_() rz_bin_elf_get_elf_class(RZ_NONNULL ELFOBJ *bin)
Return a string representing the elf class.
Definition: elf_info.c:1443
void Elf_() rz_bin_elf_dt_dynamic_free(RzBinElfDtDynamic *ptr)
Definition: elf_dynamic.c:135
bool Elf_() rz_bin_elf_read_char(RZ_NONNULL ELFOBJ *bin, RZ_NONNULL RZ_INOUT ut64 *offset, RZ_NONNULL RZ_OUT ut8 *result)
Definition: elf_misc.c:52
bool Elf_() rz_bin_elf_has_relocs(RZ_NONNULL ELFOBJ *bin)
Definition: elf_relocs.c:239
struct rz_bin_elf_gnu_hash_table_t RzBinElfGnuHashTable
RzBinElfNote
Definition: elf.h:182
RZ_BORROW RzBinElfSection *Elf_() rz_bin_elf_get_section(RZ_NONNULL ELFOBJ *bin, Elf_(Half) index)
Definition: elf_sections.c:264
bool Elf_() rz_bin_elf_has_nx(RZ_NONNULL ELFOBJ *bin)
Check if the stack is not executable.
Definition: elf_info.c:1615
struct prstatus_layout_t RzBinElfPrStatusLayout
Information about the binary layout in a NT_PRSTATUS note for core files of a certain architecture an...
bool Elf_() rz_bin_elf_is_arm_binary_supporting_thumb(RZ_NONNULL ELFOBJ *bin)
Definition: elf_arm.c:19
RZ_OWN char *Elf_() rz_bin_elf_get_intrp(RZ_NONNULL ELFOBJ *bin)
Get the program interpreter.
Definition: elf_info.c:1568
struct rz_bin_elf_symbol_t RzBinElfSymbol
RZ_OWN RzBinElfDtDynamic *Elf_() rz_bin_elf_dt_dynamic_new(RZ_NONNULL ELFOBJ *bin)
Definition: elf_dynamic.c:98
bool Elf_() rz_bin_elf_read_off(RZ_NONNULL ELFOBJ *bin, RZ_NONNULL RZ_INOUT ut64 *offset, RZ_NONNULL RZ_OUT Elf_(Off) *result)
Definition: elf_misc.c:91
RZ_OWN char *Elf_() rz_bin_elf_get_e_entry_as_string(RZ_NONNULL ELFOBJ *bin)
Definition: elf_ehdr.c:88
RZ_OWN char *Elf_() rz_bin_elf_get_abi(RZ_NONNULL ELFOBJ *bin)
Return a string representing the application binary interface.
Definition: elf_info.c:1386
void Elf_() rz_bin_elf_fix_arm_thumb_addr(ut64 *addr)
Definition: elf_arm.c:28
RZ_OWN char *Elf_() rz_bin_elf_get_e_shoff_as_string(RZ_NONNULL ELFOBJ *bin)
Definition: elf_ehdr.c:158
bool Elf_() rz_bin_elf_is_thumb_addr(ut64 addr)
Definition: elf_arm.c:24
ut64 Elf_() rz_bin_elf_get_baddr(RZ_NONNULL ELFOBJ *bin)
Compute the base address of the binary.
Definition: elf_info.c:1772
bool Elf_() rz_bin_elf_read_sxword(RZ_NONNULL ELFOBJ *bin, RZ_NONNULL RZ_INOUT ut64 *offset, RZ_NONNULL RZ_OUT Elf_(Sxword) *result)
Definition: elf_misc.c:77
bool Elf_() rz_bin_elf_read_word(RZ_NONNULL ELFOBJ *bin, RZ_NONNULL RZ_INOUT ut64 *offset, RZ_NONNULL RZ_OUT Elf_(Word) *result)
Definition: elf_misc.c:62
RZ_OWN char *Elf_() rz_bin_elf_get_machine_name(RZ_NONNULL ELFOBJ *bin)
Return a string representing the machine name.
Definition: elf_info.c:1508
RZ_OWN char *Elf_() rz_bin_elf_get_e_shentsize_as_string(RZ_NONNULL ELFOBJ *bin)
Definition: elf_ehdr.c:146
struct rz_bin_elf_section_t RzBinElfSection
RZ_OWN RzList *Elf_() rz_bin_elf_get_libs(RZ_NONNULL ELFOBJ *bin)
List all imported lib.
Definition: elf_info.c:877
bool Elf_() rz_bin_elf_has_imports(RZ_NONNULL ELFOBJ *bin)
Definition: elf_imports.c:342
struct rz_bin_elf_note_prstatus_t RzBinElfNotePrStatus
Parsed PT_NOTE of type NT_PRSTATUS.
void Elf_() rz_bin_elf_free(RZ_NONNULL ELFOBJ *bin)
Free the elf binary.
Definition: elf.c:366
RZ_OWN RzVector *Elf_() rz_bin_elf_compute_symbols(ELFOBJ *bin, RzBinElfSymbolFilter filter)
Definition: elf_symbols.c:486
bool Elf_() rz_bin_elf_read_xword(RZ_NONNULL ELFOBJ *bin, RZ_NONNULL RZ_INOUT ut64 *offset, RZ_NONNULL RZ_OUT Elf_(Xword) *result)
Definition: elf_misc.c:72
RZ_OWN RzVector *Elf_() rz_bin_elf_symbols_new(RZ_NONNULL ELFOBJ *bin)
Definition: elf_symbols.c:523
bool Elf_() rz_bin_elf_has_notes(RZ_NONNULL ELFOBJ *bin)
Definition: elf_notes.c:255
RZ_BORROW RzBinElfSection *Elf_() rz_bin_elf_get_section_with_name(RZ_NONNULL ELFOBJ *bin, RZ_NONNULL const char *name)
Definition: elf_sections.c:278
bool Elf_() rz_bin_elf_read_half(RZ_NONNULL ELFOBJ *bin, RZ_NONNULL RZ_INOUT ut64 *offset, RZ_NONNULL RZ_OUT Elf_(Half) *result)
Definition: elf_misc.c:57
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 char *Elf_() rz_bin_elf_get_e_machine_as_string(RZ_NONNULL ELFOBJ *bin)
Definition: elf_ehdr.c:122
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_read_section(RZ_NONNULL ELFOBJ *bin, RZ_NONNULL RZ_INOUT ut64 *offset, RZ_NONNULL RZ_OUT Elf_(Section) *result)
Definition: elf_misc.c:100
RzBinElfNoteFile
Definition: elf.h:165
bool Elf_() rz_bin_elf_read_sword_sxword(RZ_NONNULL ELFOBJ *bin, RZ_NONNULL RZ_INOUT ut64 *offset, RZ_NONNULL RZ_OUT Elf_(Sword) *result)
Definition: elf_misc.c:131
bool Elf_() rz_bin_elf_get_dt_info(RZ_NONNULL ELFOBJ *bin, ut64 key, RZ_OUT ut64 *info)
Definition: elf_dynamic.c:120
struct rz_bin_elf_reloc_t RzBinElfReloc
RZ_OWN char *Elf_() rz_bin_elf_get_rpath(RZ_NONNULL ELFOBJ *bin)
Get the rpath.
Definition: elf_info.c:1550
RZ_OWN char *Elf_() rz_bin_elf_get_e_flags_as_string(RZ_NONNULL ELFOBJ *bin)
Definition: elf_ehdr.c:94
RZ_OWN char *Elf_() rz_bin_elf_get_arch(RZ_NONNULL ELFOBJ *bin)
Get the elf binary architecture.
Definition: elf_info.c:1403
RZ_OWN ELFOBJ *Elf_() rz_bin_elf_new_buf(RZ_NONNULL RzBuffer *buf, RZ_NONNULL RzBinObjectLoadOptions *options)
Definition: elf.c:339
bool Elf_() rz_bin_elf_read_versym(RZ_NONNULL ELFOBJ *bin, RZ_NONNULL RZ_INOUT ut64 *offset, RZ_NONNULL RZ_OUT Elf_(Versym) *result)
Definition: elf_misc.c:105
RZ_BORROW RzVector *Elf_() rz_bin_elf_get_dt_needed(RZ_NONNULL ELFOBJ *bin)
Definition: elf_dynamic.c:88
RZ_OWN RzVector *Elf_() rz_bin_elf_segments_new(RZ_NONNULL ELFOBJ *bin, RzVector *sections, RZ_NONNULL RzBinObjectLoadOptions *options)
Definition: elf_segments.c:133
ut64 Elf_() rz_bin_elf_get_num_relocs_dynamic_plt(RZ_NONNULL ELFOBJ *bin)
Definition: elf_relocs.c:255
RZ_OWN RzVector *Elf_() rz_bin_elf_analyse_imports(RZ_NONNULL ELFOBJ *bin)
Definition: elf_imports.c:329
RZ_OWN char *Elf_() rz_bin_elf_section_type_to_string(ut64 type)
Return a string representing the elf type.
Definition: elf_sections.c:422
struct Elf_(rz_bin_elf_segment_t)
Definition: elf.h:127
RZ_OWN char *Elf_() rz_bin_elf_get_e_version_as_string(RZ_NONNULL ELFOBJ *bin)
Definition: elf_ehdr.c:176
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_add_addr(Elf_(Addr) *result, Elf_(Addr) addr, Elf_(Addr) value)
Definition: elf_misc.c:138
bool Elf_() rz_bin_elf_has_sections(RZ_NONNULL ELFOBJ *bin)
Definition: elf_sections.c:440
RZ_OWN char *Elf_() rz_bin_elf_get_head_flag(RZ_NONNULL ELFOBJ *bin)
Return the head flag.
Definition: elf_info.c:1487
bool Elf_() rz_bin_elf_mul_addr(Elf_(Addr) *result, Elf_(Addr) addr, Elf_(Addr) value)
Definition: elf_misc.c:154
bool Elf_() rz_bin_elf_get_hash_table(RZ_NONNULL ELFOBJ *bin, RzBinElfHashTable *result)
Definition: elf_hash.c:85
bool Elf_() rz_bin_elf_is_relocatable(RZ_NONNULL ELFOBJ *bin)
Check if the elf binary is relocatable.
Definition: elf_info.c:1662
RZ_OWN char *Elf_() rz_bin_elf_get_e_phoff_as_string(RZ_NONNULL ELFOBJ *bin)
Definition: elf_ehdr.c:140
RZ_OWN char *Elf_() rz_bin_elf_get_osabi_name(RZ_NONNULL ELFOBJ *bin)
Return the os application binary interface name.
Definition: elf_info.c:1527
ut64 Elf_() rz_bin_elf_get_init_offset(RZ_NONNULL ELFOBJ *bin)
Compute the init offset of the binary.
Definition: elf_info.c:1863
RZ_OWN char *Elf_() rz_bin_elf_strtab_get_dup(RZ_NONNULL RzBinElfStrtab *strtab, ut64 index)
Definition: elf_strtab.c:52
bool Elf_() rz_bin_elf_read_sword(RZ_NONNULL ELFOBJ *bin, RZ_NONNULL RZ_INOUT ut64 *offset, RZ_NONNULL RZ_OUT Elf_(Sword) *result)
Definition: elf_misc.c:67
RZ_BORROW RzBinElfPrStatusLayout *Elf_() rz_bin_elf_get_prstatus_layout(RZ_NONNULL ELFOBJ *bin)
Definition: elf_notes.c:201
size_t Elf_() rz_bin_elf_get_number_of_symbols_from_gnu_hash_table(RZ_NONNULL ELFOBJ *bin)
Definition: elf_hash.c:106
bool Elf_() rz_bin_elf_has_symbols(RZ_NONNULL ELFOBJ *bin)
Definition: elf_symbols.c:534
ut64 Elf_() rz_bin_elf_get_entry_offset(RZ_NONNULL ELFOBJ *bin)
Get the entry offset.
Definition: elf_info.c:1813
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
RZ_OWN char *Elf_() rz_bin_elf_get_e_indent_as_string(RZ_NONNULL ELFOBJ *bin)
Definition: elf_ehdr.c:100
RZ_OWN char *Elf_() rz_bin_elf_get_cpu(RZ_NONNULL ELFOBJ *bin)
Return a string representing the cpu.
Definition: elf_info.c:1422
RZ_OWN char *Elf_() rz_bin_elf_get_e_shnum_as_string(RZ_NONNULL ELFOBJ *bin)
Definition: elf_ehdr.c:152
ut64 Elf_() rz_bin_elf_v2p(RZ_NONNULL ELFOBJ *bin, ut64 vaddr)
Convert a virtual address to the physical address.
Definition: elf.c:429
ut64 Elf_() rz_bin_elf_get_sp_val(RZ_NONNULL ELFOBJ *bin)
Get the stack pointer value.
Definition: elf_corefile.c:16
RZ_BORROW const char *Elf_() rz_bin_elf_strtab_get(RZ_NONNULL RzBinElfStrtab *strtab, ut64 index)
Definition: elf_strtab.c:8
struct rz_bin_elf_hash_table_ RzBinElfHashTable
RZ_OWN char *Elf_() rz_bin_elf_get_compiler(RZ_NONNULL ELFOBJ *bin)
Get the compiler info from the .comment section.
Definition: elf_info.c:1339
RZ_BORROW RzBinElfSegment *Elf_() rz_bin_elf_get_segment_with_type(RZ_NONNULL ELFOBJ *bin, Elf_(Word) type)
Definition: elf_segments.c:120
bool Elf_() rz_bin_elf_print_ehdr(ELFOBJ *bin, RZ_NONNULL PrintfCallback cb)
Definition: elf_ehdr.c:202
RZ_OWN RzList *Elf_() rz_bin_elf_section_flag_to_rzlist(ut64 flag)
Return a list of string representing flag options.
Definition: elf_sections.c:298
void Elf_() rz_bin_elf_fix_arm_thumb_object(RZ_NONNULL ut64 *paddr, RZ_NONNULL ut64 *vaddr, RZ_NONNULL int *bits)
Definition: elf_arm.c:33
bool Elf_() rz_bin_elf_check_array(RZ_NONNULL ELFOBJ *bin, Elf_(Off) offset, Elf_(Off) length, Elf_(Off) entry_size)
Definition: elf_misc.c:32
RZ_OWN char *Elf_() rz_bin_elf_get_e_phentsize_as_string(RZ_NONNULL ELFOBJ *bin)
Definition: elf_ehdr.c:128
ut64 Elf_() rz_bin_elf_get_fini_offset(RZ_NONNULL ELFOBJ *bin)
Compute the fini offset of the binary.
Definition: elf_info.c:1840
voidpf void uLong size
Definition: ioapi.h:138
voidpf uLong offset
Definition: ioapi.h:144
voidpf void * buf
Definition: ioapi.h:138
uint8_t ut8
Definition: lh5801.h:11
static const char struct stat static buf struct stat static buf static vhangup int options
Definition: sflib.h:145
RZ_API ut64 MACH0_() reloc_targets_map_base(RzBinFile *bf, struct MACH0_(obj_t) *obj)
base vaddr where to map the artificial reloc target vfile
Definition: mach0_relocs.c:556
int type
Definition: mipsasm.c:17
const char * name
Definition: op.c:541
static bool filter(RzParse *p, ut64 addr, RzFlag *f, RzAnalysisHint *hint, char *data, char *str, int len, bool big_endian)
Definition: filter.c:185
#define RZ_OWN
Definition: rz_types.h:62
#define RZ_OUT
Definition: rz_types.h:51
#define RZ_NONNULL
Definition: rz_types.h:64
int(* PrintfCallback)(const char *str,...) RZ_PRINTF_CHECK(1
Definition: rz_types.h:233
#define RZ_INOUT
Definition: rz_types.h:52
#define RZ_BORROW
Definition: rz_types.h:63
#define st64
Definition: rz_types_base.h:10
#define b(i)
Definition: sha256.c:42
Definition: malloc.c:26
Elf_(Word) nchains
Elf_(Word) nbuckets
Definition: zipcmp.c:77
Elf_(Word) bloom_size
Elf_(Word) symoffset
Elf_(Word) nbuckets
Elf_(Word) bloom_shift
Information about the binary layout in a NT_PRSTATUS note for core files of a certain architecture an...
Definition: elf.h:82
ut64 regsize
Definition: elf.h:83
ut64 regdelta
Definition: elf.h:94
ut64 sp_offset
Definition: elf.h:108
ut8 sp_size
Size of the stack pointer register in bits.
Definition: elf.h:97
struct gnu_hash_table data
Definition: elf.h:66
struct elf_hash_table data
Definition: elf.h:78
Parsed PT_NOTE of type NT_PRSTATUS.
Definition: elf.h:168
st64 addend
exact addend value taken from the ELF, meaning depends on type
Definition: elf.h:147
ut64 offset
exact offset value taken from the ELF, meaning depends on the binary type
Definition: elf.h:148
ut16 section
Definition: elf.h:152
ut64 target_vaddr
after patching, the target that this reloc points to
Definition: elf.h:151
ut64 vaddr
source vaddr of the reloc, calculated from offset
Definition: elf.h:150
ut64 paddr
absolute paddr in the file, calculated from offset, or UT64_MAX if no such addr exists
Definition: elf.h:149
RZ_OWN char * name
Definition: elf.h:140
const char * bind
Definition: elf.h:138
const char * type
Definition: elf.h:139
Definition: sdb.h:63
#define bool
Definition: sysdefs.h:146
ut64(WINAPI *w32_GetEnabledXStateFeatures)()
static const char * cb[]
Definition: z80_tab.h:176
static int file
Definition: z80asm.c:58
static int addr
Definition: z80asm.c:58