am 8f7cdff4: am a7f976c9: update linux/tegrafb.h
* commit '8f7cdff45557c937e6c7a7e010dc961feeb60c16':
update linux/tegrafb.h
diff --git a/libc/Android.mk b/libc/Android.mk
index 647739e..1681306 100644
--- a/libc/Android.mk
+++ b/libc/Android.mk
@@ -361,10 +361,10 @@
arch-arm/bionic/sigsetjmp.S \
arch-arm/bionic/strlen.c.arm \
arch-arm/bionic/strcpy.S \
+ arch-arm/bionic/strcmp.S \
arch-arm/bionic/syscall.S \
string/memmove.c.arm \
string/bcopy.c \
- string/strcmp.c \
string/strncmp.c \
unistd/socketcalls.c
diff --git a/libc/arch-arm/bionic/strcmp.S b/libc/arch-arm/bionic/strcmp.S
new file mode 100644
index 0000000..9fdbd56
--- /dev/null
+++ b/libc/arch-arm/bionic/strcmp.S
@@ -0,0 +1,321 @@
+/*
+ * Copyright (c) 2011 The Android Open Source Project
+ * Copyright (c) 2008 ARM Ltd
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of the company may not be used to endorse or promote
+ * products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY ARM LTD ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL ARM LTD BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <machine/cpu-features.h>
+
+ .text
+
+ .global strcmp
+ .type strcmp, %function
+ .align 4
+
+#ifdef __ARMEB__
+#define SHFT2LSB lsl
+#define SHFT2LSBEQ lsleq
+#define SHFT2MSB lsr
+#define SHFT2MSBEQ lsreq
+#define MSB 0x000000ff
+#define LSB 0xff000000
+#else
+#define SHFT2LSB lsr
+#define SHFT2LSBEQ lsreq
+#define SHFT2MSB lsl
+#define SHFT2MSBEQ lsleq
+#define MSB 0xff000000
+#define LSB 0x000000ff
+#endif
+
+#define magic1(REG) REG
+#define magic2(REG) REG, lsl #7
+
+strcmp:
+ .fnstart
+ PLD(r0, #0)
+ PLD(r1, #0)
+ eor r2, r0, r1
+ tst r2, #3
+
+ /* Strings not at same byte offset from a word boundary. */
+ bne .Lstrcmp_unaligned
+ ands r2, r0, #3
+ bic r0, r0, #3
+ bic r1, r1, #3
+ ldr ip, [r0], #4
+ it eq
+ ldreq r3, [r1], #4
+ beq 1f
+
+ /* Although s1 and s2 have identical initial alignment, they are
+ * not currently word aligned. Rather than comparing bytes,
+ * make sure that any bytes fetched from before the addressed
+ * bytes are forced to 0xff. Then they will always compare
+ * equal.
+ */
+ eor r2, r2, #3
+ lsl r2, r2, #3
+ mvn r3, #MSB
+ SHFT2LSB r2, r3, r2
+ ldr r3, [r1], #4
+ orr ip, ip, r2
+ orr r3, r3, r2
+1:
+ /* Load the 'magic' constant 0x01010101. */
+ str r4, [sp, #-4]!
+ mov r4, #1
+ orr r4, r4, r4, lsl #8
+ orr r4, r4, r4, lsl #16
+ .p2align 2
+4:
+ PLD(r0, #8)
+ PLD(r1, #8)
+ sub r2, ip, magic1(r4)
+ cmp ip, r3
+ itttt eq
+
+ /* check for any zero bytes in first word */
+ biceq r2, r2, ip
+ tsteq r2, magic2(r4)
+ ldreq ip, [r0], #4
+ ldreq r3, [r1], #4
+ beq 4b
+2:
+ /* There's a zero or a different byte in the word */
+ SHFT2MSB r0, ip, #24
+ SHFT2LSB ip, ip, #8
+ cmp r0, #1
+ it cs
+ cmpcs r0, r3, SHFT2MSB #24
+ it eq
+ SHFT2LSBEQ r3, r3, #8
+ beq 2b
+ /* On a big-endian machine, r0 contains the desired byte in bits
+ * 0-7; on a little-endian machine they are in bits 24-31. In
+ * both cases the other bits in r0 are all zero. For r3 the
+ * interesting byte is at the other end of the word, but the
+ * other bits are not necessarily zero. We need a signed result
+ * representing the differnece in the unsigned bytes, so for the
+ * little-endian case we can't just shift the interesting bits up.
+ */
+#ifdef __ARMEB__
+ sub r0, r0, r3, lsr #24
+#else
+ and r3, r3, #255
+ /* No RSB instruction in Thumb2 */
+#ifdef __thumb2__
+ lsr r0, r0, #24
+ sub r0, r0, r3
+#else
+ rsb r0, r3, r0, lsr #24
+#endif
+#endif
+ ldr r4, [sp], #4
+ bx lr
+ .fnend
+
+.Lstrcmp_unaligned:
+ wp1 .req r0
+ wp2 .req r1
+ b1 .req r2
+ w1 .req r4
+ w2 .req r5
+ t1 .req ip
+ @ r3 is scratch
+
+ /* First of all, compare bytes until wp1(sp1) is word-aligned. */
+1:
+ tst wp1, #3
+ beq 2f
+ ldrb r2, [wp1], #1
+ ldrb r3, [wp2], #1
+ cmp r2, #1
+ it cs
+ cmpcs r2, r3
+ beq 1b
+ sub r0, r2, r3
+ bx lr
+
+2:
+ str r5, [sp, #-4]!
+ str r4, [sp, #-4]!
+ mov b1, #1
+ orr b1, b1, b1, lsl #8
+ orr b1, b1, b1, lsl #16
+
+ and t1, wp2, #3
+ bic wp2, wp2, #3
+ ldr w1, [wp1], #4
+ ldr w2, [wp2], #4
+ cmp t1, #2
+ beq 2f
+ bhi 3f
+
+ /* Critical inner Loop: Block with 3 bytes initial overlap */
+ .p2align 2
+1:
+ bic t1, w1, #MSB
+ cmp t1, w2, SHFT2LSB #8
+ sub r3, w1, b1
+ bic r3, r3, w1
+ bne 4f
+ ands r3, r3, b1, lsl #7
+ it eq
+ ldreq w2, [wp2], #4
+ bne 5f
+ eor t1, t1, w1
+ cmp t1, w2, SHFT2MSB #24
+ bne 6f
+ ldr w1, [wp1], #4
+ b 1b
+4:
+ SHFT2LSB w2, w2, #8
+ b 8f
+
+5:
+#ifdef __ARMEB__
+ /* The syndrome value may contain false ones if the string ends
+ * with the bytes 0x01 0x00
+ */
+ tst w1, #0xff000000
+ itt ne
+ tstne w1, #0x00ff0000
+ tstne w1, #0x0000ff00
+ beq 7f
+#else
+ bics r3, r3, #0xff000000
+ bne 7f
+#endif
+ ldrb w2, [wp2]
+ SHFT2LSB t1, w1, #24
+#ifdef __ARMEB__
+ lsl w2, w2, #24
+#endif
+ b 8f
+
+6:
+ SHFT2LSB t1, w1, #24
+ and w2, w2, #LSB
+ b 8f
+
+ /* Critical inner Loop: Block with 2 bytes initial overlap */
+ .p2align 2
+2:
+ SHFT2MSB t1, w1, #16
+ sub r3, w1, b1
+ SHFT2LSB t1, t1, #16
+ bic r3, r3, w1
+ cmp t1, w2, SHFT2LSB #16
+ bne 4f
+ ands r3, r3, b1, lsl #7
+ it eq
+ ldreq w2, [wp2], #4
+ bne 5f
+ eor t1, t1, w1
+ cmp t1, w2, SHFT2MSB #16
+ bne 6f
+ ldr w1, [wp1], #4
+ b 2b
+
+5:
+#ifdef __ARMEB__
+ /* The syndrome value may contain false ones if the string ends
+ * with the bytes 0x01 0x00
+ */
+ tst w1, #0xff000000
+ it ne
+ tstne w1, #0x00ff0000
+ beq 7f
+#else
+ lsls r3, r3, #16
+ bne 7f
+#endif
+ ldrh w2, [wp2]
+ SHFT2LSB t1, w1, #16
+#ifdef __ARMEB__
+ lsl w2, w2, #16
+#endif
+ b 8f
+
+6:
+ SHFT2MSB w2, w2, #16
+ SHFT2LSB t1, w1, #16
+4:
+ SHFT2LSB w2, w2, #16
+ b 8f
+
+ /* Critical inner Loop: Block with 1 byte initial overlap */
+ .p2align 2
+3:
+ and t1, w1, #LSB
+ cmp t1, w2, SHFT2LSB #24
+ sub r3, w1, b1
+ bic r3, r3, w1
+ bne 4f
+ ands r3, r3, b1, lsl #7
+ it eq
+ ldreq w2, [wp2], #4
+ bne 5f
+ eor t1, t1, w1
+ cmp t1, w2, SHFT2MSB #8
+ bne 6f
+ ldr w1, [wp1], #4
+ b 3b
+4:
+ SHFT2LSB w2, w2, #24
+ b 8f
+5:
+ /* The syndrome value may contain false ones if the string ends
+ * with the bytes 0x01 0x00
+ */
+ tst w1, #LSB
+ beq 7f
+ ldr w2, [wp2], #4
+6:
+ SHFT2LSB t1, w1, #8
+ bic w2, w2, #MSB
+ b 8f
+7:
+ mov r0, #0
+ ldr r4, [sp], #4
+ ldr r5, [sp], #4
+ bx lr
+
+8:
+ and r2, t1, #LSB
+ and r0, w2, #LSB
+ cmp r0, #1
+ it cs
+ cmpcs r0, r2
+ itt eq
+ SHFT2LSBEQ t1, t1, #8
+ SHFT2LSBEQ w2, w2, #8
+ beq 8b
+ sub r0, r2, r0
+ ldr r4, [sp], #4
+ ldr r5, [sp], #4
+ bx lr
diff --git a/libc/arch-x86/bionic/syscall.S b/libc/arch-x86/bionic/syscall.S
index 71abe6b..3cca85c 100644
--- a/libc/arch-x86/bionic/syscall.S
+++ b/libc/arch-x86/bionic/syscall.S
@@ -20,18 +20,15 @@
.align 4
syscall:
- push %eax
push %ebx
- push %ecx
- push %edx
push %esi
push %edi
- mov 28(%esp),%eax
- mov 32(%esp),%ebx
- mov 36(%esp),%ecx
- mov 40(%esp),%edx
- mov 44(%esp),%esi
- mov 48(%esp),%edi
+ mov 16(%esp),%eax
+ mov 20(%esp),%ebx
+ mov 24(%esp),%ecx
+ mov 28(%esp),%edx
+ mov 32(%esp),%esi
+ mov 36(%esp),%edi
int $0x80
@@ -45,8 +42,5 @@
1:
pop %edi
pop %esi
- pop %edx
- pop %ecx
pop %ebx
- pop %eax
ret
diff --git a/libc/bionic/malloc_debug_common.c b/libc/bionic/malloc_debug_common.c
index ebf0006..b9fcbc4 100644
--- a/libc/bionic/malloc_debug_common.c
+++ b/libc/bionic/malloc_debug_common.c
@@ -84,7 +84,6 @@
//
// This is used for sorting, not determination of equality, so we don't
// need to compare the bit flags.
- int result;
if (alloc1 > alloc2) {
result = -1;
} else if (alloc1 < alloc2) {
diff --git a/libc/bionic/pthread.c b/libc/bionic/pthread.c
index 34909fb..0a0854d 100644
--- a/libc/bionic/pthread.c
+++ b/libc/bionic/pthread.c
@@ -68,7 +68,13 @@
#define __likely(cond) __builtin_expect(!!(cond), 1)
#define __unlikely(cond) __builtin_expect(!!(cond), 0)
-void _thread_created_hook(pid_t thread_id) __attribute__((noinline));
+#ifdef __i386__
+#define ATTRIBUTES __attribute__((noinline)) __attribute__((fastcall))
+#else
+#define ATTRIBUTES __attribute__((noinline))
+#endif
+
+void ATTRIBUTES _thread_created_hook(pid_t thread_id);
#define PTHREAD_ATTR_FLAG_DETACHED 0x00000001
#define PTHREAD_ATTR_FLAG_USER_STACK 0x00000002
diff --git a/libc/bionic/ptrace.c b/libc/bionic/ptrace.c
index b1ca00c..463c068 100644
--- a/libc/bionic/ptrace.c
+++ b/libc/bionic/ptrace.c
@@ -57,7 +57,12 @@
/*
* Hook for gdb to get notified when a thread is created
*/
-void _thread_created_hook(pid_t thread_id) __attribute__((noinline));
-void _thread_created_hook(pid_t thread_id)
+#ifdef __i386__
+#define ATTRIBUTES __attribute__((noinline)) __attribute__((fastcall))
+#else
+#define ATTRIBUTES __attribute__((noinline))
+#endif
+
+void ATTRIBUTES _thread_created_hook(pid_t thread_id)
{
}
diff --git a/libc/include/sys/cdefs.h b/libc/include/sys/cdefs.h
index 9b6da31..92035d4 100644
--- a/libc/include/sys/cdefs.h
+++ b/libc/include/sys/cdefs.h
@@ -79,7 +79,7 @@
#define ___STRING(x) __STRING(x)
#define ___CONCAT(x,y) __CONCAT(x,y)
-#if __STDC__ || defined(__cplusplus)
+#if defined(__STDC__) || defined(__cplusplus)
#define __P(protos) protos /* full-blown ANSI C */
#define __CONCAT(x,y) x ## y
#define __STRING(x) #x
@@ -213,7 +213,7 @@
* C99 defines the restrict type qualifier keyword, which was made available
* in GCC 2.92.
*/
-#if __STDC_VERSION__ >= 199901L
+#if defined(__STDC__VERSION__) && __STDC_VERSION__ >= 199901L
#define __restrict restrict
#else
#if !__GNUC_PREREQ__(2, 92)
@@ -225,7 +225,7 @@
* C99 defines __func__ predefined identifier, which was made available
* in GCC 2.95.
*/
-#if !(__STDC_VERSION__ >= 199901L)
+#if !defined(__STDC_VERSION__) || !(__STDC_VERSION__ >= 199901L)
#if __GNUC_PREREQ__(2, 6)
#define __func__ __PRETTY_FUNCTION__
#elif __GNUC_PREREQ__(2, 4)
diff --git a/libc/netbsd/resolv/res_cache.c b/libc/netbsd/resolv/res_cache.c
index f0c51ab..e6302ed 100644
--- a/libc/netbsd/resolv/res_cache.c
+++ b/libc/netbsd/resolv/res_cache.c
@@ -34,6 +34,7 @@
#include <errno.h>
#include "arpa_nameser.h"
+#include <sys/system_properties.h>
/* This code implements a small and *simple* DNS resolver cache.
*
@@ -106,7 +107,7 @@
*/
#define CONFIG_SECONDS (60*10) /* 10 minutes */
-/* maximum number of entries kept in the cache. This value has been
+/* default number of entries kept in the cache. This value has been
* determined by browsing through various sites and counting the number
* of corresponding requests. Keep in mind that our framework is currently
* performing two requests per name lookup (one for IPv4, the other for IPv6)
@@ -125,10 +126,16 @@
* most high-level websites use lots of media/ad servers with different names
* but these are generally reused when browsing through the site.
*
- * As such, a valud of 64 should be relatively conformtable at the moment.
+ * As such, a value of 64 should be relatively comfortable at the moment.
+ *
+ * The system property ro.net.dns_cache_size can be used to override the default
+ * value with a custom value
*/
#define CONFIG_MAX_ENTRIES 64
+/* name of the system property that can be used to set the cache size */
+#define DNS_CACHE_SIZE_PROP_NAME "ro.net.dns_cache_size"
+
/****************************************************************************/
/****************************************************************************/
/***** *****/
@@ -1147,15 +1154,15 @@
* for simplicity, the hash-table fields 'hash' and 'hlink' are
* inlined in the Entry structure.
*/
-#define MAX_HASH_ENTRIES (2*CONFIG_MAX_ENTRIES)
typedef struct resolv_cache {
+ int max_entries;
int num_entries;
Entry mru_list;
pthread_mutex_t lock;
unsigned generation;
int last_id;
- Entry* entries[ MAX_HASH_ENTRIES ];
+ Entry* entries;
} Cache;
@@ -1167,9 +1174,9 @@
int nn;
time_t now = _time_now();
- for (nn = 0; nn < MAX_HASH_ENTRIES; nn++)
+ for (nn = 0; nn < cache->max_entries; nn++)
{
- Entry** pnode = &cache->entries[nn];
+ Entry** pnode = (Entry**) &cache->entries[nn];
while (*pnode != NULL) {
Entry* node = *pnode;
@@ -1187,6 +1194,30 @@
"*************************");
}
+/* Return max number of entries allowed in the cache,
+ * i.e. cache size. The cache size is either defined
+ * by system property ro.net.dns_cache_size or by
+ * CONFIG_MAX_ENTRIES if system property not set
+ * or set to invalid value. */
+static int
+_res_cache_get_max_entries( void )
+{
+ int result = -1;
+ char cache_size[PROP_VALUE_MAX];
+
+ if (__system_property_get(DNS_CACHE_SIZE_PROP_NAME, cache_size) > 0) {
+ result = atoi(cache_size);
+ }
+
+ // ro.net.dns_cache_size not set or set to negative value
+ if (result <= 0) {
+ result = CONFIG_MAX_ENTRIES;
+ }
+
+ XLOG("cache size: %d", result);
+ return result;
+}
+
static struct resolv_cache*
_resolv_cache_create( void )
{
@@ -1194,10 +1225,17 @@
cache = calloc(sizeof(*cache), 1);
if (cache) {
- cache->generation = ~0U;
- pthread_mutex_init( &cache->lock, NULL );
- cache->mru_list.mru_prev = cache->mru_list.mru_next = &cache->mru_list;
- XLOG("%s: cache created\n", __FUNCTION__);
+ cache->max_entries = _res_cache_get_max_entries();
+ cache->entries = calloc(sizeof(*cache->entries), cache->max_entries);
+ if (cache->entries) {
+ cache->generation = ~0U;
+ pthread_mutex_init( &cache->lock, NULL );
+ cache->mru_list.mru_prev = cache->mru_list.mru_next = &cache->mru_list;
+ XLOG("%s: cache created\n", __FUNCTION__);
+ } else {
+ free(cache);
+ cache = NULL;
+ }
}
return cache;
}
@@ -1288,8 +1326,8 @@
_cache_lookup_p( Cache* cache,
Entry* key )
{
- int index = key->hash % MAX_HASH_ENTRIES;
- Entry** pnode = &cache->entries[ key->hash % MAX_HASH_ENTRIES ];
+ int index = key->hash % cache->max_entries;
+ Entry** pnode = (Entry**) &cache->entries[ index ];
while (*pnode != NULL) {
Entry* node = *pnode;
@@ -1470,7 +1508,7 @@
goto Exit;
}
- if (cache->num_entries >= CONFIG_MAX_ENTRIES) {
+ if (cache->num_entries >= cache->max_entries) {
_cache_remove_oldest(cache);
/* need to lookup again */
lookup = _cache_lookup_p(cache, key);
diff --git a/libc/stdio/vfscanf.c b/libc/stdio/vfscanf.c
index b16e3c7..78f404e 100644
--- a/libc/stdio/vfscanf.c
+++ b/libc/stdio/vfscanf.c
@@ -162,7 +162,13 @@
flags |= MAXINT;
goto again;
case 'L':
- flags |= LONGDBL;
+ flags |=
+ (*fmt == 'd') ? LLONG :
+ (*fmt == 'i') ? LLONG :
+ (*fmt == 'o') ? LLONG :
+ (*fmt == 'u') ? LLONG :
+ (*fmt == 'x') ? LLONG :
+ LONGDBL;
goto again;
case 'h':
if (*fmt == 'h') {
diff --git a/libc/unistd/sigblock.c b/libc/unistd/sigblock.c
index 863d7da..176bc13 100644
--- a/libc/unistd/sigblock.c
+++ b/libc/unistd/sigblock.c
@@ -37,6 +37,7 @@
sigset_t the_sigset;
} in, out;
+ sigemptyset(&in.the_sigset);
in.the_mask = mask;
n = sigprocmask(SIG_BLOCK, &in.the_sigset, &out.the_sigset);
diff --git a/libc/unistd/sigsetmask.c b/libc/unistd/sigsetmask.c
index 4f46458..7842bf1 100644
--- a/libc/unistd/sigsetmask.c
+++ b/libc/unistd/sigsetmask.c
@@ -38,6 +38,7 @@
sigset_t the_sigset;
} in, out;
+ sigemptyset(&in.the_sigset);
in.the_mask = mask;
n = sigprocmask(SIG_SETMASK, &in.the_sigset, &out.the_sigset);
diff --git a/libthread_db/Android.mk b/libthread_db/Android.mk
index 922b9cf..af506ed 100644
--- a/libthread_db/Android.mk
+++ b/libthread_db/Android.mk
@@ -22,12 +22,7 @@
LOCAL_WHOLE_STATIC_LIBRARIES := libthread_db
LOCAL_MODULE:=libthread_db
LOCAL_SHARED_LIBRARIES := libdl libc
-
-# NOTE: Using --no-undefined results in a missing symbol that is defined inside
-# gdbserver and is resolved at runtime. Since there is no library containing
-# this symbol that we can link against, set LOCAL_ALLOW_UNDEFINED_SYMBOLS so
-# that --no-undefined is removed from the linker flags.
-LOCAL_ALLOW_UNDEFINED_SYMBOLS := true
+LOCAL_ALLOW_UNDEFINED_SYMBOLS := false
LOCAL_SYSTEM_SHARED_LIBRARIES :=
include $(BUILD_SHARED_LIBRARY)
diff --git a/libthread_db/include/thread_db.h b/libthread_db/include/thread_db.h
index 6ff968f..1ed8ffca 100644
--- a/libthread_db/include/thread_db.h
+++ b/libthread_db/include/thread_db.h
@@ -149,6 +149,10 @@
extern td_err_e td_ta_thr_iter(td_thragent_t const * agent, td_thr_iter_f * func, void * cookie,
td_thr_state_e state, int32_t prio, sigset_t * sigmask, uint32_t user_flags);
+extern td_err_e td_thr_event_enable(td_thrhandle_t const * handle, td_event_e event);
+
+extern td_err_e td_thr_get_info(td_thrhandle_t const * handle, td_thrinfo_t * info);
+
extern char const ** td_symbol_list(void);
extern td_err_e td_thr_tls_get_addr(const td_thrhandle_t * th,
diff --git a/libthread_db/libthread_db.c b/libthread_db/libthread_db.c
index 2cf4d38..86e1cf4 100644
--- a/libthread_db/libthread_db.c
+++ b/libthread_db/libthread_db.c
@@ -81,6 +81,25 @@
{
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;
+ }
+#else
pc = (void *)ptrace(PTRACE_PEEKUSR, handle->tid, (void *)60 /* r15/pc */, NULL);
if (pc == bkpt_addr) {
@@ -90,6 +109,7 @@
gEventMsgHandle.tid = gEventMsgHandle.pid;
return 0x42;
}
+#endif
return 0;
}
@@ -156,7 +176,7 @@
{
int32_t err;
- /*
+ /*
* This is nasty, ps_pglobal_lookup is implemented in gdbserver and looks up
* the symbol from it's cache, which is populated at start time with the
* symbols returned from td_symbol_list via calls back to the host.
diff --git a/linker/linker.c b/linker/linker.c
index 5a9dccf..e350d89 100644
--- a/linker/linker.c
+++ b/linker/linker.c
@@ -822,7 +822,7 @@
static int reserve_mem_region(soinfo *si)
{
void *base = mmap((void *)si->base, si->size, PROT_READ | PROT_EXEC,
- MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
+ MAP_FIXED | MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
if (base == MAP_FAILED) {
DL_ERR("%5d can NOT map (%sprelinked) library '%s' at 0x%08x "
"as requested, will try general pool: %d (%s)",