Commit graph

42 commits

Author SHA1 Message Date
Elliott Hughes
41ef902379 Fix memchr overflow.
The overflow's actually in the generic C implementation of memchr.

While I'm here, let's switch our generic memrchr to the OpenBSD version too.

Bug: https://code.google.com/p/android/issues/detail?id=147048
Change-Id: I296ae06a1ee196d2c77c95a22f11ee4d658962da
2015-02-14 13:21:22 -08:00
Colin Cross
1742a32aea Share LP32 makefile settings between arches
Add <var>_32 to patch-up-arch-specific-flags, and move the LP32
cruft varaibles from the 32-bit arch specific makefiles into the
top level Android.mk.

Change-Id: Id3fcf6805d4af048c2524c94b1295416ebe7d057
2015-02-04 17:35:49 -08:00
Elliott Hughes
e6099098a5 Fix mips build.
Move various mips-only things into the arch-mips directory. As soon as mips
writes assembler replacements, we can remove these.

Change-Id: Ia7308559bc361f5c8df3e1d456b381865e060b93
2015-01-27 11:09:27 -08:00
Elliott Hughes
76f8916b90 Clean up <stdlib.h> slightly.
Interestingly, this mostly involves cleaning up our implementation of
various <string.h> functions.

Change-Id: Ifaef49b5cb997134f7bc0cc31bdac844bdb9e089
2015-01-26 14:28:41 -08:00
Elliott Hughes
d27ae2f8d7 Merge mips setjmp/longjmp family.
Bug: 16918359
Change-Id: I9033a7d178d431ddb09f1cfa6e4bf95ae02346e9
2014-12-08 17:07:53 -08:00
Elliott Hughes
7c02d9428c Clean up the architecture-specific makefiles.
Group things appropriately and name each group.

Change-Id: I0da45eb0ccde19c31d5e984d0e6eb3dad26630dc
2014-09-16 19:06:31 -07:00
Elliott Hughes
57b7a6110e Fix pthread_getattr_np for the main thread.
On most architectures the kernel subtracts a random offset to the stack
pointer in create_elf_tables by calling arch_align_stack before writing
the auxval table and so on. On all but x86 this doesn't cause a problem
because the random offset is less than a page, but on x86 it's up to two
pages. This means that our old technique of rounding the stack pointer
doesn't work. (Our old implementation of that technique was wrong too.)

It's also incorrect to assume that the main thread's stack base and size
are constant. Likewise to assume that the main thread has a guard page.
The main thread is not like other threads.

This patch switches to reading /proc/self/maps (and checking RLIMIT_STACK)
whenever we're asked.

Bug: 17111575
Signed-off-by: Fengwei Yin <fengwei.yin@intel.com>
Change-Id: I1d4dbffe7bc7bda1d353c3a295dbf68d29f63158
2014-08-26 10:36:38 -07:00
Dan Albert
6a918870ba Revert "Replaces vfork() implementation with fork()"
We're getting cold feet on this one... let's put it back.

This reverts commit 210331d976.

Change-Id: I6b0d3c2b1dbf7f1dc9566979a91b7504c2189269
2014-08-05 14:11:38 -07:00
Elliott Hughes
c7706a02ad Merge "[MIPSR6] Use C-coded string ops on mips32r6/mips64r6" 2014-07-29 21:36:05 +00:00
Duane Sand
bc5a3ec6df [MIPSR6] Use C-coded string ops on mips32r6/mips64r6
The existing assembler code uses deprecated lwl/lwr/swl/swr ops.
Replacing those with misalignment-forgiving lw/sw ops may
involve careful performance tuning.

Change-Id: I47a042f7b22b87d7d52e46c29c44b1db1ba8b693
2014-07-23 14:00:21 -07:00
Duane Sand
ba23bd0a40 [MIPS] Drop soft-fp targets
Change-Id: I583bf8242d3034ebfc48548499cdb3316094c8e3
2014-07-24 18:04:21 +00:00
Duane Sand
f541650828 [MIPS] Allow united mipsel and mips64el gcc toolchain
Explicitly tell 32-bit links that they are doing 32-bit links.
This is needed when using united 32-bit and 64-bit toolchains.
This is harmless when using older separate 32-only toolchains.

Change-Id: I70cbd3f5867e59b1f6f829793444242fb0894aa6
2014-07-22 14:27:48 -07:00
Dan Albert
c82c0b7e07 Remove SHA1 from LP64 in favor of libcrypto.
Keep the symbols around on LP32 for binary compatibility.

Bug: 11156955
Change-Id: I379a7e0fa3092e9a70daeafcbcb2aacfc314031a
2014-06-16 16:52:27 -07:00
David 'Digit' Turner
891dedb935 libc: Fix 'index' symbol export.
The C library didn't export the 'index' symbol, but its C++ name-mangling
instead, which broke the ABI and prevented some applications from loading
properly.

The main reason was that the implementation under bionic/index.cpp relied
on the declaration to specify that the function has C linkage.

However, the declaration for index() was removed from both <string.h>
and <strings.h> in a recent patch, which made the compiler think it was
ok to compile the function with C++ linkage instead!

This patch does the following:

- Move index() definition to bionic/ndk_cruft.cpp and ensure it uses
  C linkage.

  Note that this removes index() from the 64-bit library entirely, this
  is intentional and will break source compatibility. Simply replacing
  an index() call with the equivalent strchr() should be enough to fix
  this in third-party code.

- Remove bionic/index.cpp from the tree and build files.

- Remove x86 assembly implementation from arch-x86/ to avoid conflict
  with the one in ndk_cruft.cpp

BUG=15606653

Change-Id: I816b589f69c8f8a6511f6be6195d20cf1c4e8123
2014-06-16 13:10:20 -07:00
Elliott Hughes
24614b4729 Remove __memcmp16 from bionic.
Change-Id: I2486d667d96c8900dd368d855f37c1327161efb7
2014-06-12 15:35:22 -07:00
Dan Albert
8e613cf342 Remove declaration for putw(3)/getw(3).
These were both removed from POSIX 2004, and we don't define an
implementation for getw(3). Keep the definition of put(3) on LP32 for
binary compatibility.

Bug: 13935372
Change-Id: Iba384b45093ac6d2d7c2d81f7980cd7701dd6f56
2014-06-11 14:41:45 -07:00
Dan Albert
210331d976 Replaces vfork() implementation with fork()
vfork() was removed from POSIX 2008, so this replaces its implementation
with a call to fork().

Bug: 13935372
Change-Id: I6d99ac9e52a2efc5ee9bda1cab908774b830cedc
2014-06-10 21:38:52 -07:00
Elliott Hughes
fae42a837a Merge "Revert "Revert "Lose the hand-written futex assembler.""" 2014-05-29 03:13:23 +00:00
Elliott Hughes
b30aff405a Revert "Revert "Lose the hand-written futex assembler.""
The problem with the original patch was that using syscall(3) means that
errno can be set, but pthread_create(3) was abusing the TLS errno slot as
a pthread_mutex_t for the thread startup handshake.

There was also a mistake in the check for syscall failures --- it should
have checked against -1 instead of 0 (not just because that's the default
idiom, but also here because futex(2) can legitimately return values > 0).

This patch stops abusing the TLS errno slot and adds a pthread_mutex_t to
pthread_internal_t instead. (Note that for LP64 sizeof(pthread_mutex_t) >
sizeof(uintptr_t), so we could potentially clobber other TLS slots too.)

I've also rewritten the LP32 compatibility stubs to directly reuse the
code from the .h file.

This reverts commit 75c55ff84e.

Bug: 15195455
Change-Id: I6ffb13e5cf6a35d8f59f692d94192aae9ab4593d
2014-05-28 18:31:15 -07:00
Christopher Ferris
8a405b027a Merge "Add optimized AArch64 versions of bcopy and wmemmove based on memmove" 2014-05-28 21:35:04 +00:00
Narayan Kamath
75c55ff84e Revert "Lose the hand-written futex assembler."
This reverts commit ced906c849.

Causes issues on art / dalvik due to a broken return value
check and other undiagnosed issues.

bug: 15195455

Change-Id: I5d6bbb389ecefb0e33a5237421a9d56d32a9317c
2014-05-28 18:03:01 +00:00
Bernhard Rosenkraenzer
6f2bde3441 Add optimized AArch64 versions of bcopy and wmemmove based on memmove
Add optimized versions of bcopy and wmemmove for AArch64 based on the
memmove implementation

Change-Id: I82fbe8a7221ce224c567ffcfed7a94a53640fca8
Signed-off-by: Bernhard Rosenkraenzer <Bernhard.Rosenkranzer@linaro.org>
2014-05-23 18:49:57 -07:00
Christopher Ferris
fd0ce866ce Revert "Add optimized AArch64 versions of bcopy and wmemmove based on memmove"
This reverts commit 8167dd7cb9.

For some reason I thought the bcopy change was bzero. The bcopy code doesn't pass our tests, so reverting until I can figure out what's wrong.

Change-Id: Id89fe959ea5105cd58dff6bba8d91a30cc4bcb07
2014-05-24 01:02:22 +00:00
Bernhard Rosenkraenzer
8167dd7cb9 Add optimized AArch64 versions of bcopy and wmemmove based on memmove
Add optimized versions of bcopy and wmemmove for AArch64 based on the
memmove implementation

Change-Id: Ie43d0ff4f8ec4edba5b4fb5ccacd941f81ac6557
Signed-off-by: Bernhard Rosenkraenzer <Bernhard.Rosenkranzer@linaro.org>
2014-05-23 17:54:08 -07:00
Elliott Hughes
ced906c849 Lose the hand-written futex assembler.
Also stop exporting 'futex'.

Bug: 12250341
Change-Id: Icc4fa4296cd04dfe0d1061822c69e2eb40c3433a
2014-05-22 19:49:11 -07:00
Christopher Ferris
c1d26965ae Merge "Add 32-bit Silvermont-optimized string/memory functions." 2014-05-13 00:26:50 +00:00
Elliott Hughes
dcbef06ce6 Remove the useless indirection in mips' __set_tls.
Change-Id: I12e9d6716c42ccbccc9a186441aca0736bb22d05
2014-05-12 16:11:06 -07:00
Varvara Rainchik
5a92284167 Add 32-bit Silvermont-optimized string/memory functions.
Add following functions:
bcopy, memcpy, memmove, memset, bzero, memcmp, wmemcmp, strlen,
strcpy, strncpy, stpcpy, stpncpy.
Create new directories inside arch-x86 to specify architecture: atom,
silvermont and generic (non atom or silvermont architectures are treated like generic).
Due to introducing optimized versions of stpcpy and stpncpy,
c-implementations of these functions are moved from
common for architectures makefile to arm and mips specific makefiles.

Change-Id: I990f8061c3e9bca1f154119303da9e781c5d086e
Signed-off-by: Varvara Rainchik <varvara.rainchik@intel.com>
2014-05-12 13:56:59 -07:00
Elliott Hughes
8d77bce185 LP64 shouldn't include the non-standard <time64.h> cruft.
This patch includes just enough to keep external/chromium_org building
until they switch 64-bit Android over to using the regular non-Android code.

Change-Id: Iecaf274efa46ae18a42d5e3439c5aa4f909177c1
2014-04-22 13:55:58 -07:00
Elliott Hughes
53e43292aa More OpenBSD cleanup (primarily string).
This patch removes the string/ and wchar/ directories.

Change-Id: Ia489904bc67047e4bc79acb1f3eec21aa3fe5f0d
2014-02-24 18:02:05 -08:00
Elliott Hughes
b8dc9bbd90 Stop asking GCC to cause trouble.
Why do we see so many bogus strict-aliasing warnings? Because we asked GCC to
cause trouble on arm and mips.

Change-Id: I25d7fd036b6afff7ccfa799abe0dc1579ead2847
2014-02-20 14:35:20 -08:00
Elliott Hughes
6e39ba73bf Stop advertising an arm32-specific hack like it's a build system feature.
Change-Id: I3a830b4a3516b6eb8e4f8e6e6b122a22a2e341df
2014-02-20 11:36:55 -08:00
Ying Wang
f25d677147 Reconfig libc's Android.mk to build for multilib
1. Moved arch-specific setup to their own files:
    - <arch>/<arch>.mk, arch-specific configs. Variables in those config
      end with the arch name.
    - removed the extra complexity introduced by function libc-add-cpu-variant-src,
      which seems to be not very useful these days.
2. Separated out the crt object files generation rules and set up the
   rules for both TARGET_ARCH and TARGET_2ND_ARCH.
3. Build all the libraries for both TARGET_ARCH and TARGET_2ND_ARCH,
  with the arch-specific LOCAL_ variables.

Bug: 11654773
Change-Id: I9c2d85db0affa49199d182236d2210060a321421
2014-02-12 13:58:34 -08:00
Elliott Hughes
0266ae5f88 Switch <elf.h> over to linux uapi under the covers.
Remove the linker's reliance on BSD cruft and use the glibc-style
ElfW macro. (Other code too, but the linker contains the majority
of the code that needs to work for Elf32 and Elf64.)

All platforms need dl_iterate_phdr_static, so it doesn't make sense
to have that part of the per-architecture configuration.

Bug: 12476126
Change-Id: I1d7f918f1303a392794a6cd8b3512ff56bd6e487
2014-02-10 18:22:24 -08:00
Chris Dearman
645d0312c2 [MIPS64] libc/libm support
libc/libm support for MIPS64 targets

Change-Id: I8271941d418612a286be55495f0e95822f90004f
Signed-off-by: Chris Dearman <chris.dearman@imgtec.com>
Signed-off-by: Raghu Gandham <raghu.gandham@imgtec.com>
2014-02-06 16:22:20 -08:00
Elliott Hughes
36d6188f8c Clean up forking and cloning.
The kernel now maintains the pthread_internal_t::tid field for us,
and __clone was only used in one place so let's inline it so we don't
have to leave such a dangerous function lying around. Also rename
files to match their content and remove some useless #includes.

Change-Id: I24299fb4a940e394de75f864ee36fdabbd9438f9
2013-11-19 14:08:54 -08:00
Chris Dearman
effaa7824d [MIPS] Reimplement syscall to invoke the system call directly
Some MIPS kernels do not correctly restart interrupted system calls that
have been invoked using the indirect syscall (NR_syscall).

The simplest workaround is to handle the indirection in userland and then
call the required system call directly.

Change-Id: I8385399621529db9a52b463c96925f6decaaca30
2013-11-14 16:53:15 -08:00
Elliott Hughes
bf425680e4 Let the compiler worry about implementing ffs(3).
It does at least as good a job as our old hand-written assembly anyway.

Change-Id: If7c4a1ac508bace0b71ee7b67808caa6eabf11d2
2013-10-24 16:29:40 -07:00
Elliott Hughes
b8cf18b4dd MIPS' pipe(2) is weird, but MIPS' pipe2(2) is the same as everyone else's.
arch/mips/kernel/syscall.c has a special sysm_pipe wrapper, but there's
no special treatment of pipe2 because it carries no historical baggage.

Change-Id: I892c0f690b21992c8a48276a9b732126f18fc0ee
2013-10-23 11:21:36 -07:00
Elliott Hughes
14b467e840 Fix MIPS build.
Warnings are errors for all home-grown bionic code, and the arch-specific
code now counts as home-grown bionic code (it was mistakenly counted as
"not ours" before).

Change-Id: I9c6a881b0dc596bae7dfe112c5c189e073800a3a
2013-10-09 16:40:33 -07:00
Elliott Hughes
2a0b873065 Fix __errno for LP64 and clean up __get_tls.
If __get_tls has the right type, a lot of confusing casting can disappear.

It was probably a mistake that __get_tls was exposed as a function for mips
and x86 (but not arm), so let's (a) ensure that the __get_tls function
always matches the macro, (b) that we have the function for arm too, and
(c) that we don't have the function for any 64-bit architecture.

Change-Id: Ie9cb989b66e2006524ad7733eb6e1a65055463be
2013-10-09 13:39:13 -07:00
Christopher Ferris
7c83a1ed81 Break bionic implementations into arch versions. DO NOT MERGE
Move arch specific code for arm, mips, x86 into separate
makefiles.
In addition, add different arm cpu versions of memcpy/memset.

Bug: 8005082

(cherry picked from commit acdde8c1cf)

Change-Id: I0108d432af9f6283ae99adfc92a3399e5ab3e31d
2013-02-28 17:45:16 -08:00