Rizin
unix-like reverse engineering framework and cli tools
bflt.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: 2021 Florian Märkl <info@florianmaerkl.de>
2 // SPDX-FileCopyrightText: 2016 Oscar Salvador <osalvador.vilardaga@gmail.com>
3 // SPDX-License-Identifier: LGPL-3.0-only
4 
5 #ifndef BFLT_H
6 #define BFLT_H
7 
8 #include <rz_types.h>
9 #include <rz_util.h>
10 #include <rz_lib.h>
11 #include <rz_bin.h>
12 
13 /* Version 4 */
14 #define FLAT_VERSION 0x00000004L
15 #define FLAT_FLAG_RAM 0x1 /* load program entirely into RAM */
16 #define FLAT_FLAG_GOTPIC 0x2 /* program is PIC with GOT */
17 #define FLAT_FLAG_GZIP 0x4 /* all but the header is compressed */
18 #define FLAT_FLAG_GZDATA 0x8 /* only data/relocs are compressed (for XIP) */
19 #define FLAT_FLAG_KTRACE 0x10 /* output useful kernel trace for debugging */
20 
21 typedef struct rz_bflt_hdr_t {
22  char magic[4];
35 
36 typedef struct rz_bflt_reloc_t {
40 
41 typedef struct rz_bflt_obj_t {
43  RzVector /*<RzBfltReloc>*/ relocs;
44  RzVector /*<RzBfltReloc>*/ got_relocs;
48  bool big_endian;
49  size_t size;
52 
53 #define BFLT_HDR_SIZE sizeof(RzBfltHdr)
54 
55 RzBfltObj *rz_bflt_new_buf(RzBuffer *buf, ut64 baddr, bool big_endian, bool patch_relocs);
56 void rz_bflt_free(RzBfltObj *obj);
62 
63 #endif
ut64 rz_bflt_get_data_base(RzBfltObj *bin)
Address to map data+bss segment to.
Definition: bflt.c:198
RzBinAddr * rz_bflt_get_entry(RzBfltObj *bin)
Definition: bflt.c:183
struct rz_bflt_obj_t RzBfltObj
struct rz_bflt_hdr_t RzBfltHdr
RzBfltObj * rz_bflt_new_buf(RzBuffer *buf, ut64 baddr, bool big_endian, bool patch_relocs)
Definition: bflt.c:164
void rz_bflt_free(RzBfltObj *obj)
Definition: bflt.c:173
ut64 rz_bflt_paddr_to_vaddr(RzBfltObj *bin, ut32 paddr)
Definition: bflt.c:208
ut64 rz_bflt_get_data_vsize(RzBfltObj *bin)
Total size of data+bss.
Definition: bflt.c:204
struct rz_bflt_reloc_t RzBfltReloc
ut64 rz_bflt_get_text_base(RzBfltObj *bin)
Address to map text segment to.
Definition: bflt.c:193
static ut64 baddr(RzBinFile *bf)
Definition: bin_any.c:58
uint32_t ut32
voidpf void * buf
Definition: ioapi.h:138
RZ_API void MACH0_() patch_relocs(RzBinFile *bf, struct MACH0_(obj_t) *obj)
Patching of external relocs in a sparse overlay buffer.
Definition: mach0_relocs.c:614
unsigned int uint32_t
Definition: sftypes.h:29
Definition: malloc.c:26
ut32 rev
Definition: bflt.h:23
ut32 data_start
Definition: bflt.h:25
char magic[4]
Definition: bflt.h:22
ut32 flags
Definition: bflt.h:31
ut32 entry
Definition: bflt.h:24
ut32 reloc_count
Definition: bflt.h:30
ut32 build_date
Definition: bflt.h:32
ut32 reloc_start
Definition: bflt.h:29
ut32 bss_end
Definition: bflt.h:27
ut32 filler[5]
Definition: bflt.h:33
ut32 stack_size
Definition: bflt.h:28
ut32 data_end
Definition: bflt.h:26
bool big_endian
Definition: bflt.h:48
RzBuffer * b
Definition: bflt.h:45
RzBfltHdr hdr
Definition: bflt.h:42
size_t size
Definition: bflt.h:49
ut64 baddr
Definition: bflt.h:47
RzVector got_relocs
Definition: bflt.h:44
RzVector relocs
Definition: bflt.h:43
RzBuffer * buf_patched
overlay over the original file with relocs patched
Definition: bflt.h:46
uint32_t n_got
Definition: bflt.h:50
ut32 reloc_paddr
where to patch, offset from the beginning of the file
Definition: bflt.h:37
ut32 value_orig
original value at that address
Definition: bflt.h:38
ut64(WINAPI *w32_GetEnabledXStateFeatures)()