Also group all the RELR/arm64/riscv64 bits together rather than mixing them up slightly as we'd done so far.
Change-Id: Iff1ea2cfca9ff702b88aa2e7d09db46e2f34f965
Add basic assembly stubs for TLS Descriptor support in the dynamic
linker, and enable several code paths related to TLSDESC for RISC-V.
Note: This patch requires an updated toolchain that supports TLSDESC
for RISC-V, and the `-mtls-dialect=` compiler option specifically.
Test: adb shell /data/nativetest64/bionic-unit-tests/bionic-unit-tests --gtest_filter=*tls*
Bug: 322984914
Change-Id: I74bd0fa216b44b4ca2c5a5a6aec37b3fc47b00d9
Every time I look at mmap.cpp, I fail to realize it's only built for ILP32.
Also improve some of the commentary in SYSCALLS.TXT and legacy_32_bit_support.cpp.
Change-Id: Ieedfe800b437e30c060c3e8663b6d96d517dbf6f
clang-19 and later default to C++14 sized deallocation. Currently we don't have C23's C equivalent of free_sized(), so we just implement these in terms of free() for now.
Bug: http://b/344993254
Change-Id: I708710aee3f7a684bfe494a96f7baed014acbe57
Not a security problem, but definitely a bug if you're calling this and ignoring the result, since it has no side-effects.
(All of the more important functions -- realloc() especially -- are already annotated.)
Change-Id: I217463518b4716befcc0ed9426648eafbfbbdde4
Kernel headers coming from:
Git: https://android.googlesource.com/kernel/common/
Branch: android-mainline
Tag: android-mainline-6.9
Test: Builds and bionic unit tests pass on raven.
Test: Able to log in to an Android GO 32 bit device.
Change-Id: If53a38bbb65c3c653ce790fe5c6e51597901a14e
This is just POSIX nonsense. Android, iOS/macOS, the BSDs, and glibc all have getpagesize(). Window doesn't, but Windows doesn't have sysconf(3) either, so there's not a strong "portability" argument to be had there!
Change-Id: Ieacfbb61c3612045f27c20c3fa4fa12694db2243
This is fairly conservative, touching only those functions (such as feof()) where it's clearly an error to not use the return value.
Also fix a test that was ignoring the return value of feof() (because it was just checking whether the function could take the lock, and genuinely didn't care about the result).
Change-Id: If2ade10ae87df45a8b9bfcb24828e460201fa9a1
I only came to improve the signature mismatch error, but I was then annoyed by the copy & paste of the other checks.
get_chunk_size() seems to be deliberately avoiding any checks, though I think that might be a bug, and there should be a get_chunk_size() that _does_ check for most callers, and a get_chunk_size_unchecked() for the <sys/thread_properties.h> stuff that seems to want to only be "best effort" (but does still have _some_ possibility of aborting, in addition to the possibility of segfaulting).
Also a bit of "include what you use" after cider complained about all the unused includes in bionic_allocator.h.
Bug: https://issuetracker.google.com/341850283
Change-Id: I278b495601353733af516a2d60ed10feb9cef36b
We only use this in one other place anyway.
Also be explicit about how `__tls_get_addr` and `___tls_get_addr` differ, since I missed that at first!
Change-Id: Ica214886c5346f118f063bca26e6dd8d74ee21f4
Strictly, this is more of "swap one form of duplication for another", but
I found the existing code non-obvious in part because people have added new
code under existing comments (which don't apply), in two places. At this
point, duplicating the _condition_ (which is much less likely to change at
all, let alone grow more complex) clarifies the code and makes the comments
match the code they're adjacent to again.
Test: treehugger
Change-Id: Ic8f01dc5b4fd14e942bf8dd7c72cab7df06d99d5
The maximum page size Android supports
now is 16384, and Art only supports 16kB,
so we can save a bit of space.
Bug: 332556665
Test: N/A
Change-Id: I23df607bcc5cf9e96d7b6a66169413cd1a883f7e
Rather than only updating the maps when a pc can't be found, always update
the maps before using them. This avoids issues where the maps change
and it could cause a crash reading from a map that has been modified.
This assumes that executed code never gets unloaded, or that the
code is unloaded so infrequently that it doesn't matter. This happens
because the pcs for the backtraces are gathered as the program runs
and those pcs are symbolized and made into relative pcs at a later time.
Also, add safe reading of the elf data when necessary to avoid any
crashes if maps are changing while this is running.
Since the MapEntry objects can be deleted, copy the values for
the current map in the backtrace code to detect when in our own code
instead of keeping a pointer.
Bug: 340988785
Test: malloc_debug unit/system tests pass.
Test: libmemunreachable tests pass.
Change-Id: Ica2ba50a5bcf9e19c7e4033e29a5a67a1847d1a6
We do the same thing in pthread_create().
This has the nice side-effect of letting us move part of the child setup that we were doing in the parent into the child where it belongs.
Bug: https://issuetracker.google.com/340125671
Change-Id: Ibe646d5ca9066f487d08fd40f004550349e8a02e
This makes this TraceFunction() more like trace_function() in malloc_debug. I'll leave whether we can collapse these into one implementation as an open question for now...
Change-Id: I3981e4114244d49f8dbae1d3b776a7e9c32be688
I was only here to stop saying "Android R", which doesn't mean much to most app developers, but while I'm here...
Change-Id: I0ffd5d679747491d338064e36efc80b2b82e9e06
We can (and should) use `inline` in C++ but not in C headers that
need to support ANSI/C89/C90. `__inline__` works everywhere, but
traditionally we've used the BSD `__inline` in public headers.
Change-Id: I920e0a1f5fcd01cf8ddd89240ef66b25c50378d7
This reverts commit 58f06e1112.
Bare `inline` is not ANSI C compatible, and NDK users may be using
that.
Test: treehugger
Change-Id: I82c5424522142001cd59da63ef3fd440014451ad