Also move this and android_get_device_api_level into <android/api-level.h>
so that they're always available.
This involves cleaning up <sys/cdefs.h> slightly.
Bug: N/A
Test: builds
Change-Id: I25435c55f3549cd0d827a7581bee75ea8228028b
libcrt_builtins does not work with libm, which is statically linked in
bionic-unit-tests-static. Opt it out of libcrt_builtins for now.
Bug: 119207651
Bug: 117167374
Test: run bionic-unit-test-static
Change-Id: I20067c9841beb9de2b73342847aaa945dbadbff8
* HWASan report invalid use of the allocator api (like alignment not
being power of two, or allocation size too large) in a way tests do not
expect.
* Code in .preinit_array runs before HWASan shadow is initialized and
needs to be excluded from instrumentation.
* It looks that mm system calls (mmap/mprotect/etc) will not allow
tagged pointers. In fact, the use of mprotect on malloc()ed memory is
doubtful - one can imagine some kind of speculative load from such
memory, as compiler knows that it is addressable.
Bug: 114279110
Test: bionic-unit-tests with hwasan
Change-Id: I6ba4b46a0d554de77c923ad134cf156ce4ddba1b
According to posix, this test invokes undefined behavior by deleting
a timer twice.
According to hwasan, the second call to timer_delete loads
kernel_timer_id from previously deallocated PosixTimer (i.e.
heap-use-after-free).
Bug: 114279110
Test: bionic-unit-tests with hwasan
Change-Id: Ic54579e3bb41d3f38282b8822dafaba51efd003a
This reverts commit 8e462d411a.
Reason for revert: this lld bug has been fixed upstream and in AOSP prebuilts
Bug: 80109858
Change-Id: Ied600324201e1a014a1d4e6742767e2ddd94999a
This reverts commit da1bc79f93.
Reason for revert: Caused OOM in media process
Bug: 112907825
Bug: 118593766
Change-Id: I545663871d75889b209b9fd2131cdaa97166478f
Use <android-base/macros.h> instead where possible, and move the bionic
macros out of the way of the libbase ones. Yes, there are folks who manage
to end up with both included at once (thanks OpenGL!), and cleaning that
up doesn't seem nearly as practical as just making this change.
Bug: N/A
Test: builds
Change-Id: I23fc544f39d5addf81dc61471771a5438778895b
Some vendors may have been using the AIDs outside the oem ranges
for long that those aids need continue to be maitained for the
existing devices. We allow them countinue to use the old AID names
and values on device launch with P and before, to give them the
period of time to adopt the new AID scheme.
Bug: 116405200
Change-Id: I0453ed14df4c0855575ef1404c596ddc6ded681b
Previously, we were callign tgkill(pid, 0, signal) instead, which would
fail with EINVAL instead.
Test: bionic-unit-tests
Change-Id: I25b127dcf347e0223274502b0516a950b6c2093e
We added a check in P that ensures all vendor provided AIDs only
appear in the carved out ranges for vendors to use. However,
upgrading devices may be using AIDs outside of this range and it is
very difficult to change these AIDs, so we waive this test for them.
Bug: 116830906
Test: test succeeds on upgrading devices
Change-Id: Iddcacb1dce77a150d5138e7b3115abf25bf60a6e
The executable can be inside a zip file using the same syntax used for
shared objects: path.zip!/libentry.so.
The linker currently requires an absolute path. This restriction could be
loosened, but it didn't seem important? If it allowed non-absolute paths,
we'd need to decide how to handle:
- foo/bar (relative to CWD?)
- foo (search PATH / LD_LIBRARY_PATH, or also relative to CWD?)
- foo.zip!/bar (normalize_path() requires an absolute path)
The linker adjusts the argc/argv passed to main() and to constructor
functions to hide the initial linker argument, but doesn't adjust the auxv
vector or files like /proc/self/{exe,cmdline,auxv,stat}. Those files will
report that the kernel loaded the linker as an executable.
I think the linker_logger.cpp change guarding against (g_argv == NULL)
isn't actually necessary, but it seemed like a good idea given that I'm
delaying initialization of g_argv until after C++ constructors have run.
Bug: http://b/112050209
Test: bionic unit tests
Change-Id: I846faf98b16fd34218946f6167e8b451897debe5
Previously, we were zeroing out the reserved signals, when we actually
wanted to have TIMER_SIGNAL always be blocked, and the other signals
always be unblocked. This resulted in process termination when a
SIGEV_THREAD timer callback calls sigprocmask(SIG_SETMASK, ...) with
any signal mask value, and then subsequently fails to complete its
callback and reach the sigtimedwait in bionic before the next timer
iteration triggers.
Add a how argument to filter_reserved_signals to appropriately
block/unblock our reserved signals.
Bug: http://b/116783733
Test: bionic-unit-tests32/64
Change-Id: Ie5339682cdeb914711cd4089cd26ee395704d0df
glibc and musl both have these as synonyms for one another, so we may
as well do the same and get backwards compatibility on old OS releases.
Bug: N/A
Test: ran tests
Change-Id: I6bf38ea446560e1b11022ff539f07eb67c157049
Use a global gtest isolation runner rather than the custom one in
bionic.
Test: Ran all unit tests and verified same behavior before and after.
Change-Id: I24a7cf17cf8e018d0f51969c64b53ce9059cc779
During the review of the script that generates /vendor/etc/passwd, it
was suggested that the shell be /vendor/bin/sh instead of the typical
/system/bin/sh. This has subsequently caused bionic unit tests to
fail, since they always check that the shell is set to /system/bin/sh.
In the spirit of that review, libc is modified to return
/vendor/bin/sh for the OEM AID ranges and the test is updated to
expect this.
Test: bionic unit tests
Change-Id: Ie7c1c48fde8a71b3df1aa0ef112d42ab7bd3baec
Originally a BSD extension, now in glibc too. We've used it internally
for a while.
(cherry-pick of e4b13f7e3ca68edfcc5faedc5e7d4e13c4e8edb9.)
Bug: http://b/112163459
Test: ran tests
Change-Id: I813c3a62b13ddb91ba41e32a5a853d09207ea6bc
Merged-In: I813c3a62b13ddb91ba41e32a5a853d09207ea6bc
Disable -Wmemset-transposed-args to ensure that FORTIFY still works
without it. Also, we can finally enable checking for
FLT_HAS_SUBNORM/DBL_HAS_SUBNORM/LDBL_HAS_SUBNORM now that those are
available in Clang.
Bug: http://b/110779387
Test: build and run bionic unit tests
Change-Id: I4bf19b870c44d981ecbd1089d0ae6a2496be5441
Updates HasMembarrier(cmd) to probe rather than execute command to fix
unintended test skipping.
Test: manual on OrangePi Zero running 4.17.4.
Change-Id: I33a6684a3662cae20cbedc52463b26ef299caf71
Some older kernels do not support all membarrier commands. For example,
the 4.9.x kernel only supports MEMBARRIER_CMD_QUERY and MEMBARRIER_CMD_SHARED.
Test: Ran unit tests on hikey.
Change-Id: I5d4b93df6aa5f443c4700e8f7d33f46953f74e87
There's TLS space used for unknown errno values, and a call to printf
shouldn't clobber that. No-one will ever hit this in real life, but
since it's easily fixed...
Bug: http://b/112776560
Test: ran tests
Change-Id: I8c2437f2e5214e652119791d4e162a197b049d5b
Allows ART JIT use membarrier to invalidate instruction
pipelines.
Bug: 66095511
Test: bionic-unit-tests
Change-Id: I8cf83929f00baf5a3c440a899d2667a992bda8e2
I don't think we want to *document* this, but since at least
external/curl/lib/select.c is relying on this, we should be careful not
to break it.
Bug: http://b/111850071
Test: ran tests
Change-Id: Ic877250d755a0cb59e77ae38ae5e3949f753dad6
Match it against the dl_iterate_phdr list. It should have the same entries,
but they could be in a different order.
Test that the dl_iterate_phdr callback always provides at least a PT_LOAD
segment.
Verify that the executable comes first in the _r_debug list.
Test: bionic-unit-tests
Bug: http://b/110967431
Change-Id: I9b6ec77d1205c4c45848adf65456bb7b3da4a3a1
We've copied & pasted these to too many places. And if we're going to
have another go at upstreaming these, that's probably yet another reason
to have the *values* in just one place. (Even if upstream wants different
names, we'll likely keep the legacy names around for a while for source
compatibility.)
Bug: http://b/111903542
Test: ran tests
Change-Id: I8ccc557453d69530e5b74f865cbe0b458c84e3ba
EXPECT_DEATH requires special handling to work with fdsan, because of
our fork detection. Instead of duplicating the EXPECT_FDSAN_DEATH macro
in the libbase tests as well, move the unique_fd fdsan tests here.
Test: bionic_unit_tests
Change-Id: Ia7b65d4560601d5a78d143aced887a6773b401c0
Add handling for all 4 cases of failure of exchange_owner_tag. Also,
mask off and sign extend the type byte of the owner tag, and add a
test for that.
Test: bionic_unit_tests
Change-Id: Ic7c49f0ee5498623f05c49b5b4cd055db48a4b9f
make checkbuild gives the following error:
bionic/tests/fortify_filecheck_diagnostics_test.cpp:1:0: error: unknown value 'cortex-a55' for -mcpu
The error is because we have a clang to support the new architecture,
but not a corresponding GCC. It is not trivial to filter out an invalid
CPU, and since there is no platform code built with GCC any more, its
better to remove bionic-compile-time-tests-g++
Bug: 74404306
Test: builds
Change-Id: I6aa181c652abeef782fec6380dfadd066140b8b9
This reverts commit 067bdc9546.
The angler/bullhead builds still use GCC, so I'll wait until they're turned down.
Bug: https://issuetracker.google.com/74404306
Change-Id: I777b08dd6ab5250d532b4b5cc56e9a790c13db20
NDK r18 (which removes GCC) is about to ship. We don't need this any more.
The immediate motivation for removing this right now is that the test
fails whenever we add Clang-only flags to the build system.
While we're here, clean up <stdatomic.h> too.
Bug: https://issuetracker.google.com/74404306
Test: ran tests
Change-Id: Iaad5d634d1ba76f0b6f19ad32cc27b2533771a4a
Add two functions to allow objects that own a file descriptor to
enforce that only they can close their file descriptor.
Use them in FILE* and DIR*.
Bug: http://b/110100358
Test: bionic_unit_tests
Test: aosp/master boots without errors
Test: treehugger
Change-Id: Iecd6e8b26c62217271e0822dc3d2d7888b091a45
This along with commit c1ef5eb034 should
get back to the initial behavior prior to the change in commit
83b6379783.
Fixes: 111396376
Test: `adb shell /data/nativetest64/bionic-unit-tests/bionic-unit-tests --gtest_color=yes`
shows colored output.
Test: `adb shell -t /data/nativetest64/bionic-unit-tests/bionic-unit-tests --gtest_color=no`
doesn't add color escapes.
Change-Id: I88530e8b264cd0c259c16b09bdf867cdd2e88224
POSIX says it's unspecified whether setjmp is a macro or a function,
but C11 says it's a macro, and the C standard always wins.
Bug: https://github.com/android-ndk/ndk/issues/744
Test: ran tests
Change-Id: I4a1abc37724f8e9d9498f2093ef3c1f3b8253949
I don't think this will help the original submitter, because <resolv.h>
is mostly useless on Android. One day we might have a deprecation and
removal policy for the NDK, but until then we should probably maintain
this header.
Bug: https://github.com/android-ndk/ndk/issues/739
Test: ran tests
Change-Id: I2db859abfdebc3824c997462fa6133d5b355a8dd
pclose(3) is now an alias for fclose(3). We could add a FORTIFY check
that you use pclose(3) if and only if you used popen(3), but there seems
little value to that when we can just do the right thing.
This patch also adds the missing locking to _fwalk --- we need to lock
both the global list of FILE*s and also each FILE* we touch. POSIX says
that "The popen() function shall ensure that any streams from previous
popen() calls that remain open in the parent process are closed in the
new child process", which we implement via _fwalk(fclose) in the child,
but we might want to just make *all* popen(3) file descriptors O_CLOEXEC
in all cases.
Ignore fewer errors in popen(3) failure cases.
Improve popen(3) test coverage.
Bug: http://b/72470344
Test: ran tests
Change-Id: Ic937594bf28ec88b375f7e5825b9c05f500af438
It is wrong to depend on internal ABI. And in the new version, they
explicitly disabled that.
b3d9be5c1d
Test: run test
Change-Id: I194a1e9417df2c52872b6eca6b61fb392e07cd29
This essentially was phony before, but it wasn't marked as such. Mark it
so that we can turn on some more sanity checks in the build.
Test: Fewer warnings when --warn_real_to_phony is enabled for kati
Change-Id: I5f02b291ca01141dea75977df8b5ef9630917eb2
This check was not necessary since it is perfectly fine for a dso to
have any number of PT_LOAD segments, given that the number is > 0.
Bug: http://b/109747297
Test: make
Change-Id: I0e3b400fddf05ed7b9342bacbfffd3b578f26cf3