1
1

Merge pull request #1560 from hjelmn/new_hooks_update

Patcher hooks bug fixes
Этот коммит содержится в:
Nathan Hjelm 2016-04-19 11:39:30 -06:00
родитель 178c97b406 d981a9fc7d
Коммит b3abd5380b
3 изменённых файлов: 26 добавлений и 10 удалений

Просмотреть файл

@ -31,11 +31,21 @@ AC_DEFUN([MCA_opal_patcher_linux_CONFIG],[
OPAL_VAR_SCOPE_PUSH([opal_patcher_linux_CPPFLAGS_save])
opal_patcher_linux_happy=no
if test $OPAL_ENABLE_DLOPEN_SUPPORT = 1; then
OPAL_CHECK_PACKAGE([patcher_linux], [dlfcn.h], [dl], [dl_iterate_phdr], [], [], [],
[opal_patcher_linux_happy=yes],[])
AC_CHECK_HEADERS([elf.h],[],[opal_patcher_linux_happy=no])
AC_CHECK_HEADERS([sys/auxv.h])
if test $OPAL_ENABLE_DLOPEN_SUPPORT = 1 ; then
# Only enable on Linux for now. In the future this component might
# be modified to work on FreeBSD.
case $host in
*-linux*)
opal_patcher_linux_happy=yes;
;;
esac
if test $opal_patcher_linux_happy = yes ; then
OPAL_CHECK_PACKAGE([patcher_linux], [dlfcn.h], [dl], [dl_iterate_phdr], [], [], [],
[],[opal_patcher_linux_happy=no])
AC_CHECK_HEADERS([elf.h],[],[opal_patcher_linux_happy=no])
AC_CHECK_HEADERS([sys/auxv.h])
fi
fi
AS_IF([test $opal_patcher_linux_happy = yes], [$1], [$2])

Просмотреть файл

@ -90,8 +90,13 @@ mca_patcher_linux_get_phdr_dynamic(const ElfW(Phdr) *phdr, uint16_t phnum, int p
return NULL;
}
#if SIZEOF_VOID_P == 8
static const ElfW(Dyn)*
mca_patcher_linux_get_dynentry(ElfW(Addr) base, const ElfW(Phdr) *pdyn, uint32_t type)
mca_patcher_linux_get_dynentry(ElfW(Addr) base, const ElfW(Phdr) *pdyn, int64_t type)
#else
static const ElfW(Dyn)*
mca_patcher_linux_get_dynentry(ElfW(Addr) base, const ElfW(Phdr) *pdyn, int32_t type)
#endif
{
for (ElfW(Dyn) *dyn = (ElfW(Dyn)*)(base + pdyn->p_vaddr); dyn->d_tag; ++dyn) {
if (dyn->d_tag == type) {
@ -196,7 +201,7 @@ static int mca_patcher_linux_get_aux_phent (void)
nread = read(fd, buffer, sizeof(buffer));
if (nread < 0) {
opal_output_verbose (MCA_BASE_VERBOSE_ERROR, opal_patcher_base_framework.framework_output,
"failed to read %lu bytes from %s (ret=%ld): %s", sizeof (buffer),
"failed to read %" PRIsize_t " bytes from %s (ret=%ld): %s", sizeof (buffer),
proc_auxv_filename, nread, strerror (errno));
break;
}
@ -319,7 +324,8 @@ static int mca_patcher_linux_apply_patch (mca_patcher_linux_patch_t *patch)
(void)dl_iterate_phdr(mca_patcher_linux_phdr_iterator, &ctx);
if (ctx.status == OPAL_SUCCESS) {
opal_output_verbose (MCA_BASE_VERBOSE_INFO, opal_patcher_base_framework.framework_output,
"modified '%s' to 0x%lx", ctx.patch->super.patch_symbol, ctx.patch->super.patch_value);
"modified '%s' to %" PRIxPTR , ctx.patch->super.patch_symbol,
ctx.patch->super.patch_value);
}
return ctx.status;

Просмотреть файл

@ -90,7 +90,7 @@ static int mca_patcher_overwrite_apply_patch (mca_patcher_base_patch_t *patch)
#if defined(__i386__)
patch->patch_data_size = 5;
*(unsigned char *)(patch->patch_data+0) = 0xe9;
*(unsigned int *) (patch->patch_data+1) = (unsigned int)(func_new_addr - func_old_addr - 5);
*(unsigned int *) (patch->patch_data+1) = (unsigned int)(func_new_addr - patch->patch_orig - 5);
#elif defined(__x86_64__)
patch->patch_data_size = 13;
*(unsigned short*)(patch->patch_data + 0) = 0xbb49;
@ -237,7 +237,7 @@ static int mca_patcher_overwrite_apply_patch (mca_patcher_base_patch_t *patch)
#endif
static int mca_patcher_overwrite_patch_address (uintptr_t sys_addr, unsigned long hook_addr)
static int mca_patcher_overwrite_patch_address (uintptr_t sys_addr, uintptr_t hook_addr)
{
mca_patcher_base_patch_t *patch;
int rc;