summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2019-03-03 01:52:05 (GMT)
committermidipix <writeonce@midipix.org>2019-03-03 01:52:05 (GMT)
commita4a68a0965094e460bdadfb216fa500ff16a78a3 (patch)
tree3d42ae72a95d2233d4ca59ac3e19a6870edbab97
parent57b45a46075d70f1fcf82c70782e5a8a3c062489 (diff)
downloadperk-a4a68a0965094e460bdadfb216fa500ff16a78a3.tar.bz2
perk-a4a68a0965094e460bdadfb216fa500ff16a78a3.tar.xz
pe_output_mdso_libraries(): adjust following mdso's pre-alpha abi update.HEADmain
-rw-r--r--src/output/pe_output_mdso_libraries.c42
1 files 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;