Rizin
unix-like reverse engineering framework and cli tools
elf_map.c File Reference
#include "elf.h"

Go to the source code of this file.

Functions

static ut64 get_targets_map_base_from_segments (ELFOBJ *bin)
 
static ut64 get_targets_map_base_from_sections (ELFOBJ *bin)
 
static ut64 get_targets_map_base (ELFOBJ *bin)
 
ut64 Elf_() rz_bin_elf_get_targets_map_base (ELFOBJ *bin)
 

Function Documentation

◆ get_targets_map_base()

static ut64 get_targets_map_base ( ELFOBJ bin)
static

Definition at line 36 of file elf_map.c.

36  {
39  }
40 
42 }
bool Elf_() rz_bin_elf_has_segments(RZ_NONNULL ELFOBJ *bin)
Definition: elf_segments.c:149
static ut64 get_targets_map_base_from_segments(ELFOBJ *bin)
Definition: elf_map.c:7
static ut64 get_targets_map_base_from_sections(ELFOBJ *bin)
Definition: elf_map.c:22
#define Elf_(name)
Definition: elf_specs.h:32
Definition: malloc.c:26

References Elf_, get_targets_map_base_from_sections(), get_targets_map_base_from_segments(), and rz_bin_elf_has_segments().

Referenced by rz_bin_elf_get_targets_map_base().

◆ get_targets_map_base_from_sections()

static ut64 get_targets_map_base_from_sections ( ELFOBJ bin)
static

Definition at line 22 of file elf_map.c.

22  {
23  ut64 result = 0;
24 
27  if (section->rva == UT64_MAX) {
28  continue;
29  }
30  result = RZ_MAX(result, section->rva + section->size);
31  }
32 
33  return result;
34 }
#define rz_bin_elf_foreach_sections(bin, section)
Definition: elf.h:30
#define RZ_MAX(x, y)
#define UT64_MAX
Definition: rz_types_base.h:86
uint32_t size
ut64(WINAPI *w32_GetEnabledXStateFeatures)()

References rz_bin_elf_foreach_sections, RZ_MAX, section::size, ut64(), and UT64_MAX.

Referenced by get_targets_map_base().

◆ get_targets_map_base_from_segments()

static ut64 get_targets_map_base_from_segments ( ELFOBJ bin)
static

Definition at line 7 of file elf_map.c.

7  {
8  ut64 result = 0;
9 
10  RzBinElfSegment *segment;
12  if (segment->data.p_type != PT_LOAD) {
13  continue;
14  }
15 
16  result = RZ_MAX(result, segment->data.p_paddr + segment->data.p_memsz);
17  }
18 
19  return result;
20 }
#define rz_bin_elf_foreach_segments(bin, segment)
Definition: elf.h:26
RzBinElfSegment
Definition: elf.h:131
#define PT_LOAD
Definition: common.h:303

References PT_LOAD, rz_bin_elf_foreach_segments, RZ_MAX, RzBinElfSegment, and ut64().

Referenced by get_targets_map_base().

◆ rz_bin_elf_get_targets_map_base()

ut64 Elf_() rz_bin_elf_get_targets_map_base ( ELFOBJ bin)

Definition at line 44 of file elf_map.c.

44  {
45  ut64 result = get_targets_map_base(bin);
46  result += 0x8; // small additional shift to not overlap with symbols like _end
47  return result + rz_num_align_delta(result, sizeof(Elf_(Addr)));
48 }
static ut64 get_targets_map_base(ELFOBJ *bin)
Definition: elf_map.c:36
static ut64 rz_num_align_delta(ut64 v, ut64 alignment)
Padding to align v to the next alignment-boundary.
Definition: rz_num.h:116

References Elf_, get_targets_map_base(), rz_num_align_delta(), and ut64().

Referenced by init().