Rizin
unix-like reverse engineering framework and cli tools
elf_map.c
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: 2021 08A <08A@riseup.net>
2 // SPDX-FileCopyrightText: 2021 RizinOrg <info@rizin.re>
3 // SPDX-License-Identifier: LGPL-3.0-only
4 
5 #include "elf.h"
6 
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 }
21 
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 }
35 
39  }
40 
42 }
43 
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 }
#define rz_bin_elf_foreach_segments(bin, segment)
Definition: elf.h:26
#define rz_bin_elf_foreach_sections(bin, section)
Definition: elf.h:30
RzBinElfSegment
Definition: elf.h:131
#define ELFOBJ
Definition: elf.h:24
bool Elf_() rz_bin_elf_has_segments(RZ_NONNULL ELFOBJ *bin)
Definition: elf_segments.c:149
ut64 Elf_() rz_bin_elf_get_targets_map_base(ELFOBJ *bin)
Definition: elf_map.c:44
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
static ut64 get_targets_map_base(ELFOBJ *bin)
Definition: elf_map.c:36
#define Elf_(name)
Definition: elf_specs.h:32
#define PT_LOAD
Definition: common.h:303
static ut64 rz_num_align_delta(ut64 v, ut64 alignment)
Padding to align v to the next alignment-boundary.
Definition: rz_num.h:116
#define RZ_MAX(x, y)
#define UT64_MAX
Definition: rz_types_base.h:86
Definition: malloc.c:26
uint32_t size
ut64(WINAPI *w32_GetEnabledXStateFeatures)()