Commit graph

8669 commits

Author SHA1 Message Date
Elliott Hughes
b3639adf9c Merge changes I76dde1e3,I54fec461
* changes:
  Add <sys/random.h>.
  Run other maintenance scripts as part of the preupload hooks.
2017-09-29 15:39:29 +00:00
Elliott Hughes
8465e968a8 Add <sys/random.h>.
iOS 10 has <sys/random.h> with getentropy, glibc >= 2.25 has
<sys/random.h> with getentropy and getrandom. (glibc also pollutes
<unistd.h>, but that seems like a bad idea.)

Also, all supported devices now have kernels with the getrandom system
call.

We've had these available internally for a while, but it seems like the
time is ripe to expose them.

Bug: http://b/67014255
Test: ran tests
Change-Id: I76dde1e3a2d0bc82777eea437ac193f96964f138
2017-09-29 05:31:35 +00:00
Elliott Hughes
9651093569 Run other maintenance scripts as part of the preupload hooks.
And get back up to date by actually running them...

Bug: N/A
Test: uploaded this
Change-Id: I54fec461190e8570929fdcbcbf2746ddd6a4b293
2017-09-28 22:28:23 -07:00
Elliott Hughes
f1c568d1ea Add <glob.h>.
This is the FreeBSD implementation, plus some tests. The FreeBSD
implementation includes the GNU extensions and seems to be what
iOS is using too, which should provide bug compatibility for app
developers.

The code unfortunately uses a lot of stack, and uses FreeBSD locale
implementation that we don't have, but it does seem better maintained
than the other BSDs.

Bug: http://b/29251134
Test: ran tests
Change-Id: Ie477b45e42a6df1319b25712098519d2b33adf67
2017-09-26 18:46:09 -07:00
Elliott Hughes
c51a404b1a All architectures have AT_SYSINFO_EHDR now.
Bug: N/A
Test: builds
Change-Id: Ibc894be98ed0781c8b991ffadff34f616b934aa7
2017-09-22 13:08:50 -07:00
Dan Willemsen
7ccc50d2e4 Use an embedded linker for host bionic
The linux kernel requires that the ELF interpreter (runtime linker)
that's referenced by PT_INTERP be either an absolute path, or a relative
path from the current working directory. We'd prefer a relative path
from the binary, similarly to how we handle looking up shared libraries,
but that's not supported.

Instead, extract the LOAD segments from the runtime linker ELF binary
and embed them into each host bionic binary, omitting the PT_INTERP
declaration. The kernel will treat it as a static binary, and we'll use
a special entry point (linker_wrapper) to fix up the arguments passed by
the kernel before jumping to the embedded linker. From the linker's
point of view, it looks like the kernel loaded the linker like normal.

Bug: 31559095
Test: Enable host bionic, build and run libdemangle_test
Change-Id: I1753401ef91eecbf0ae3376faca31eec1c53842b
2017-09-20 13:59:13 -07:00
Treehugger Robot
e27d29cfaf Merge "Improve pthread_create failure handling." 2017-09-19 23:44:23 +00:00
Elliott Hughes
53dc9dd701 Improve pthread_create failure handling.
Return EAGAIN rather than aborting if we fail to set up the TLS for a new
thread.

Add a test that uses all the VMAs so we can properly test these edge cases.

Add an explicit test for pthread_attr_setdetachstate, which we use in the
previous test, but other than that has no tests.

Remove support for ro.logd.timestamp/persist.logd.timestamp, which doesn't
seem to be used, and which prevents us from logging failures in cases where
mmap fails (because we need to mmap in the system property implementation).

Bug: http://b/65608572
Test: ran tests
Change-Id: I9009f06546e1c2cc55eff996d08b55eff3482343
2017-09-19 14:02:50 -07:00
Elliott Hughes
0d9301e156 Merge "Rename _Exit in a way that works with libandroid_support." 2017-09-19 18:34:52 +00:00
Elliott Hughes
2f94a29d9c Rename _Exit in a way that works with libandroid_support.
Bug: N/A
Test: builds
Change-Id: I2aeaf9bafe7d51e91b67f22d68f4e52191df062b
2017-09-19 18:34:40 +00:00
Treehugger Robot
cce6ada00a Merge "Make <math.h> renames compatible with GCC." 2017-09-19 01:14:29 +00:00
Treehugger Robot
dacbb04cde Merge "Support larger guard regions." 2017-09-19 01:08:25 +00:00
Christopher Ferris
7a5bb687f4 Merge "Drop thread list lock before abort." 2017-09-19 00:15:32 +00:00
Elliott Hughes
d6541c2a97 Make <math.h> renames compatible with GCC.
GCC is fussy about the order in which attributes and renames occur.

Bug: N/A
Test: builds
Change-Id: Icee5ec00aa4626ddad0d89d2d7cee5ec6891c368
2017-09-18 16:22:32 -07:00
Elliott Hughes
d6c678ca90 Support larger guard regions.
This also fixes a long-standing bug where the guard region would be taken
out of the stack itself, rather than being -- as POSIX demands -- additional
space after the stack. Historically a 128KiB stack with a 256KiB guard would
have given you an immediate crash.

Bug: http://b/38413813
Test: builds, boots
Change-Id: Idd12a3899be1d92fea3d3e0fa6882ca2216bd79c
2017-09-18 16:09:43 -07:00
Christopher Ferris
7982914fae Drop thread list lock before abort.
Bug: 65656273

Test: Ran the app and verified it crashes instead of deadlocks.
Change-Id: I7dbe653d50a635a23993c99c5f73ca094ee80b28
2017-09-18 14:40:35 -07:00
Treehugger Robot
0c9ea17e0c Merge "Always log errno when aborting." 2017-09-18 21:33:54 +00:00
Elliott Hughes
7b0af7ad82 Always log errno when aborting.
(Where errno is relevant.)

Also consistently use -1 as the fd for anonymous mmaps. (It doesn't matter,
but it's more common, and potentially more intention-revealing.)

Bug: http://b/65608572
Test: ran tests
Change-Id: Ie9a207632d8242f42086ba3ca862519014c3c102
2017-09-15 16:18:49 -07:00
Elliott Hughes
50cda38f1d Use __RENAME for long double functions.
We can cut a lot of stuff out of the NDK's libandroid_support with this,
and reduce unnecessary relocations for all LP32 code. LP64 code should
be unaffected.

Bug: https://issuetracker.google.com/64450768
Bug: https://github.com/android-ndk/ndk/issues/507
Test: ran tests, plus manual readelf on the _test.o files
Change-Id: I3de6015921195304ea9c829ef31665cd34664066
2017-09-14 16:10:43 -07:00
Treehugger Robot
7e6f98b93d Merge "Remove clang: true" 2017-09-11 21:39:41 +00:00
Elliott Hughes
40756d61ac Merge "Cast __builtin_swap64 to uint64_t." 2017-09-11 20:43:36 +00:00
Elliott Hughes
4c0803d165 Cast __builtin_swap64 to uint64_t.
strace 4.19 causes clang to emit a questionable warning:

  external/strace/nlattr.c:254:35: error: format specifies type 'unsigned long' but the argument has type 'unsigned long long' [-Werror,-Wformat]
                tprintf("htobe64(%" PRIu64 ")", be64toh(num));
                                 ~~~            ^~~~~~~~~~~~
  bionic/libc/include/sys/endian.h💯20: note: expanded from macro 'be64toh'
  #define be64toh(x) htobe64(x)
                     ^~~~~~~~~~
  bionic/libc/include/sys/endian.h:80:17: note: expanded from macro 'htobe64'
  #define htobe64 __swap64
                  ^
  bionic/libc/include/sys/endian.h:48:18: note: expanded from macro '__swap64'
  #define __swap64 __builtin_bswap64
                   ^

What's happened here is:

* be64toh is __builtin_bswap64

* PRIu64 is "lu"

* __builtin_bswap64 is internally declared a "ULLiULLi"

All of which leads to the `unsigned long` != `unsigned long long` complaint.

It seems like __builtin_bswap64 should be ULiULi on 64-bit architectures,
where `long` rather than `long long` is the natural way to refer to 64-bit
types, as evidenced by the "lu" for PRIu64.

As long as clang behaves like this, though, we can work around it with a cast.

Also clean up the other casts in the file, be more consistent about whether
these function-like macros are defined with an argument, and remove an
incorrect comment.

Bug: http://b/65495954
Test: ran tests, built strace 4.19 without warnings
Change-Id: I8e06d4bf71e95d62f556eab8661033e04d487e0d
2017-09-11 13:21:35 -07:00
Lennart Wieboldt
2286b9f5ae Remove clang: true
clang is the default compiler since Android nougat

Test: mma & verified it´s still build with clang
Change-Id: Id8b5361d18c1b2febb2dc6cc44502feaa08f605c
Signed-off-by: Lennart Wieboldt <lennart.1997@gmx.de>
2017-09-11 21:43:58 +02:00
Elliott Hughes
4c9d528a25 Merge "Finish <search.h>." 2017-09-11 18:39:30 +00:00
Jayant Chowdhary
ab2f79c0da For devices which are not treble enabled, return the system shell.
For treble enabled devices, still return the appropriate shell depending
on whether the process is a vendor process or a system one.

Test: Manual testing: on a bullhead device, ran test programs from
      /vendor/bin which used popen() and system(). The calls succeeded.

Bug: 65054230

Bug: 64516799

Merged-In: I15dfdbb107cfca7c0f92f337c9bb46b9876eb38e
Change-Id: I15dfdbb107cfca7c0f92f337c9bb46b9876eb38e
(cherry picked from commit 1e52871773)
2017-09-07 17:19:21 -07:00
Elliott Hughes
04503da174 Merge "<stdbool.h> not necessary in C++." 2017-09-07 23:11:22 +00:00
Elliott Hughes
7379018162 <stdbool.h> not necessary in C++.
Bug: N/A
Test: builds
Change-Id: I40fffe92d4273eab5a98bd65013bb9da2aea2171
2017-09-07 13:28:14 -07:00
Christopher Ferris
5a905961f8 Merge "Provide method to dump backtrace heap data." 2017-09-06 01:37:47 +00:00
Christopher Ferris
602b88ccdd Provide method to dump backtrace heap data.
For non-zygote spawned processes, we might want to dump the backtrace
data. Provide a method to send a signal to a process and then dump the
data to a file.

Adds a method to dump the backtrace data on exit.

Update documentation and explain format of heap dump data.

Test: Ran unit tests, enabled new options and used them.
Change-Id: Ie2fa706694160731afe02c1382b037d06df1d069
2017-09-05 15:57:00 -07:00
Elliott Hughes
5702c6ff45 Finish <search.h>.
I'm unable to find a bug, but we've had requests for this internally
once or twice (though I pointed those folks at the STL), and there's
code we build for the host or in our bootloaders that would use this,
and there's reasonable-looking FreeBSD implementation ready and waiting.

Bug: N/A
Test: ran tests
Change-Id: I6ddee4b71bea4c22ed015debd31d3eaac4fcdd35
2017-08-31 17:38:51 -07:00
Stephen Crane
77bb564dc7 Use env to invoke python
/usr/bin/python may be python3. We should respect PATH to find the python
executable so it can be locally overridden to be python2.

Test: Build libc, repo upload
Change-Id: Iaddd7cd4a1c2177c32786e4fa0fc664ab0ad36de
2017-08-31 15:11:50 -07:00
Treehugger Robot
274e2661a2 Merge "Add new status document, based on internal wiki." 2017-08-30 00:06:04 +00:00
Elliott Hughes
0bfcbaf4d0 Add new status document, based on internal wiki.
Also start breaking up the monolithic top level README.md, pulling the
32-bit ABI stuff out into its own file, and moving the remaining benchmark
documentation in with the rest of the benchmark documentation.

Bug: N/A
Test: N/A
Change-Id: Ic1b9995e27b5044199ed34883cc0b8faa894df0e
2017-08-29 11:07:36 -07:00
Treehugger Robot
0e23c87de5 Merge "Allow io_* syscalls." 2017-08-29 03:28:25 +00:00
Treehugger Robot
8468a1be01 Merge "Pretend the <fts.h> functions didn't appear until 21." 2017-08-26 00:02:50 +00:00
Elliott Hughes
f11aa95ee7 Pretend the <fts.h> functions didn't appear until 21.
Because there was an accidental ABI breakage in 21, and we can't fix
the past. It seems more useful to refuse to build code that won't work
on any current or future device.

Bug: https://issuetracker.google.com/37051826
Test: builds
Change-Id: I4b5c30f899e2c7307642e2fb20e43a3ca14ae7fe
2017-08-25 15:18:33 -07:00
Elliott Hughes
bda6f3b6af Improve names for function arguments in <unistd.h> for Studio.
Spotted while adding syncfs(2). I'd previously seen that this file already
had names, but apparently not inspected them. A couple were missing, a
couple (pipe/pipe2) could usefully have a more specific type, and many
hadruntogethercstylenames.

Bug: http://b/64613623
Test: builds
Change-Id: I6b4a131bf51bf04825317ec481bc55e87c88c2b3
2017-08-25 15:07:05 -07:00
Elliott Hughes
a648733cb7 Implement <iconv.h>.
Bug: http://b/32978596
Test: ran tests
Change-Id: I56b6ae3d9c5a3a56d2b4afba33fb8f9e964bf7b9
2017-08-25 08:47:41 -07:00
Elliott Hughes
44d8f7be1f Fix ndk build.
The NDK gen_stub_libs.py doesn't support introduced=P yet:

  Traceback (most recent call last):
    File "build/soong/cc/gen_stub_libs.py", line 439, in <module>
      main()
    File "build/soong/cc/gen_stub_libs.py", line 429, in main
      versions = SymbolFileParser(symbol_file, api_map).parse()
    File "build/soong/cc/gen_stub_libs.py", line 234, in parse
      versions.append(self.parse_version())
    File "build/soong/cc/gen_stub_libs.py", line 269, in parse_version
      symbols.append(self.parse_symbol())
    File "build/soong/cc/gen_stub_libs.py", line 286, in parse_symbol
      tags = decode_api_level_tags(tags, self.api_map)
    File "build/soong/cc/gen_stub_libs.py", line 76, in decode_api_level_tags
      raise ParseError('Unknown version name in tag: {}'.format(tag))
  __main__.ParseError: Unknown version name in tag: introduced=P

Bug: N/A
Test: builds
Change-Id: Ifd91e525b30f3aa9ad8c889c9564cd769a3a603a
2017-08-25 08:42:48 -07:00
Elliott Hughes
fa3d3291e1 Merge "Add syncfs(2)." 2017-08-25 14:50:58 +00:00
Elliott Hughes
5da4fe4ada Fix overflow in get_phys_pages and get_avphys_pages.
On LP32 mem_unit will be 4096 to allow more than 4GiB in the "ulong"
fields, but we need to promote to a 64-bit type before we multiply.

Bug: N/A
Test: tested manually with an x86 static binary on my 64GiB desktop.
Signed-off-by: YiPing Xu <xuyiping@hisilicon.com>
Change-Id: Id663932503b75793bb7c26a008129f3e2e4cccbf
2017-08-24 16:51:48 -07:00
Elliott Hughes
896362eb0e Add syncfs(2).
GMM calls this system call directly at the moment. That's silly.

Bug: http://b/36405699
Test: ran tests
Change-Id: I1e14c0e5ce0bc2aa888d884845ac30dc20f13cd5
2017-08-24 16:31:49 -07:00
Treehugger Robot
7b4fb64177 Merge "Add more const-correct C++ overloads." 2017-08-24 02:31:35 +00:00
Elliott Hughes
8f0c87e21f Remove dead longjmperror.
This used to be used by the ARM longjmp implementation, but hasn't been in
libc.so for as long as we've used a linker script.

Bug: N/A
Test: builds
Change-Id: I3dff4d154d5e317955c349c9eaa08b982cbf0285
2017-08-23 15:40:03 -07:00
Elliott Hughes
df9a489b2b Add more const-correct C++ overloads.
libc++ actually provides overloads for all the standard C library stuff,
so we just need to handle the POSIX and GNU extensions, of which there
are just two more: memrchr and strcasestr.

Bug: http://b/22768375
Test: builds
Change-Id: Ie9ed1fbcc794e14a0c9bba13b5307ad677949613
2017-08-23 14:34:40 -07:00
Elliott Hughes
3ce774c83b Merge "Add three more functions to the list of POSIX cruft." 2017-08-23 00:29:45 +00:00
Christopher Ferris
1b3fe44e3d Merge "Refactor BufferOutputStream." 2017-08-22 22:50:32 +00:00
Elliott Hughes
abf510a39f Add three more functions to the list of POSIX cruft.
It will never make sense to implement confstr, gethostid, or ulimit.

Bug: N/A
Test: N/A
Change-Id: I9cc18b8a0dbe066f0f76b842c5a5be6b8d5da436
2017-08-22 15:21:39 -07:00
Christopher Ferris
9247640711 Refactor BufferOutputStream.
- Rewrite BufferOutputStream to handle 0 sized buffers and to get rid
  of an unnecessary loop.
- Add tests to verify overflow corner cases.
- Implement async_safe_format_buffer to call async_safe_format_buffer_va_list
  instead of duplicate the code.

Test: Ran new unit tests, booted on angler.
Change-Id: I7fb13e209f5b7443d212f55aab4b05ff2e0e8219
2017-08-22 13:17:28 -07:00
Sandeep Patil
4a3c9751eb Merge "libc: Add support to allow library calls to find appropriate shell executable for a process" 2017-08-22 19:55:41 +00:00