Clean up linker architecture macros.
We don't need our own architecture macros; the standard ones will do. This patch also fixes some __x86_64__ tests to be USE_RELA tests instead, because they're not actually x86_64-specific. I've cleaned up architecture-specific code slightly so where possible all the code corresponding to a particular architecture is together. This patch also fixes a bug in LP64 DT_PLTGOT handling, which should be an error rather than falling through into DT_DEBUG! There was another #ifdef bug where we'd only report unexpected DT_ entries on MIPS. Change-Id: Id1d04e372611f641c1aa278a18e379f28af9eaf5
This commit is contained in:
@@ -79,29 +79,8 @@ static td_thrhandle_t gEventMsgHandle;
|
||||
static int
|
||||
_event_getmsg_helper(td_thrhandle_t const * handle, void * bkpt_addr)
|
||||
{
|
||||
void * pc;
|
||||
|
||||
#ifdef __i386__
|
||||
/* Get the eip from offset 12*4 = 48 as defined in the struct
|
||||
* user_regs_struct in user_32.h
|
||||
*/
|
||||
pc = (void *)ptrace(PTRACE_PEEKUSR, handle->tid, (void *)48 /* eip */, NULL);
|
||||
/* FIXME - pc is a non-decremented breakpoint address, hence the
|
||||
* addition of 1 on test. This seems to work for the thread hook
|
||||
* function in libc.so but should be properly fixed.
|
||||
*/
|
||||
if (pc == ((int)bkpt_addr + 1)) {
|
||||
/* The hook function takes the id of the new thread as it's first
|
||||
* param, so grab it from ecx at offset 4 in struct user_regs_struct
|
||||
* (using fastcall convention for x86)
|
||||
*/
|
||||
gEventMsgHandle.pid = ptrace(PTRACE_PEEKUSR, handle->tid, (void *)4 /* ecx */, NULL);
|
||||
gEventMsgHandle.tid = gEventMsgHandle.pid;
|
||||
return 0x42;
|
||||
}
|
||||
#elif defined(__arm__)
|
||||
pc = (void *)ptrace(PTRACE_PEEKUSR, handle->tid, (void *)60 /* r15/pc */, NULL);
|
||||
|
||||
#if defined(__arm__)
|
||||
void* pc = (void *)ptrace(PTRACE_PEEKUSR, handle->tid, (void *)60 /* r15/pc */, NULL);
|
||||
if (pc == bkpt_addr) {
|
||||
// The hook function takes the id of the new thread as it's first param,
|
||||
// so grab it from r0.
|
||||
@@ -109,8 +88,23 @@ _event_getmsg_helper(td_thrhandle_t const * handle, void * bkpt_addr)
|
||||
gEventMsgHandle.tid = gEventMsgHandle.pid;
|
||||
return 0x42;
|
||||
}
|
||||
#elif defined(__i386__)
|
||||
// Get the eip from offset 12*4 = 48 as defined in the struct
|
||||
// user_regs_struct in user_32.h
|
||||
void* pc = (void *)ptrace(PTRACE_PEEKUSR, handle->tid, (void *)48 /* eip */, NULL);
|
||||
// FIXME - pc is a non-decremented breakpoint address, hence the
|
||||
// addition of 1 on test. This seems to work for the thread hook
|
||||
// function in libc.so but should be properly fixed.
|
||||
if (pc == ((int)bkpt_addr + 1)) {
|
||||
// The hook function takes the id of the new thread as it's first
|
||||
// param, so grab it from ecx at offset 4 in struct user_regs_struct
|
||||
// (using fastcall convention for x86)
|
||||
gEventMsgHandle.pid = ptrace(PTRACE_PEEKUSR, handle->tid, (void *)4 /* ecx */, NULL);
|
||||
gEventMsgHandle.tid = gEventMsgHandle.pid;
|
||||
return 0x42;
|
||||
}
|
||||
#elif defined(__mips__)
|
||||
pc = (void *)ptrace(PTRACE_PEEKUSR, handle->tid, (void *)(64*4) /* pc */, NULL);
|
||||
void* pc = (void *)ptrace(PTRACE_PEEKUSR, handle->tid, (void *)(64*4) /* pc */, NULL);
|
||||
if (pc == bkpt_addr) {
|
||||
// The hook function takes the id of the new thread as it's first param,
|
||||
// so grab it from a0
|
||||
|
||||
Reference in New Issue
Block a user