diff options
author | android-build-team Robot <android-build-team-robot@google.com> | 2019-04-24 03:09:43 +0000 |
---|---|---|
committer | android-build-team Robot <android-build-team-robot@google.com> | 2019-04-24 03:09:43 +0000 |
commit | 18de7810d66fcc557c4f0e7e98f70e6b22d4ea8f (patch) | |
tree | aa5d90a5c88b3f2f82e2f8a670125cee86e160a4 | |
parent | 9044a3abd32250a5f959f94999a1e6a8c6116d0d (diff) | |
parent | 53080db75a550f6b513b11e84881f592b128a1f5 (diff) | |
download | bionic-18de7810d66fcc557c4f0e7e98f70e6b22d4ea8f.tar.gz |
Snap for 5499134 from 53080db75a550f6b513b11e84881f592b128a1f5 to qt-release
Change-Id: If1153dac5bf9b154ea1ed966d427b2654e6c8451
-rw-r--r-- | libc/Android.bp | 7 | ||||
-rw-r--r-- | libc/arch-arm/dynamic_function_dispatch.cpp | 12 | ||||
-rw-r--r-- | libc/arch-arm/dynamic_function_wrapper.S | 37 | ||||
-rw-r--r-- | libc/bionic/pthread_mutex.cpp | 2 | ||||
-rw-r--r-- | linker/linker.cpp | 10 | ||||
-rw-r--r-- | tests/dlext_test.cpp | 20 | ||||
-rw-r--r-- | tests/pthread_test.cpp | 18 |
7 files changed, 53 insertions, 53 deletions
diff --git a/libc/Android.bp b/libc/Android.bp index 23ccbe3e9..32e756043 100644 --- a/libc/Android.bp +++ b/libc/Android.bp @@ -1435,12 +1435,7 @@ cc_library_static { srcs: ["arch-x86/dynamic_function_dispatch.cpp"], }, arm: { - srcs: [ - "arch-arm/dynamic_function_dispatch.cpp", - - // Workaround for b/120254692. - "arch-arm/dynamic_function_wrapper.S", - ], + srcs: ["arch-arm/dynamic_function_dispatch.cpp"], }, }, diff --git a/libc/arch-arm/dynamic_function_dispatch.cpp b/libc/arch-arm/dynamic_function_dispatch.cpp index 09fd8f30e..640f3306a 100644 --- a/libc/arch-arm/dynamic_function_dispatch.cpp +++ b/libc/arch-arm/dynamic_function_dispatch.cpp @@ -89,15 +89,11 @@ static int ifunc_close(int fd) { return r0; } -#define DEFINE_IFUNC_WITH_SUFFIX(name, suffix) \ - name##_func name##suffix __attribute__((ifunc(#name "_resolver"))); \ +#define DEFINE_IFUNC(name) \ + name##_func name __attribute__((ifunc(#name "_resolver"))); \ __attribute__((visibility("hidden"))) \ name##_func* name##_resolver() -#define DEFINE_IFUNC(name) DEFINE_IFUNC_WITH_SUFFIX(name, ) - -#define DEFINE_INTERNAL_IFUNC(name) DEFINE_IFUNC_WITH_SUFFIX(name, _internal) - #define DECLARE_FUNC(type, name) \ __attribute__((visibility("hidden"))) \ type name @@ -291,7 +287,7 @@ DEFINE_IFUNC(__strcat_chk) { } typedef int strcmp_func(const char* __lhs, const char* __rhs); -DEFINE_INTERNAL_IFUNC(strcmp) { +DEFINE_IFUNC(strcmp) { switch(get_cpu_variant()) { case kCortexA9: RETURN_FUNC(strcmp_func, strcmp_a9); @@ -305,7 +301,7 @@ DEFINE_INTERNAL_IFUNC(strcmp) { } typedef size_t strlen_func(const char* __s); -DEFINE_INTERNAL_IFUNC(strlen) { +DEFINE_IFUNC(strlen) { switch(get_cpu_variant()) { case kCortexA9: RETURN_FUNC(strlen_func, strlen_a9); diff --git a/libc/arch-arm/dynamic_function_wrapper.S b/libc/arch-arm/dynamic_function_wrapper.S deleted file mode 100644 index 1d2842b5c..000000000 --- a/libc/arch-arm/dynamic_function_wrapper.S +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (C) 2018 The Android Open Source Project - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * 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. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "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 THE - * COPYRIGHT OWNER OR CONTRIBUTORS 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 <private/bionic_asm.h> - -#define FUNCTION_DELEGATE(name, impl) \ -ENTRY(name); \ - b impl; \ -END(name) - -FUNCTION_DELEGATE(strcmp, strcmp_internal) -FUNCTION_DELEGATE(strlen, strlen_internal) diff --git a/libc/bionic/pthread_mutex.cpp b/libc/bionic/pthread_mutex.cpp index d9ddf1058..f92184e50 100644 --- a/libc/bionic/pthread_mutex.cpp +++ b/libc/bionic/pthread_mutex.cpp @@ -199,6 +199,8 @@ static int PIMutexUnlock(PIMutex& mutex) { memory_order_relaxed))) { return 0; } + } else { + old_owner = atomic_load_explicit(&mutex.owner_tid, memory_order_relaxed); } if (tid != (old_owner & FUTEX_TID_MASK)) { diff --git a/linker/linker.cpp b/linker/linker.cpp index d62eaec39..b59df7302 100644 --- a/linker/linker.cpp +++ b/linker/linker.cpp @@ -1865,11 +1865,17 @@ bool find_libraries(android_namespace_t* ns, soinfo_list_t global_group = local_group_ns->get_global_group(); bool linked = local_group.visit([&](soinfo* si) { - // Even though local group may contain accessible soinfos from other namesapces + // Even though local group may contain accessible soinfos from other namespaces // we should avoid linking them (because if they are not linked -> they // are in the local_group_roots and will be linked later). if (!si->is_linked() && si->get_primary_namespace() == local_group_ns) { - if (!si->link_image(global_group, local_group, extinfo, &relro_fd_offset) || + const android_dlextinfo* link_extinfo = nullptr; + if (si == soinfos[0] || reserved_address_recursive) { + // Only forward extinfo for the first library unless the recursive + // flag is set. + link_extinfo = extinfo; + } + if (!si->link_image(global_group, local_group, link_extinfo, &relro_fd_offset) || !get_cfi_shadow()->AfterLoad(si, solist_get_head())) { return false; } diff --git a/tests/dlext_test.cpp b/tests/dlext_test.cpp index 3af52d47c..eed84a4c1 100644 --- a/tests/dlext_test.cpp +++ b/tests/dlext_test.cpp @@ -538,6 +538,26 @@ TEST_F(DlExtRelroSharingTest, ChildWritesGoodDataRecursive) { tf.fd = extinfo_.relro_fd; } +TEST_F(DlExtRelroSharingTest, CheckRelroSizes) { + TemporaryFile tf1, tf2; + ASSERT_NOERROR(close(tf1.fd)); + ASSERT_NOERROR(close(tf2.fd)); + + ASSERT_NO_FATAL_FAILURE(CreateRelroFile(kLibNameRecursive, tf1.path, false)); + struct stat no_recursive; + ASSERT_NOERROR(fstat(extinfo_.relro_fd, &no_recursive)); + tf1.fd = extinfo_.relro_fd; + + ASSERT_NO_FATAL_FAILURE(CreateRelroFile(kLibNameRecursive, tf2.path, true)); + struct stat with_recursive; + ASSERT_NOERROR(fstat(extinfo_.relro_fd, &with_recursive)); + tf2.fd = extinfo_.relro_fd; + + // RELRO file should end up bigger when we use the recursive flag, since it + // includes data for more than one library. + ASSERT_GT(with_recursive.st_size, no_recursive.st_size); +} + TEST_F(DlExtRelroSharingTest, ChildWritesNoRelro) { TemporaryFile tf; // // Use tf to get an unique filename. ASSERT_NOERROR(close(tf.fd)); diff --git a/tests/pthread_test.cpp b/tests/pthread_test.cpp index 7b64401db..0bf8e294b 100644 --- a/tests/pthread_test.cpp +++ b/tests/pthread_test.cpp @@ -1843,10 +1843,25 @@ struct PthreadMutex { DISALLOW_COPY_AND_ASSIGN(PthreadMutex); }; +static int UnlockFromAnotherThread(pthread_mutex_t* mutex) { + pthread_t thread; + pthread_create(&thread, nullptr, [](void* mutex_voidp) -> void* { + pthread_mutex_t* mutex = static_cast<pthread_mutex_t*>(mutex_voidp); + intptr_t result = pthread_mutex_unlock(mutex); + return reinterpret_cast<void*>(result); + }, mutex); + void* result; + EXPECT_EQ(0, pthread_join(thread, &result)); + return reinterpret_cast<intptr_t>(result); +}; + static void TestPthreadMutexLockNormal(int protocol) { PthreadMutex m(PTHREAD_MUTEX_NORMAL, protocol); ASSERT_EQ(0, pthread_mutex_lock(&m.lock)); + if (protocol == PTHREAD_PRIO_INHERIT) { + ASSERT_EQ(EPERM, UnlockFromAnotherThread(&m.lock)); + } ASSERT_EQ(0, pthread_mutex_unlock(&m.lock)); ASSERT_EQ(0, pthread_mutex_trylock(&m.lock)); ASSERT_EQ(EBUSY, pthread_mutex_trylock(&m.lock)); @@ -1857,6 +1872,7 @@ static void TestPthreadMutexLockErrorCheck(int protocol) { PthreadMutex m(PTHREAD_MUTEX_ERRORCHECK, protocol); ASSERT_EQ(0, pthread_mutex_lock(&m.lock)); + ASSERT_EQ(EPERM, UnlockFromAnotherThread(&m.lock)); ASSERT_EQ(EDEADLK, pthread_mutex_lock(&m.lock)); ASSERT_EQ(0, pthread_mutex_unlock(&m.lock)); ASSERT_EQ(0, pthread_mutex_trylock(&m.lock)); @@ -1873,7 +1889,9 @@ static void TestPthreadMutexLockRecursive(int protocol) { PthreadMutex m(PTHREAD_MUTEX_RECURSIVE, protocol); ASSERT_EQ(0, pthread_mutex_lock(&m.lock)); + ASSERT_EQ(EPERM, UnlockFromAnotherThread(&m.lock)); ASSERT_EQ(0, pthread_mutex_lock(&m.lock)); + ASSERT_EQ(EPERM, UnlockFromAnotherThread(&m.lock)); ASSERT_EQ(0, pthread_mutex_unlock(&m.lock)); ASSERT_EQ(0, pthread_mutex_unlock(&m.lock)); ASSERT_EQ(0, pthread_mutex_trylock(&m.lock)); |