19 #define MAX_SHARED_LIBS 1
20 #define FLAT_DATA_ALIGN 0x20
23 rz_read_be32((x) + (i)); \
34 if (strncmp((
const char *)bhdr,
"bFLT", 4)) {
46 bin->hdr.reloc_start =
READ(bhdr,
i);
47 bin->hdr.reloc_count =
READ(bhdr,
i);
56 RZ_LOG_WARN(
"this bFLT file is compressed. This is not (yet) supported.\n");
77 if (paddr + 4 >
bin->size || paddr + 4 < paddr) {
81 if (!rz_buf_read_ble32_at(
bin->b, paddr, &
value, big_endian)) {
84 if (
value == 0xffffffff) {
97 for (
ut32 i = 0;
i <
bin->hdr.reloc_count;
i++) {
98 ut32 table_paddr =
bin->hdr.reloc_start +
i * 4;
99 if (table_paddr + 4 >
bin->size || table_paddr + 4 <
bin->hdr.reloc_start) {
107 if (reloc_paddr + 4 < reloc_paddr || reloc_paddr >
bin->size) {
111 if (!rz_buf_read_ble32_at(
bin->b, reloc_paddr, &
value, big_endian)) {
130 rz_buf_write_ble32_at(
bin->buf_patched,
139 if (!
bin->buf_patched) {
205 return RZ_MAX(
bin->hdr.data_end,
bin->hdr.bss_end) -
bin->hdr.data_start;
209 if (paddr >=
bin->hdr.data_start) {
212 return bin->baddr + paddr;
static bool rz_bflt_init(RzBfltObj *obj, RzBuffer *buf, ut64 baddr, bool big_endian, bool patch_relocs)
ut64 rz_bflt_get_data_base(RzBfltObj *bin)
Address to map data+bss segment to.
RzBinAddr * rz_bflt_get_entry(RzBfltObj *bin)
static void patch_relocs_in(RzBfltObj *bin, RzVector *relocs)
static void bflt_patch_relocs(RzBfltObj *bin)
RzBfltObj * rz_bflt_new_buf(RzBuffer *buf, ut64 baddr, bool big_endian, bool patch_relocs)
void rz_bflt_free(RzBfltObj *obj)
static bool bflt_reloc_big_endian(RzBfltObj *bin)
ut64 rz_bflt_paddr_to_vaddr(RzBfltObj *bin, ut32 paddr)
static bool bflt_init_hdr(RzBfltObj *bin)
ut64 rz_bflt_get_data_vsize(RzBfltObj *bin)
Total size of data+bss.
static void bflt_load_relocs(RzBfltObj *bin)
ut64 rz_bflt_get_text_base(RzBfltObj *bin)
Address to map text segment to.
static ut64 baddr(RzBinFile *bf)
RzList * relocs(RzBinFile *bf)
RZ_API void MACH0_() patch_relocs(RzBinFile *bf, struct MACH0_(obj_t) *obj)
Patching of external relocs in a sparse overlay buffer.
RZ_API void rz_buf_sparse_set_write_mode(RzBuffer *b, RzBufferSparseWriteMode mode)
Only for sparse RzBuffers.
RZ_API RzBuffer * rz_buf_ref(RzBuffer *b)
Increment the reference count of the buffer.
RZ_API st64 rz_buf_read_at(RZ_NONNULL RzBuffer *b, ut64 addr, RZ_NONNULL RZ_OUT ut8 *buf, ut64 len)
Read len bytes of the buffer at the specified address.
#define rz_buf_read_be32_at(b, addr, result)
@ RZ_BUF_SPARSE_WRITE_MODE_SPARSE
all writes are performed in the sparse overlay
@ RZ_BUF_SPARSE_WRITE_MODE_THROUGH
all writes are performed in the underlying base buffer
RZ_API void rz_buf_free(RzBuffer *b)
Free all internal data hold by the buffer and the buffer.
RZ_API ut64 rz_buf_size(RZ_NONNULL RzBuffer *b)
Return the size of the buffer.
RZ_API RZ_OWN RzBuffer * rz_buf_new_sparse_overlay(RzBuffer *b, RzBufferSparseWriteMode write_mode)
Creates a sparse buffer from a already populated buffer.
#define RZ_LOG_WARN(fmtstr,...)
static ut64 rz_num_align_delta(ut64 v, ut64 alignment)
Padding to align v to the next alignment-boundary.
RZ_API void * rz_vector_push(RzVector *vec, void *x)
#define rz_vector_foreach(vec, it)
RZ_API void rz_vector_fini(RzVector *vec)
RZ_API void rz_vector_init(RzVector *vec, size_t elem_size, RzVectorFree free, void *free_user)
RzBuffer * buf_patched
overlay over the original file with relocs patched
ut32 reloc_paddr
where to patch, offset from the beginning of the file
ut32 value_orig
original value at that address
ut64(WINAPI *w32_GetEnabledXStateFeatures)()