Rizin
unix-like reverse engineering framework and cli tools
elf_corefile.c
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: 2021 08A <08A@riseup.net>
2 // SPDX-FileCopyrightText: 2008-2020 nibble <nibble.ds@gmail.com>
3 // SPDX-FileCopyrightText: 2008-2020 pancake <pancake@nopcode.org>
4 // SPDX-FileCopyrightText: 2008-2020 alvaro_fe <alvaro.felipe91@gmail.com>
5 // SPDX-License-Identifier: LGPL-3.0-only
6 
7 #include "elf.h"
8 
18 
20  if (!layout) {
21  return UT64_MAX;
22  }
23 
24  RzVector *notes;
27  rz_vector_foreach(notes, tmp) {
28  if (tmp->type != NT_PRSTATUS) {
29  continue;
30  }
31 
32  RzBinElfNotePrStatus *note = &tmp->prstatus;
33  if (layout->sp_offset + layout->sp_size / 8 > note->regstate_size) {
34  return UT64_MAX;
35  }
36 
37  return rz_read_ble(note->regstate + layout->sp_offset, bin->big_endian, layout->sp_size);
38  }
39  }
40 
41  return UT64_MAX;
42 }
#define ELFOBJ
Definition: elf.h:24
#define rz_bin_elf_foreach_notes_segment(bin, notes)
Definition: elf.h:42
RzBinElfNote
Definition: elf.h:182
RZ_BORROW RzBinElfPrStatusLayout *Elf_() rz_bin_elf_get_prstatus_layout(RZ_NONNULL ELFOBJ *bin)
Definition: elf_notes.c:201
ut64 Elf_() rz_bin_elf_get_sp_val(RZ_NONNULL ELFOBJ *bin)
Get the stack pointer value.
Definition: elf_corefile.c:16
#define Elf_(name)
Definition: elf_specs.h:32
#define NT_PRSTATUS
Definition: common.h:393
#define rz_return_val_if_fail(expr, val)
Definition: rz_assert.h:108
static ut64 rz_read_ble(const void *src, bool big_endian, int size)
Definition: rz_endian.h:517
#define RZ_NONNULL
Definition: rz_types.h:64
#define UT64_MAX
Definition: rz_types_base.h:86
#define rz_vector_foreach(vec, it)
Definition: rz_vector.h:169
Definition: malloc.c:26
Information about the binary layout in a NT_PRSTATUS note for core files of a certain architecture an...
Definition: elf.h:82
ut64 sp_offset
Definition: elf.h:108
ut8 sp_size
Size of the stack pointer register in bits.
Definition: elf.h:97
Parsed PT_NOTE of type NT_PRSTATUS.
Definition: elf.h:168
ut64(WINAPI *w32_GetEnabledXStateFeatures)()