From a4a68a0965094e460bdadfb216fa500ff16a78a3 Mon Sep 17 00:00:00 2001 From: midipix Date: Sat, 2 Mar 2019 20:52:05 -0500 Subject: pe_output_mdso_libraries(): adjust following mdso's pre-alpha abi update. --- src/output/pe_output_mdso_libraries.c | 42 ++++++++++++++++++++++------------- 1 file changed, 26 insertions(+), 16 deletions(-) diff --git a/src/output/pe_output_mdso_libraries.c b/src/output/pe_output_mdso_libraries.c index ba72665..9dda96b 100644 --- a/src/output/pe_output_mdso_libraries.c +++ b/src/output/pe_output_mdso_libraries.c @@ -98,26 +98,31 @@ static char * dsolib_name(const struct pe_image_meta * m, int i) static unsigned char * dsosym_meta(const struct pe_image_meta * m, int j) { - uintptr_t va; - uint64_t rva; + uint64_t va; + uint32_t rva; uint32_t roffset; struct mdso_raw_sym_entry_m32 * sym32; struct mdso_raw_sym_entry_m64 * sym64; + int idx; if (m->m_opt.oh_std.coh_magic == PE_MAGIC_PE32_PLUS) { sym64 = (struct mdso_raw_sym_entry_m64 *)m->r_dsosyms + j; va = pe_read_quad(sym64->msym_meta); - rva = va - m->m_opt.oh_mem.coh_image_base; - - if (rva >> 32) - return 0; + rva = pe_read_long(sym64->msym_meta); } else { sym32 = (struct mdso_raw_sym_entry_m32 *)m->r_dsosyms + j; va = pe_read_long(sym32->msym_meta); - rva = va - m->m_opt.oh_mem.coh_image_base; + rva = va; } - if (pe_get_roffset_from_rva(m,(uint32_t)rva,&roffset) < 0) + if ((idx = pe_get_named_section_index(m,MDSO_META_SECTION)) >= 0) + if (idx != pe_get_block_section_index(m,&(struct pe_block){rva,0})) + return (unsigned char *)(-1); + + if (va > rva) + return 0; + + if (pe_get_roffset_from_rva(m,rva,&roffset) < 0) return 0; return (unsigned char *)m->r_image.map_addr + roffset; @@ -125,26 +130,31 @@ static unsigned char * dsosym_meta(const struct pe_image_meta * m, int j) static char * dsosym_string(const struct pe_image_meta * m, int j) { - uintptr_t va; - uint64_t rva; + uint64_t va; + uint32_t rva; uint32_t roffset; struct mdso_raw_sym_entry_m32 * sym32; struct mdso_raw_sym_entry_m64 * sym64; + int idx; if (m->m_opt.oh_std.coh_magic == PE_MAGIC_PE32_PLUS) { sym64 = (struct mdso_raw_sym_entry_m64 *)m->r_dsosyms + j; va = pe_read_quad(sym64->msym_string); - rva = va - m->m_opt.oh_mem.coh_image_base; - - if (rva >> 32) - return 0; + rva = pe_read_long(sym64->msym_string); } else { sym32 = (struct mdso_raw_sym_entry_m32 *)m->r_dsosyms + j; va = pe_read_long(sym32->msym_string); - rva = va - m->m_opt.oh_mem.coh_image_base; + rva = va; } - if (pe_get_roffset_from_rva(m,(uint32_t)rva,&roffset) < 0) + if ((idx = pe_get_named_section_index(m,MDSO_STRS_SECTION)) >= 0) + if (idx != pe_get_block_section_index(m,&(struct pe_block){rva,0})) + return (char *)(-2); + + if (va > rva) + return 0; + + if (pe_get_roffset_from_rva(m,rva,&roffset) < 0) return 0; return m->r_image.map_addr + roffset; -- cgit v1.2.3