Rizin
unix-like reverse engineering framework and cli tools
bflt.h File Reference
#include <rz_types.h>
#include <rz_util.h>
#include <rz_lib.h>
#include <rz_bin.h>

Go to the source code of this file.

Classes

struct  rz_bflt_hdr_t
 
struct  rz_bflt_reloc_t
 
struct  rz_bflt_obj_t
 

Macros

#define FLAT_VERSION   0x00000004L
 
#define FLAT_FLAG_RAM   0x1 /* load program entirely into RAM */
 
#define FLAT_FLAG_GOTPIC   0x2 /* program is PIC with GOT */
 
#define FLAT_FLAG_GZIP   0x4 /* all but the header is compressed */
 
#define FLAT_FLAG_GZDATA   0x8 /* only data/relocs are compressed (for XIP) */
 
#define FLAT_FLAG_KTRACE   0x10 /* output useful kernel trace for debugging */
 
#define BFLT_HDR_SIZE   sizeof(RzBfltHdr)
 

Typedefs

typedef struct rz_bflt_hdr_t RzBfltHdr
 
typedef struct rz_bflt_reloc_t RzBfltReloc
 
typedef struct rz_bflt_obj_t RzBfltObj
 

Functions

RzBfltObjrz_bflt_new_buf (RzBuffer *buf, ut64 baddr, bool big_endian, bool patch_relocs)
 
void rz_bflt_free (RzBfltObj *obj)
 
RzBinAddrrz_bflt_get_entry (RzBfltObj *bin)
 
ut64 rz_bflt_get_text_base (RzBfltObj *bin)
 Address to map text segment to. More...
 
ut64 rz_bflt_get_data_base (RzBfltObj *bin)
 Address to map data+bss segment to. More...
 
ut64 rz_bflt_get_data_vsize (RzBfltObj *bin)
 Total size of data+bss. More...
 
ut64 rz_bflt_paddr_to_vaddr (RzBfltObj *bin, ut32 paddr)
 

Macro Definition Documentation

◆ BFLT_HDR_SIZE

#define BFLT_HDR_SIZE   sizeof(RzBfltHdr)

Definition at line 53 of file bflt.h.

◆ FLAT_FLAG_GOTPIC

#define FLAT_FLAG_GOTPIC   0x2 /* program is PIC with GOT */

Definition at line 16 of file bflt.h.

◆ FLAT_FLAG_GZDATA

#define FLAT_FLAG_GZDATA   0x8 /* only data/relocs are compressed (for XIP) */

Definition at line 18 of file bflt.h.

◆ FLAT_FLAG_GZIP

#define FLAT_FLAG_GZIP   0x4 /* all but the header is compressed */

Definition at line 17 of file bflt.h.

◆ FLAT_FLAG_KTRACE

#define FLAT_FLAG_KTRACE   0x10 /* output useful kernel trace for debugging */

Definition at line 19 of file bflt.h.

◆ FLAT_FLAG_RAM

#define FLAT_FLAG_RAM   0x1 /* load program entirely into RAM */

Definition at line 15 of file bflt.h.

◆ FLAT_VERSION

#define FLAT_VERSION   0x00000004L

Definition at line 14 of file bflt.h.

Typedef Documentation

◆ RzBfltHdr

typedef struct rz_bflt_hdr_t RzBfltHdr

◆ RzBfltObj

typedef struct rz_bflt_obj_t RzBfltObj

◆ RzBfltReloc

typedef struct rz_bflt_reloc_t RzBfltReloc

Function Documentation

◆ rz_bflt_free()

void rz_bflt_free ( RzBfltObj obj)

Definition at line 173 of file bflt.c.

173  {
174  if (obj) {
175  rz_buf_free(obj->b);
176  rz_buf_free(obj->buf_patched);
177  rz_vector_fini(&obj->relocs);
178  rz_vector_fini(&obj->got_relocs);
179  RZ_FREE(obj);
180  }
181 }
RZ_API void rz_buf_free(RzBuffer *b)
Free all internal data hold by the buffer and the buffer.
Definition: buf.c:1253
#define RZ_FREE(x)
Definition: rz_types.h:369
RZ_API void rz_vector_fini(RzVector *vec)
Definition: vector.c:61
RzBuffer * b
Definition: bflt.h:45
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

References rz_bflt_obj_t::b, rz_bflt_obj_t::buf_patched, rz_bflt_obj_t::got_relocs, rz_bflt_obj_t::relocs, rz_buf_free(), RZ_FREE, and rz_vector_fini().

Referenced by destroy(), and rz_bflt_new_buf().

◆ rz_bflt_get_data_base()

ut64 rz_bflt_get_data_base ( RzBfltObj bin)

Address to map data+bss segment to.

Definition at line 198 of file bflt.c.

198  {
199  ut64 r = bin->baddr + bin->hdr.data_start + MAX_SHARED_LIBS * sizeof(ut32);
201 }
#define FLAT_DATA_ALIGN
Definition: bflt.c:20
#define MAX_SHARED_LIBS
Definition: bflt.c:19
#define r
Definition: crypto_rc6.c:12
uint32_t ut32
static ut64 rz_num_align_delta(ut64 v, ut64 alignment)
Padding to align v to the next alignment-boundary.
Definition: rz_num.h:116
Definition: malloc.c:26
ut64(WINAPI *w32_GetEnabledXStateFeatures)()

References FLAT_DATA_ALIGN, MAX_SHARED_LIBS, r, rz_num_align_delta(), and ut64().

Referenced by maps(), rz_bflt_paddr_to_vaddr(), and sections().

◆ rz_bflt_get_data_vsize()

ut64 rz_bflt_get_data_vsize ( RzBfltObj bin)

Total size of data+bss.

Definition at line 204 of file bflt.c.

204  {
205  return RZ_MAX(bin->hdr.data_end, bin->hdr.bss_end) - bin->hdr.data_start;
206 }
#define RZ_MAX(x, y)

References RZ_MAX.

Referenced by maps(), and sections().

◆ rz_bflt_get_entry()

RzBinAddr* rz_bflt_get_entry ( RzBfltObj bin)

Definition at line 183 of file bflt.c.

183  {
185  if (addr && bin) {
186  addr->paddr = bin->hdr.entry;
187  addr->vaddr = rz_bflt_get_text_base(bin) + bin->hdr.entry;
188  }
189  return addr;
190 }
ut64 rz_bflt_get_text_base(RzBfltObj *bin)
Address to map text segment to.
Definition: bflt.c:193
#define RZ_NEW0(x)
Definition: rz_types.h:284
static int addr
Definition: z80asm.c:58

References addr, rz_bflt_get_text_base(), and RZ_NEW0.

Referenced by entries().

◆ rz_bflt_get_text_base()

ut64 rz_bflt_get_text_base ( RzBfltObj bin)

Address to map text segment to.

Definition at line 193 of file bflt.c.

193  {
194  return bin->baddr;
195 }

Referenced by maps(), rz_bflt_get_entry(), and sections().

◆ rz_bflt_new_buf()

RzBfltObj* rz_bflt_new_buf ( RzBuffer buf,
ut64  baddr,
bool  big_endian,
bool  patch_relocs 
)

Definition at line 164 of file bflt.c.

164  {
166  if (bin && rz_bflt_init(bin, buf, baddr, big_endian, patch_relocs)) {
167  return bin;
168  }
169  rz_bflt_free(bin);
170  return NULL;
171 }
static bool rz_bflt_init(RzBfltObj *obj, RzBuffer *buf, ut64 baddr, bool big_endian, bool patch_relocs)
Definition: bflt.c:147
void rz_bflt_free(RzBfltObj *obj)
Definition: bflt.c:173
static ut64 baddr(RzBinFile *bf)
Definition: bin_any.c:58
#define NULL
Definition: cris-opc.c:27
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

References baddr(), NULL, patch_relocs(), rz_bflt_free(), rz_bflt_init(), and RZ_NEW0.

Referenced by load_buffer().

◆ rz_bflt_paddr_to_vaddr()

ut64 rz_bflt_paddr_to_vaddr ( RzBfltObj bin,
ut32  paddr 
)

Definition at line 208 of file bflt.c.

208  {
209  if (paddr >= bin->hdr.data_start) {
210  return rz_bflt_get_data_base(bin) + paddr - bin->hdr.data_start;
211  }
212  return bin->baddr + paddr;
213 }
ut64 rz_bflt_get_data_base(RzBfltObj *bin)
Address to map data+bss segment to.
Definition: bflt.c:198

References rz_bflt_get_data_base().

Referenced by convert_relocs(), and patch_relocs_in().