From 62c289e44b3394c67cb748b439a8aff242e0e390 Mon Sep 17 00:00:00 2001 From: Stefano Moioli Date: Sat, 6 Apr 2024 01:35:57 +0200 Subject: [PATCH] add resolve_libc_imports --- xzre.h | 15 +++++++++++++++ xzre.lds | 3 +++ 2 files changed, 18 insertions(+) diff --git a/xzre.h b/xzre.h index cb2b56c..cb508ce 100644 --- a/xzre.h +++ b/xzre.h @@ -23,6 +23,7 @@ typedef uintptr_t uptr; #include #include #include +#include #define UPTR(x) ((uptr)(x)) #define PTRADD(a, b) (UPTR(a) + UPTR(b)) @@ -877,5 +878,19 @@ extern BOOL secret_data_append_singleton( */ extern BOOL backdoor_setup(backdoor_setup_params_t *params); +/** + * @brief parses the libc ELF from the supplied link map, and resolves its imports + * + * @param libc the loaded libc's link map (obtained by traversing r_debug->r_map) + * @param libc_info pointer to an ELF context that will be populated with the parsed ELF information + * @param imports pointer to libc imports that will be populated with resolved libc function pointers + * @return BOOL TRUE if successful, FALSE otherwise + */ +extern BOOL resolve_libc_imports( + struct link_map *libc, + elf_info_t *libc_info, + libc_imports_t *imports +); + #include "util.h" #endif \ No newline at end of file diff --git a/xzre.lds b/xzre.lds index c5c8394..a9fc61f 100644 --- a/xzre.lds +++ b/xzre.lds @@ -65,5 +65,8 @@ SECTIONS { "backdoor_setup" = "."; *(.text.microlzma_encoder_inia); + + "resolve_libc_imports" = "."; + *(.text.lzma_index_buffer_encoda); } } INSERT AFTER .text;