Commit graph

15801 commits

Author SHA1 Message Date
Elliott Hughes
2558b11230 Merge "Remove __sinit and __sdidinit." 2015-12-04 23:27:07 +00:00
Tom Cherry
136bf8fa45 Merge "add checks for initialization for system properties" 2015-12-04 23:06:31 +00:00
Tom Cherry
6ed51c0e85 add checks for initialization for system properties
If a __system_property* function is called before
__system_properties_init() then the app will will abort.  This commit
returns either an error code or a safe return value instead.

Bug 26027140

Change-Id: I95ffd143e9563658ab67a397991e84fb4c46ab77
2015-12-04 13:26:47 -08:00
Yabin Cui
2452cf3c33 Merge "Clear pthread_internal_t allocated on user provided stack." 2015-12-04 00:58:05 +00:00
Yabin Cui
304348af19 Clear pthread_internal_t allocated on user provided stack.
Several parts in pthread_internal_t should be initialized
to zero, like tls, key_data and thread_local_dtors. So
just clear the whole pthread_internal_t is more convenient.

Bug: 25990348
Change-Id: Ibb6d1200ea5e6e1afbc77971f179197e8239f6ea
2015-12-03 16:51:20 -08:00
Yabin Cui
514f46b74c Merge "Don't use StringPrintf() in gtest runner." 2015-12-04 00:29:47 +00:00
Yabin Cui
a32fc8685d Don't use StringPrintf() in gtest runner.
Change-Id: I0cd0b3cbb952c65b1c449e88ce12964b93029538
2015-12-03 16:28:03 -08:00
Tom Cherry
b35a2fb370 Merge "Remove c++14'isms from system_properties" 2015-12-03 23:48:54 +00:00
Dimitry Ivanov
bf20d0226b Merge "libm: stop exporting __muldc3" 2015-12-03 23:44:59 +00:00
Tom Cherry
845e24a05e Remove c++14'isms from system_properties
Change-Id: If78e7d2770e8f8321f0d1824c3c52f93820dd325
2015-12-03 15:40:23 -08:00
Dimitry Ivanov
a2ead18657 libm: stop exporting __muldc3
Bug: http://b/26004493
Change-Id: I991268d5e7b59bca646da25d0ad90a1cb4a9d4b9
2015-12-03 15:25:37 -08:00
Tom Cherry
376b94f1e7 Merge "Separate properties by selabel" 2015-12-03 22:55:32 +00:00
Yabin Cui
f57ae1cd43 Merge "Improve unit test runner." 2015-12-03 22:29:29 +00:00
Elliott Hughes
4371961e00 Remove __sinit and __sdidinit.
We're eagerly initializing stdio now, so this can all be simplified.

Change-Id: Icb288f8dd0ee08f02bea0d23670f75e78bed6b99
2015-12-03 13:23:03 -08:00
Yabin Cui
d4c9b9d5ac Improve unit test runner.
1. Read unit test's output while the test is running. Previously
we only read output when the test finishes, which has trouble
when the test outputs too many stuff.
2. Report failed unit test's exit code. It is useful when the
test doesn't fail in ASSERT_xxx, but in somewhere else.

Bug: 25392375
Change-Id: Ie90823337f7c2ee25fa489a5534801d991258f95
2015-12-03 13:20:39 -08:00
Dan Willemsen
22dca83e1c Merge "Re-add putw for LP32" 2015-12-03 01:56:00 +00:00
Dan Willemsen
b9055518fc Re-add putw for LP32
This was missed when switching to LOCAL_SRC_FILES_EXCLUDE

Change-Id: I6ea23c9eb31abe11e0ec4abfc2ee2f2a43c76ce2
2015-12-02 17:31:32 -08:00
Tom Cherry
49a309ff6a Separate properties by selabel
The purpose of this change is to add read access control to the property
space.

In the current design, a process either has access to the single
/dev/__properties__ file and therefore all properties that it contains
or it has access to no properties.  This change separates properties
into multiple property files based on their selabel, which allows
creation of sepolicies that allow read access of only specific sets of
properties to specific domains.

Bug 21852512

Change-Id: Ice265db79201ca811c6b6cf6d851703f53224f03
2015-12-02 15:17:03 -08:00
Dimitry Ivanov
b24f7a0513 Merge "Explicitly disallow default c-tor" 2015-12-02 18:44:20 +00:00
Dimitry Ivanov
a5e183c066 Explicitly disallow default c-tor
Change-Id: Ia52995a459443159e80383d5b396c3edd90a08ae
2015-12-01 16:57:19 -08:00
Chih-hung Hsieh
9cbabd8fe5 Merge "Add bionic-unit-tests-gcc{32,64}, compiled with gcc." 2015-12-01 00:23:32 +00:00
Yabin Cui
6bef152af2 Merge "Init stdio in __libc_init_common." 2015-11-30 23:57:02 +00:00
Yabin Cui
af87c9ccfc Merge "Enable using clang to build __cxa_thread_atexit_impl." 2015-11-30 23:56:41 +00:00
Yabin Cui
9b687dc243 Enable using clang to build __cxa_thread_atexit_impl.
Remove previous workaround as we no longer use
__thread in __cxa_thread_atexit_impl.cpp.

Change-Id: Ic1062995db488859b341acdda0b5f6635e10d7e8
2015-11-30 14:43:52 -08:00
Yabin Cui
28d3f00cf4 Merge "Don't use __thread in __cxa_thread_finalize()." 2015-11-30 21:59:47 +00:00
Yabin Cui
d68c9e5906 Init stdio in __libc_init_common.
Previously we call __sinit() lazily. But it is likely to cause data
races like in https://android-review.googlesource.com/#/c/183237/. So
we prefer to call __sinit() explicitly at libc initialization.

Bug: 25392375

Change-Id: I181ea7a4b2e4c7350b45f2e6c86886ea023e80b8
2015-11-30 13:51:07 -08:00
Yabin Cui
aec13988da Merge "Fix pthread_test according to tsan report." 2015-11-30 21:38:59 +00:00
Chih-hung Hsieh
2bb85c848a Merge "Consider $(use_clang) when building libc_thread_atexit_impl module" 2015-11-30 18:58:59 +00:00
Chih-Hung Hsieh
f688c5d5b4 Add bionic-unit-tests-gcc{32,64}, compiled with gcc.
* bionic-unit-tests{32,64} are compiled with clang/llvm.
* Skip one single test in __cxa_thread_atexit_test.cpp
  when compiled with aarch64 clang/llvm.
  Aarch64 clang/llvm generates relocation references to
  "thread_local" symbols not supported by Android linker.

BUG: 25642296
Change-Id: Ia0497b79c4b335228afeb48a26e0592217909953
2015-11-30 10:52:16 -08:00
Nikola Veljkovic
83f314f060 Consider $(use_clang) when building libc_thread_atexit_impl module
Change-Id: Ia369d94979f418198a2ee891385942d9bc5604d7
2015-11-25 18:09:34 +00:00
Yabin Cui
952e9eb086 Don't use __thread in __cxa_thread_finalize().
Currently we use __thread variable to store thread_local_dtors,
which makes tsan test fork_atexit.cc hang. The problem is as below:
The main thread creates a worker thread, the worker thread calls
pthread_exit() -> __cxa_thread_finalize() -> __emutls_get_address()
-> pthread_once(emutls_init) -> emutls_init().
Then the main thread calls fork(), the child process cals
exit() -> __cxa_thread_finalize() -> __emutls_get_address()
-> pthread_once(emutls_init).
So the child process is waiting for pthread_once(emutls_init)
to finish which will never occur.

It might be the test's fault because POSIX standard says if a
multi-threaded process calls fork(), the new process may only
execute async-signal-safe operations until exec functions are
called. And exit() is not async-signal-safe. But we can make
bionic more reliable by not using __thread in
__cxa_thread_finalize().

Bug: 25392375
Change-Id: Ife403dd7379dad8ddf1859c348c1c0adea07afb3
2015-11-24 17:24:06 -08:00
Colin Cross
a01108d9bf Merge "Remove cflags and ldflags from crt defaults" 2015-11-24 21:33:54 +00:00
Colin Cross
8bd27182c5 Merge "move arch variant structs down a level" 2015-11-24 20:21:20 +00:00
Colin Cross
bff87d19f1 Remove cflags and ldflags from crt defaults
After ToolchainCflags were added to soong crt no longer needs to try to
recreate the bare minimum cflags for compiling for each architecture.
Also always use GCC to match crt.mk

Change-Id: I01a833ab70d989033c84f072e3660d060189688c
2015-11-24 11:11:02 -08:00
Dimitry Ivanov
db8caa740a Merge "Introduce anonymous namespace" 2015-11-24 02:23:34 +00:00
Dmitriy Ivanov
1ffec1cc4d Introduce anonymous namespace
The anonymous namespace is introduced to
handle cases when linker can not find the
caller. This usually happens when caller
code was not loaded by dynamic linker;
for example mono-generated code.

Bug: http://b/25844435
Bug: http://b/22548808
Change-Id: I9e5b1d23c1c75bc78548d68e79216a6a943a33cf
2015-11-23 16:13:10 -08:00
Colin Cross
6ab8f89d1c move arch variant structs down a level
Use blueprint's new anonymous embedded struct feature to move the arch
variant properties down a level, replacing arch.cortex_a9.srcs with
arch.arm.cortex_a9.srcs, while still supporting top-level properties
like arch.arm.srcs.

Change-Id: Ib41c80e3549440d5efdfd293a15cffa3f51a0fe4
2015-11-23 14:14:57 -08:00
Yabin Cui
17554356cc Merge "Change _stdio_handles_locking into _caller_handles_locking." 2015-11-23 18:57:26 +00:00
Dimitry Ivanov
a7fc7f9909 Merge "Handling invalid section headers" 2015-11-23 07:28:32 +00:00
Dmitriy Ivanov
3c5248182e Handling invalid section headers
The linker crashes if native library has invalid section
headers. This change adds boundary checks on target offsets
and generates dlerror instead of crash.

Bug: http://b/25800330
Change-Id: Ibe282029997302b9b557637c3aad064d7d0febc5
2015-11-22 23:25:06 -08:00
Yabin Cui
74ed96d597 Merge "Use FUTEX_WAIT_BITSET to avoid converting timeouts." 2015-11-21 01:50:29 +00:00
Yabin Cui
76144aaa63 Change _stdio_handles_locking into _caller_handles_locking.
It is reported by tsan that funlockfile() can unlock an unlocked mutex.
It happens when printf() is called before fopen() or other stdio stuff.
As FLOCKFILE(fp) is called before __sinit(), _stdio_handles_locking is false,
and _FLOCK(fp) will not be locked. But then cantwrite(fp) in __vfprintf()
calls__sinit(), which makes _stdio_handles_locking become true, and
FUNLOCKFILE(fp) unlocks _FLOCK(fp).

Change _stdio_handles_locking into _caller_handles_locking,
so __sinit() won't change its value. Add test due to my previous fault.

Bug: 25392375
Change-Id: I483e3c3cdb28da65e62f1fd9615bf58c5403b4dd
2015-11-20 17:44:26 -08:00
Dimitry Ivanov
fb3219fbd1 Merge "Move some utility functions to linker_utils" 2015-11-20 21:42:18 +00:00
Dmitriy Ivanov
84bab5a955 Move some utility functions to linker_utils
Also adds unit-tests for page_start, page_offset, and safe_add

Change-Id: Ia1325b4682d367328a01599a19848e4ffcd2c0ea
2015-11-20 21:37:51 +00:00
Dimitry Ivanov
a1ab0d8ed1 Merge "Improve error message for files with no sections" 2015-11-20 19:16:14 +00:00
Dmitriy Ivanov
b76123fed8 Improve error message for files with no sections
Bug: http://b/25801618
Change-Id: I4f4f368e727ff48c84781279e3d17d4ac2d1b6b0
2015-11-20 10:49:12 -08:00
Chih-hung Hsieh
8d5fb0d787 Merge "Disable clang for mips/mips64 libc." 2015-11-20 18:27:14 +00:00
Chih-Hung Hsieh
b4bc156c6c Disable clang for mips/mips64 libc.
* Many processes, including adbd, failed to start in mips/mips64
  emulator when libc.so was compiled by clang.

BUG: 25291096
Change-Id: If3434ebdca4a3a6bf6102b120ee838a7ab66cd74
2015-11-20 09:55:35 -08:00
Elliott Hughes
43c9045017 Merge "mmap: fix calculation of is_private_anonymous variable" 2015-11-20 17:19:19 +00:00
Vitaly Vul
ee67dd75e2 mmap: fix calculation of is_private_anonymous variable
Currently is_private_anonymous is calculated as true if _either_
MAP_PRIVATE or MAP_ANONYMOUS is set, which is a mistake.
According to Documentation/vm/ksm.txt, "KSM only merges anonymous
(private) pages, never pagecache (file) pages". MAP_PRIVATE can
still be set on file cache pages so in order to not redundantly
set MADV_MERGEABLE on pages that are not fitted for it, both
MAP_PRIVATE and MAP_ANONYMOUS should be set.

Along with this fix, add an extra check that the mapped page is
not a stack page before setting MADV_MERGEABLE for it. Stack pages
change too quickly and always end up in KSM 'page_volatile' list.

Change-Id: If4954142852f17cc61f02985ea1cb625a7f3dec6
2015-11-20 09:16:59 -08:00