Skip to content

Commit

Permalink
xzre_code: add update_cpuid_got_index
Browse files Browse the repository at this point in the history
  • Loading branch information
smx-smx committed Aug 3, 2024
1 parent bef711d commit c025508
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 4 deletions.
4 changes: 2 additions & 2 deletions xzre.h
Original file line number Diff line number Diff line change
Expand Up @@ -2860,7 +2860,7 @@ extern void * backdoor_init(elf_entry_ctx_t *state, u64 *caller_frame);
* stores the address of the symbol cpuid_random_symbol in elf_entry_ctx_t::symbol_ptr
* stores the return address of the function that called the IFUNC resolver which is a stack address in ld.so
* calls update_got_offset() to update elf_entry_ctx_t::got_offset
* calls get_cpuid_got_index() to update @ref elf_entry_ctx_t.got_ctx.cpuid_fn
* calls update_cpuid_got_index() to update @ref elf_entry_ctx_t.got_ctx.cpuid_fn
*
* @param ctx
*/
Expand All @@ -2885,7 +2885,7 @@ extern void update_got_offset(elf_entry_ctx_t *ctx);
* @param ctx
* @return u64 cpuid() GOT index
*/
extern u64 get_cpuid_got_index(elf_entry_ctx_t *ctx);
extern void update_cpuid_got_index(elf_entry_ctx_t *ctx);

/**
* @brief
Expand Down
2 changes: 1 addition & 1 deletion xzre.lds.in
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ SECTIONS_BEGIN()
/* 0000000000003CD0 */ DEFSYM(main_elf_parse, .text.lzma_filter_decoder_is_supportea)
/* 0000000000003D40 */ DEFSYM(sshd_get_sensitive_data_score, .text.lzma_lzma2_encoder_memusaga)
/* 0000000000003DA0 */ DEFSYM(sshd_find_monitor_struct, .text.lzma_mf_bt4_fina)
/* 0000000000003F50 */ DEFSYM(get_cpuid_got_index, .text.lzma_stream_decoder_inia)
/* 0000000000003F50 */ DEFSYM(update_cpuid_got_index, .text.lzma_stream_decoder_inia)
/* 0000000000003F70 */ DEFSYM(get_tls_get_addr_random_symbol_got_offset, .text.lzma_stream_flags_compara)
/* 0000000000003F90 */ DEFSYM(update_got_address, .text.lzma_stream_header_encoda)
/* 0000000000004000 */ DEFSYM(update_got_offset, .text.parse_delt1)
Expand Down
1 change: 1 addition & 0 deletions xzre_code/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ add_library(xzre_code
sha256.c
sshd_patch_variables.c
update_got_offset.c
update_cpuid_got_index.c
)
target_compile_options(xzre_code PRIVATE
-Os -fomit-frame-pointer
Expand Down
2 changes: 1 addition & 1 deletion xzre_code/init_elf_entry_ctx.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ void init_elf_entry_ctx(elf_entry_ctx_t *ctx){
ctx->symbol_ptr = (void *)&cpuid_random_symbol;
ctx->got_ctx.return_address = (void *)ctx->frame_address[3];
update_got_offset(ctx);
get_cpuid_got_index(ctx);
update_cpuid_got_index(ctx);
ctx->got_ctx.got_ptr = NULL;
}
8 changes: 8 additions & 0 deletions xzre_code/update_cpuid_got_index.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/**
* Copyright (C) 2024 Stefano Moioli <[email protected]>
**/
#include "xzre.h"

void update_cpuid_got_index(elf_entry_ctx_t *ctx){
ctx->got_ctx.cpuid_fn = (void *)cpuid_reloc_consts.cpuid_got_index;
}

0 comments on commit c025508

Please sign in to comment.