summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2017-12-13 19:40:13 -0500
committermidipix <writeonce@midipix.org>2017-12-14 11:36:09 -0500
commit20e8a3f6e4e37fe028ebc2daefb10bc55eec85d9 (patch)
treebea6fdc5149354436e830c8c89ecdf2e6719ff9f /src
parent2111da6c6b5a906d2e9a821b3d6733684b7378eb (diff)
downloadperk-20e8a3f6e4e37fe028ebc2daefb10bc55eec85d9.tar.bz2
perk-20e8a3f6e4e37fe028ebc2daefb10bc55eec85d9.tar.xz
logic: pe_get_image_meta(): added mdso support.
Diffstat (limited to 'src')
-rw-r--r--src/logic/pe_get_image_meta.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/src/logic/pe_get_image_meta.c b/src/logic/pe_get_image_meta.c
index f995b11..b8bf8a8 100644
--- a/src/logic/pe_get_image_meta.c
+++ b/src/logic/pe_get_image_meta.c
@@ -9,6 +9,9 @@
#include <stdio.h>
#include <string.h>
+#include <mdso/mdso_specs.h>
+#include <mdso/mdso_structs.h>
+
#include <perk/perk.h>
#include "perk_reader_impl.h"
#include "perk_errinfo_impl.h"
@@ -349,6 +352,45 @@ int pe_get_image_meta(
}
}
+ /* .dsometa */
+ if ((i = pe_get_named_section_index(m,MDSO_META_SECTION)) >= 0) {
+ m->h_dsometa = &m->m_sectbl[i];
+ m->r_dsometa = base + m->m_sectbl[i].sh_ptr_to_raw_data;
+
+ m->m_stats.t_ndsolibs = (m->m_opt.oh_std.coh_magic == PE_MAGIC_PE32_PLUS)
+ ? m->h_dsometa->sh_virtual_size / sizeof(struct mdso_raw_meta_record_m64)
+ : m->h_dsometa->sh_virtual_size / sizeof(struct mdso_raw_meta_record_m32);
+ }
+
+ /* .dsosyms */
+ if ((i = pe_get_named_section_index(m,MDSO_SYMS_SECTION)) >= 0) {
+ m->h_dsosyms = &m->m_sectbl[i];
+ m->r_dsosyms = base + m->m_sectbl[i].sh_ptr_to_raw_data;
+
+ m->m_stats.t_ndsosyms = (m->m_opt.oh_std.coh_magic == PE_MAGIC_PE32_PLUS)
+ ? m->h_dsosyms->sh_virtual_size / sizeof(struct mdso_raw_sym_entry_m64)
+ : m->h_dsosyms->sh_virtual_size / sizeof(struct mdso_raw_sym_entry_m32);
+ }
+
+ /* .dsostrs */
+ if ((i = pe_get_named_section_index(m,MDSO_STRS_SECTION)) >= 0) {
+ m->h_dsostrs = &m->m_sectbl[i];
+ m->r_dsostrs = base + m->m_sectbl[i].sh_ptr_to_raw_data;
+ }
+
+ /* .dsodata */
+ if ((i = pe_get_named_section_index(m,MDSO_DATA_SECTION)) >= 0) {
+ m->h_dsodata = &m->m_sectbl[i];
+ m->r_dsodata = base + m->m_sectbl[i].sh_ptr_to_raw_data;
+ }
+
+ /* mdso abi */
+ if (m->h_dsometa || m->h_dsosyms)
+ if (pe_get_image_abi(m,0) == PE_ABI_UNSUPPORTED)
+ return pe_free_image_meta_impl(
+ m,PERK_CUSTOM_ERROR(
+ dctx,PERK_ERR_UNSUPPORTED_ABI));
+
/* image */
m->r_image.map_addr = image->map_addr;
m->r_image.map_size = image->map_size;