mirror of
https://github.com/radareorg/radare2.git
synced 2025-02-13 18:32:56 +00:00
Implement RBinInfo.nx check for ELF (need tests)
This commit is contained in:
parent
231b6b21d6
commit
1686073c8b
@ -65,7 +65,8 @@ static int Elf_(r_bin_elf_init_phdr)(struct Elf_(r_bin_elf_obj_t) *bin) {
|
||||
R_FREE (bin->phdr);
|
||||
return R_FALSE;
|
||||
}
|
||||
sdb_bool_set (bin->kv, "elf.relro", Elf_(r_bin_elf_have_relro)(bin), 0);
|
||||
sdb_bool_set (bin->kv, "elf.relro", Elf_(r_bin_elf_has_relro)(bin), 0);
|
||||
sdb_bool_set (bin->kv, "elf.nx", Elf_(r_bin_elf_has_nx)(bin), 0);
|
||||
return R_TRUE;
|
||||
}
|
||||
|
||||
@ -302,7 +303,16 @@ static ut64 Elf_(get_import_addr)(struct Elf_(r_bin_elf_obj_t) *bin, int sym) {
|
||||
return UT64_MAX;
|
||||
}
|
||||
|
||||
int Elf_(r_bin_elf_have_relro)(struct Elf_(r_bin_elf_obj_t) *bin) {
|
||||
int Elf_(r_bin_elf_has_nx)(struct Elf_(r_bin_elf_obj_t) *bin) {
|
||||
int i;
|
||||
if (bin->phdr)
|
||||
for (i = 0; i < bin->ehdr.e_phnum; i++)
|
||||
if (bin->phdr[i].p_type == PT_GNU_STACK)
|
||||
return (!(bin->phdr[i].p_type & 1))? 1: 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Elf_(r_bin_elf_has_relro)(struct Elf_(r_bin_elf_obj_t) *bin) {
|
||||
int i;
|
||||
if (bin->phdr)
|
||||
for (i = 0; i < bin->ehdr.e_phnum; i++)
|
||||
|
@ -123,7 +123,8 @@ struct Elf_(r_bin_elf_obj_t)* Elf_(r_bin_elf_new)(const char* file);
|
||||
struct Elf_(r_bin_elf_obj_t)* Elf_(r_bin_elf_new_buf)(struct r_buf_t *buf);
|
||||
ut64 Elf_(r_bin_elf_resize_section)(struct Elf_(r_bin_elf_obj_t) *bin, const char *name, ut64 size);
|
||||
int Elf_(r_bin_elf_del_rpath)(struct Elf_(r_bin_elf_obj_t) *bin);
|
||||
int Elf_(r_bin_elf_have_relro)(struct Elf_(r_bin_elf_obj_t) *bin);
|
||||
int Elf_(r_bin_elf_has_relro)(struct Elf_(r_bin_elf_obj_t) *bin);
|
||||
int Elf_(r_bin_elf_has_nx)(struct Elf_(r_bin_elf_obj_t) *bin);
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -487,6 +487,7 @@ static RBinInfo* info(RBinFile *arch) {
|
||||
ret->bits = Elf_(r_bin_elf_get_bits) (arch->o->bin_obj);
|
||||
ret->big_endian = Elf_(r_bin_elf_is_big_endian) (arch->o->bin_obj);
|
||||
ret->has_va = Elf_(r_bin_elf_has_va) (arch->o->bin_obj);
|
||||
ret->has_nx = Elf_(r_bin_elf_has_nx) (arch->o->bin_obj);
|
||||
ret->dbg_info = 0;
|
||||
if (!Elf_(r_bin_elf_get_stripped) (arch->o->bin_obj))
|
||||
ret->dbg_info |= 0x04 | 0x08 | 0x10;
|
||||
|
Loading…
x
Reference in New Issue
Block a user