}
static RList *entries(RBinFile *bf) {
- RList *ret;
- RBinAddr *ptr = NULL;
RBinPlan9Obj *o = (RBinPlan9Obj *)bf->bo->bin_obj;
-
- if (!(ret = r_list_new ())) {
- return NULL;
- }
-
- ret->free = free;
-
- if ((ptr = R_NEW0 (RBinAddr))) {
- ptr->paddr = o->entry - baddr (bf);
- // for kernels the header is not mapped
- if (o->is_kernel) {
- ptr->paddr += o->header_size;
- }
- ptr->vaddr = o->entry;
- r_list_append (ret, ptr);
+ RList *ret = r_list_newf (free);
+ RBinAddr *ptr = R_NEW0 (RBinAddr);
+ ptr->paddr = o->entry - baddr (bf);
+ // for kernels the header is not mapped
+ if (o->is_kernel) {
+ ptr->paddr += o->header_size;
}
+ ptr->vaddr = o->entry;
+ r_list_append (ret, ptr);
return ret;
}
static RList *sections(RBinFile *bf) {
RList *ret = NULL;
- RBinSection *ptr = NULL;
RBinPlan9Obj *o = (RBinPlan9Obj *)bf->bo->bin_obj;
if (!bf->bo->info) {
ut64 vsize = 0;
// add text segment
- if (!(ptr = R_NEW0 (RBinSection))) {
- return ret;
- }
+ RBinSection *ptr = R_NEW0 (RBinSection);
ptr->name = strdup ("text");
ptr->size = o->header.text;
// for regular applications: header is included in the text segment
align = 0x1000;
// add data segment
- if (!(ptr = R_NEW0 (RBinSection))) {
- return ret;
- }
+ ptr = R_NEW0 (RBinSection);
ptr->name = strdup ("data");
ptr->size = o->header.data;
ptr->vsize = P9_ALIGN (o->header.data, align);
vsize += ptr->vsize;
// add bss segment
- if (!(ptr = R_NEW0 (RBinSection))) {
- return ret;
- }
+ ptr = R_NEW0 (RBinSection);
ptr->name = strdup ("bss");
ptr->size = 0;
ptr->vsize = P9_ALIGN (o->header.bss, align);
vsize += ptr->vsize;
// add syms segment
- if (!(ptr = R_NEW0 (RBinSection))) {
- return ret;
- }
+ ptr = R_NEW0 (RBinSection);
ptr->name = strdup ("syms");
ptr->size = o->header.syms;
ptr->vsize = P9_ALIGN (o->header.syms, align);
vsize += ptr->vsize;
// add pc/sp offsets segment
- if (!(ptr = R_NEW0 (RBinSection))) {
- return ret;
- }
+ ptr = R_NEW0 (RBinSection);
ptr->name = strdup ("pcsp");
ptr->size = o->header.spsz;
ptr->vsize = P9_ALIGN (o->header.spsz, align);
vsize += ptr->vsize;
// add pc/line numbers segment
- if (!(ptr = R_NEW0 (RBinSection))) {
- return ret;
- }
+ ptr = R_NEW0 (RBinSection);
ptr->name = strdup ("pcline");
ptr->size = o->header.pcsz;
ptr->vsize = P9_ALIGN (o->header.pcsz, align);
}
RBinSymbol *bin_sym = R_NEW0 (RBinSymbol);
- if (!bin_sym) {
- goto error;
- }
-
bin_sym->name = r_bin_name_new (sym.name);
bin_sym->paddr = sym.value - baddr (bf);
// for kernels the header is not mapped
pc += o->pcq;
- if (prev != line && r_vector_length (history) > 1) {
+ if (history && prev != line && r_vector_length (history) > 1) {
apply_history (bf, pc, line, r_vector_at (history, 0), NULL);
}
}
}
static RBinInfo *info(RBinFile *bf) {
- RBinInfo *ret = NULL;
const char *arch;
int bits, big_endian;
struct plan9_exec header;
return NULL;
}
- if (!(ret = R_NEW0 (RBinInfo))) {
- return NULL;
- }
-
+ RBinInfo *ret = R_NEW0 (RBinInfo);
ret->file = strdup (bf->file);
ret->bclass = strdup ("program");
ret->rclass = strdup ("p9");