summaryrefslogtreecommitdiffstats
path: root/libthread_db
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2013-10-25 17:38:02 -0700
committerElliott Hughes <enh@google.com>2013-10-28 11:02:49 -0700
commit4eeb1f12a8b63afc0d0ad4d466b16fbffb21cd5a (patch)
tree618c8b7133f3602880e0a4c8285c34e7552a0a45 /libthread_db
parent93fcfeee2b4de4c65fc766bf10601397592341d7 (diff)
downloadbionic-4eeb1f12a8b63afc0d0ad4d466b16fbffb21cd5a.zip
bionic-4eeb1f12a8b63afc0d0ad4d466b16fbffb21cd5a.tar.gz
bionic-4eeb1f12a8b63afc0d0ad4d466b16fbffb21cd5a.tar.bz2
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
Diffstat (limited to 'libthread_db')
-rw-r--r--libthread_db/libthread_db.c42
1 files changed, 18 insertions, 24 deletions
diff --git a/libthread_db/libthread_db.c b/libthread_db/libthread_db.c
index bd78ae6..d899045 100644
--- a/libthread_db/libthread_db.c
+++ b/libthread_db/libthread_db.c
@@ -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