Compare commits

..

118 Commits

Author SHA1 Message Date
Nilesh Poddar
023c327cbb DO NOT MERGE ANYWHERE - bionic: resolver: exclude a range of ports from random_bind in DNS
Add a new API to set a range of ports which the DNS resolver should
never try to bind

Bug: 20127213
Change-Id: Ie3fca0ec2ee2523625816edd9417a0b5d5f91614
2015-04-23 21:46:36 +09:00
Christopher Ferris
3da136aa47 Modify test to avoid race condition.
There is a possible race if a timer is set to trigger at nearly the same
time as it is set. Since nobody uses the timers like this, modify the test
so this doesn't happen. The race that this can provoke has been fixed in
aosp.

Bug: 19423618
Change-Id: I21084c99da5ae46f404936d673dae6bad7c82caa
2015-02-18 17:45:50 -08:00
Neil Fuller
4177bd8d16 Fixes to the update-tzdata.py tool
We build one too many times. Creating a missing directory
is sufficient.

The tz2icu needs some files in the CWD. Added symlinks.

Bug: 19230091
(cherry-pick of commit 0662c3e5b3)
Change-Id: Ie21d848f1b776ec745473b9122e003fdf0acf105
2015-02-02 17:53:19 +00:00
Neil Fuller
700eb048fb Update tzdata to tzdata2015a
Time Zone Data v. 2015a (Released 2015-01-29)
http://www.iana.org/time-zones/repository/releases/tzdata2015a.tar.gz

Information from NEWS:

Release 2015a - 2015-01-29 22:35:20 -0800

  Changes affecting future time stamps

    The Mexican state of Quintana Roo, represented by America/Cancun,
    will shift from Central Time with DST to Eastern Time without DST
    on 2015-02-01 at 02:00.  (Thanks to Steffen Thorsen and Gwillim Law.)

    Chile will not change clocks in April or thereafter; its new standard time
    will be its old daylight saving time.  This affects America/Santiago,
    Pacific/Easter, and Antarctica/Palmer.  (Thanks to Juan Correa.)

    New leap second 2015-06-30 23:59:60 UTC as per IERS Bulletin C 49.
    (Thanks to Tim Parenti.)

  Changes affecting past time stamps

    Iceland observed DST in 1919 and 1921, and its 1939 fallback
    transition was Oct. 29, not Nov. 29.  Remove incorrect data from
    Shanks about time in Iceland between 1837 and 1908.

    Some more zones have been turned into links, when they differed
    from existing zones only for older time stamps.  As usual,
    these changes affect UTC offsets in pre-1970 time stamps only.
    Their old contents have been moved to the 'backzone' file.
    The affected zones are: Asia/Aden, Asia/Bahrain, Asia/Kuwait,
    and Asia/Muscat.

  Changes affecting code

    tzalloc now scrubs time zone abbreviations compatibly with the way
    that tzset always has, by replacing invalid bytes with '_' and by
    shortening too-long abbreviations.

    tzselect ports to POSIX awk implementations, no longer mishandles
    POSIX TZ settings when GNU awk is used, and reports POSIX TZ
    settings to the user.  (Thanks to Stefan Kuhn.)

  Changes affecting build procedure

    'make check' now checks for links to links in the data.
    One such link (for Africa/Asmera) has been fixed.
    (Thanks to Stephen Colebourne for pointing out the problem.)

  Changes affecting commentary

    The leapseconds file commentary now mentions the expiration date.
    (Problem reported by Martin Burnicki.)

    Update Mexican Library of Congress URL.

Bug: 19212588
Change-Id: Idc07ac862901500d4a1dbd0f4aadcfd0aa9d10b8
2015-02-02 11:32:10 +00:00
Dmitriy Ivanov
d9e211ca1f Print error when prelink fails for main executable
Bug: 18931021
Change-Id: Ieefdcf60f1506af522714300030754a4ed61c08e
2015-01-07 11:23:34 -08:00
Elliott Hughes
c7450f7738 Restore symbols from <arpa/nameser.h>.
Bug: 18627252
Bug: https://code.google.com/p/android/issues/detail?id=81690

(cherry picked from commit 42804c4b30)

Change-Id: Idd33578b31bba9a4afdfd15c7b193d10974aea90
2014-12-04 13:45:22 -08:00
Elliott Hughes
27d276f3a6 Avoid pathological behavior in OpenBSD's fread.
(cherry picked from commit 20841a137b)

Bug: https://code.google.com/p/android/issues/detail?id=81155
Bug: 18556607
Change-Id: Ibdfebc20dce4c34ad565014523c9b074e90ea665
2014-12-02 14:54:52 -08:00
Elliott Hughes
152e978f73 Merge "Put stdin/stdout/stderr symbols in place." into lmp-mr1-dev 2014-12-02 18:56:50 +00:00
Elliott Hughes
111461aaae Put stdin/stdout/stderr symbols in place.
To help with future binary compatibility.

Bug: 18553223
Change-Id: Ia8103b4f189c18528b11948ac9e520f61b9ccc0e
2014-12-01 21:27:59 -08:00
Lorenzo Colitti
e5477f83b0 Fail queries fast if no DNS servers are configured.
When no DNS servers are configured (and thus there is no chance
that the DNS query will suceed), res_nsend returns early, but
it does not tell the cache that the query has failed.
Therefore, if the caller retries the query, it will block for
PENDING_REQUEST_TIMEOUT (= 20 seconds) waiting for the "existing
query" (which isn't actually doing anything) to complete.

Bug: 18240188
Bug: 18327075
Change-Id: I0df13ff4a17ee65e640be96695a3af31b020963a
2014-12-01 20:03:25 +00:00
Elliott Hughes
432f645887 Fix flockfile(3) and friends for stdin/stdout/stderr too.
stdin/stdout/stderr are special; their mutexes are initialized by
__sinit. There's no unit test for this, because __sinit has already
been called by the time the first unit test runs, but you could
reproduce this failure with a trivial main() that calls flockfile
or ftrylockfile on one of the standard streams before otherwise
using stdio.

Bug: 18208568

(cherry picked from commit c48c3e4bb3)

Change-Id: Ia0c43ed4ac69daea8152aee9516415a6e3f8a042
2014-11-19 15:49:09 -08:00
Elliott Hughes
047d943ee9 sysconf(3) returns long.
On LP32, this makes no difference. Not an ABI change.

On LP64, results are going to be in %rax or x0 whether they're 32- or 64-bit,
and the only difference is going to be whether the top bits are clobbered.

(cherry picked from commit 60d84af172)

Bug: 18390956
Change-Id: I722461498bc5494e2972fb07d5189dffe76e8993
2014-11-14 15:37:49 -08:00
Daniel Rosenberg
4a50d8ead7 bionic: libc: Added path to vendor build properties file.
Signed-off-by: Daniel Rosenberg <drosen@google.com>

(cherry picked from commit 71d220c1de)

Bug: 18281574
Change-Id: I2843f23ecb4c4ca79b230d8041bbca02dbedeadc
2014-11-13 13:09:59 -08:00
Elliott Hughes
c05314a0b2 Merge "Fix tzdata update tools for 'backzone'." into lmp-mr1-dev 2014-11-12 17:19:57 +00:00
Elliott Hughes
1ca3350f4c Upgrade bionic to tzdata2014j.
From the release notes:

   Changes affecting current and future time stamps

     Turks & Caicos' switch from US eastern time to UTC-4 year-round
     did not occur on 2014-11-02 at 02:00.  It's currently scheduled
     for 2015-11-01 at 02:00.  (Thanks to Chris Walton.)

   Changes affecting past time stamps

     Many pre-1989 time stamps have been corrected for Asia/Seoul and
     Asia/Pyongyang, based on sources for the Korean-language Wikipedia
     entry for time in Korea.  (Thanks to Sanghyuk Jung.)  Also, no
     longer guess that Pyongyang mimicked Seoul time after World War II,
     as this is politically implausible.

     Some more zones have been turned into links, when they differed
     from existing zones only for older time stamps.  As usual,
     these changes affect UTC offsets in pre-1970 time stamps only.
     Their old contents have been moved to the 'backzone' file.
     The affected zones are: Africa/Addis_Ababa, Africa/Asmara,
     Africa/Dar_es_Salaam, Africa/Djibouti, Africa/Kampala,
     Africa/Mogadishu, Indian/Antananarivo, Indian/Comoro, and
     Indian/Mayotte.

Bug: 18330681

(cherry picked from commit b11d8e057c)

Change-Id: Ifd48e7446e400dccae3afd5cbef96ca843775477
2014-11-11 19:56:09 -08:00
Elliott Hughes
371dcc189f Fix tzdata update tools for 'backzone'.
To maintain the status quo, we need to pull in backzone file. This file
can't be built on its own, so the easiest fix is to give zic(1) all the
files at once.

We also now have a situation where we have links to links, so we need to
dereference them until we find actual data.

Bug: 18330681

(cherry picked from commit 2c2463bd30)

Change-Id: I654b80518a7144038d8b3ea7223f49e2b1d2ad13
2014-11-11 19:55:35 -08:00
Dmitriy Ivanov
9d3382d97a Revert "Fix dlsym() to take into account RTLD_GLOBAL/LOCAL"
This reverts commit c85e82dde5.

Bug: 18222321
Bug: 18211780
Change-Id: I32f4048bd5ea85dc8a3dfccce8cf141b241ab692
2014-11-03 22:15:29 -08:00
Dmitriy Ivanov
69c5d108a5 Revert "Add RTLD_NODELETE flag support"
This reverts commit c87f65d2cd.

Bug: 18222321
Bug: 18211780
Change-Id: I00252e26a28a41ab9f1e2dd3b32f0f80d86297f1
2014-11-03 22:15:26 -08:00
Dmitriy Ivanov
00dce52553 Revert "Fix relocation to look for symbols in local group"
This reverts commit fd2747bb58.

Bug: 18222321
Bug: 18211780
Change-Id: I2d4ebab1e73b7277161af76b99f8249825b22d65
2014-11-03 22:15:20 -08:00
Dmitriy Ivanov
eae0977255 Revert "Remove unnecessary lookups during relocations"
This reverts commit 6442dbd3bc.

Bug: 18222321
Bug: 18211780
Change-Id: I87b18a32238a1f75afe56149221b6691f50d9f56
2014-11-03 22:15:17 -08:00
Dmitriy Ivanov
4402804c35 Revert "Fix mips build"
This reverts commit bf3d5ef5fd.

Bug: 18222321
Bug: 18211780
Change-Id: I902ed888197b358c77303f1acb6d5ffd7ae6dcd3
2014-11-03 22:15:13 -08:00
Dmitriy Ivanov
f947be2889 Revert "Fix symbol lookup order during relocation"
This reverts commit 976402cca1.

Bug: 18222321
Bug: 18211780
Change-Id: Iafdd3d843db7b1cf288be9a0232022816622c944
2014-11-03 22:15:08 -08:00
Dmitriy Ivanov
494bee796a Revert "Fix arm64 and arm builds."
This reverts commit 445111a1c9.

Bug: 18222321
Bug: 18211780
Change-Id: I4fa9e1b63ec9b528f8bfed73c2ec15046c43a2fe
2014-11-03 22:14:19 -08:00
Elliott Hughes
d18f4b2578 Ensure we initialize stdin/stdout/stderr's recursive mutexes.
(cherry-pick of 6a03abcfd23f31d1df06eb0059830e22621282bb.)

Bug: 18208568
Change-Id: I9da16ce0f9375bc363d1d02be706d73fd3b1e150
2014-11-03 13:46:41 -08:00
Dmitriy Ivanov
445111a1c9 Fix arm64 and arm builds.
Bug: 18186310

(cherry picked from commit 4e446b19d8)

Change-Id: Ibc77a9ade36dc6b9bf5a316b5ab9ae5f0a70e826
2014-10-31 19:29:04 -07:00
Dmitriy Ivanov
976402cca1 Fix symbol lookup order during relocation
Relocate symbol against DF_1_GLOBAL shared libraries
  loaded before this shared library. This includes
  main executable, ld_preloads and other libraries
  that have DF_1_GLOBAL flag set.

Bug: 2643900
Bug: 15432753
Bug: 18186310

(cherry picked from commit d225a5e652)

Change-Id: I4e889cdf2dfbf8230b0790053d311ee6b0d0ee2d
2014-10-31 17:10:30 -07:00
Dmitriy Ivanov
bf3d5ef5fd Fix mips build
Bug: 18186310

(cherry picked from commit 90b74fb867)

Change-Id: I8d4ed254e5c421b65b62c401abdb1ee07e5dc3b2
2014-10-31 17:04:00 -07:00
Dmitriy Ivanov
6442dbd3bc Remove unnecessary lookups during relocations
local_group includes this library and its dependencies.

Bug: 18186310

(cherry picked from commit e47b3f8456)

Change-Id: I93c2d873e924df7319569307444bf603d7d27bf0
2014-10-31 17:04:00 -07:00
Dmitriy Ivanov
fd2747bb58 Fix relocation to look for symbols in local group
The local group is a sequence of libraries in default (breadth-first)
  order. It allows RTLD_LOCALLY loaded library to correctly relocate
  symbols within its group (see test-cases).

  Local group lookup is performed after main executable and ld_preloads.

Bug: 2643900
Bug: 15432753
Bug: 18186310

(cherry picked from commit cfa97f172d)

Change-Id: I5fa8c673f929e4652c738912c7ae078d7ec286d2
2014-10-31 17:04:00 -07:00
Dmitriy Ivanov
4d0c1f673f Correct way to specify additional dependencies
Previous one was not covering all the targets

Bug: 17548097
Bug: 18186310

(cherry picked from commit 4a9e1937c5)

Change-Id: I2cd9e58893555d16cbfe291b2d1279621489d5ad
2014-10-31 17:04:00 -07:00
Dmitriy Ivanov
382e06ce8e Add dlfcn_test to glibc test suite.
Bug: 18186310

(cherry picked from commit eb27bbae8f)

Change-Id: I1d608dfa12dbafbdcdb8bc6d818c5872404c19e0
2014-10-31 17:04:00 -07:00
Dmitriy Ivanov
e4bc6f026a Ignore DT_BIND_NOW (0x18)
Bug: 18186310
Bug: 17552334

(cherry picked from commit ea6eae182a)

Change-Id: I07d6f6fbb462fea329581d0da02f6d88be1c262f
2014-10-31 17:04:00 -07:00
Dmitriy Ivanov
1d3e81a9e7 Resolve "unused DT entry" warnings for x86_64
Bug: 18186310

(cherry picked from commit 513e29e16f)

Change-Id: I1e4c5af2cdc09dc978c7a78fcdcf8796c919751e
2014-10-31 17:04:00 -07:00
Dmitriy Ivanov
c87f65d2cd Add RTLD_NODELETE flag support
Bug: 18186310
Bug: https://code.google.com/p/android/issues/detail?id=64069

(cherry picked from commit 1b20dafdbe)

Change-Id: Ic02eec22a7c322ece65eb40730a3404f611526b1
2014-10-31 17:04:00 -07:00
Dmitriy Ivanov
210ff1b27b Fix mips build
Bug: 18186310

(cherry picked from commit ecf532fa1c)

Change-Id: Ia12f2fa28c8cd3204eb7d6b4c7d872f4e81fb8ef
2014-10-31 17:04:00 -07:00
Dmitriy Ivanov
0f47d9c1ce Fix unused DT entry warnings.
DT_STRSZ Implement strtab boundary checks
 DT_FLAGS_1 Warn if flags other than DF_1_NOW|DF_1_GLOBAL are set

Bug: 17552334
Bug: 18186310

(cherry picked from commit 6cdeb5234d)

Change-Id: I7ffc7bc600798308a77ad949a644949b64250ae2
2014-10-31 17:03:59 -07:00
Dmitriy Ivanov
f90e21004e Return has_DT_SYMBOLIC flag.
This reverts commit 8f61d99183

 Despite the fact that static linker does all the work while linking
 -Bsymbolic executables, according to the SCO doc following DT_SYMBOLIC
 and DF_SYMBOLIC flags is still a requirement for the dynamic linker
 as well.

 (see http://www.sco.com/developers/gabi/2012-12-31/ch5.dynamic.html)

Bug: 18186310

(cherry picked from commit 96bc37f2e1)

Change-Id: Ie217be4f3305d877066e4cfe91975ae1c7768330
2014-10-31 17:03:59 -07:00
Elliott Hughes
748fbe5c41 Fix a couple more cases of missing CLOEXEC.
The debuggerd case can probably never happen, because you're crashing at this
point anyway. The system property one seems possible though.

Bug: 18186310

(cherry picked from commit 0dc39f9952)

Change-Id: I3e84488fc246f6c28cbd82e96d0cd4343a12c28a
2014-10-31 17:03:21 -07:00
Dmitriy Ivanov
d5eb10875a Temporary disable DL_WARNs for unused DT_*
Bug: 17552334
Bug: 18186310

(cherry picked from commit 1b77423eff)

Change-Id: I8a9d05195a862bc287fff7156913606f0311b8bb
2014-10-31 17:02:14 -07:00
Dmitriy Ivanov
09608848ed Fix 64bit build
Bug: 18186310

(cherry picked from commit f240aa8089)

Change-Id: Id46f1f9be90a17a58fb44d3540095c8c685c9726
2014-10-31 17:02:14 -07:00
Dmitriy Ivanov
634a045c5c Fix some unused DT_ warnings
* DT_PLTGOT - ignored for non-mips
 * DT_RELCOUNT/RELACOUNT - ignored
 * DT_RELENT/RELAENT - sanity checks
 * DT_SYMENT - sanity check
 * DT_SONAME - ignore for now.

Bug: 18186310

(cherry picked from commit 4a6e9a835a)

Change-Id: Ib40095f0770d65628fc7abac5a471378de35ebe7
2014-10-31 17:02:14 -07:00
Dmitriy Ivanov
b364d95380 Remove has_DT_SYMBOLIC flag
From the elf-spec: "Symbolically bound shared objects are
  identified by the .dynamic entry DT_SYMBOLIC. This tag is
  informational only; the runtime linker processes symbol
  lookups from these objects in the same manner as any
  other object."

Bug: 18186310

(cherry picked from commit 8f61d99183)

Change-Id: I37024799ac8d1837993c8ae78780a448bedd6539
2014-10-31 17:02:13 -07:00
Dmitriy Ivanov
c85e82dde5 Fix dlsym() to take into account RTLD_GLOBAL/LOCAL
Symbols from libraries opened with RTLD_LOCAL (default)
  should not be visible via dlsym(RLTD_DEFAULT/RTLD_NEXT, .)

Bug: 17512583
Bug: 18186310

(cherry picked from commit e8ba50fe0d)

Change-Id: Idf6bbe2233fb2bfc0c88677e7d1fc518fb3f7a8b
2014-10-31 17:02:13 -07:00
Dmitriy Ivanov
926797a8a9 Reformatting
No functional changes.

Bug: 18186310

(cherry picked from commit 6abf624d12)]

Change-Id: I0acf52d8ee7fe2d4f44bc832cbe9fabe1782f03f
2014-10-31 17:02:13 -07:00
Dan Albert
653263a964 Only use <atomic> for C++11 and newer.
Any pre-C++11 clients of stdatomic.h that use libc++ are being forced
over to <atomic>, which they don't have the language support to use.

Bug:17736764

Change-Id: I62445c1f2541410a1569498c09433c7196635537
(cherry picked from commit 3ce0769aa5)
2014-10-30 13:22:34 -07:00
Elliott Hughes
b0693ec582 Merge changes I0feda6b2,I22d13fde,I49d7d09d,Ice490bfe into lmp-mr1-dev
* changes:
  Fix the type of u_ar0 in <sys/user.h>.
  Add greg_t for arm64.
  POSIX says <signal.h> gets you ucontext_t.
  Add in_port_t and move it and in_addr_t to the correct header file.
2014-10-29 23:22:30 +00:00
Elliott Hughes
0c4e98adbe Fix the type of u_ar0 in <sys/user.h>.
(cherry picked from commit e03950fa0c)

Bug: 18172268
Change-Id: I0feda6b253882f68f47bcf30fad998286cc7f620
2014-10-29 11:57:36 -07:00
Elliott Hughes
d0fb6a2940 Add greg_t for arm64.
This was already present for the other architectures. I think we skipped
this because glibc seems to have an incorrect definition (int rather than
long), but the kernel has the sane definition (just not in a uapi header).

(cherry picked from commit 8e4d371091)

Bug: 18172268
Change-Id: I22d13fdeb6431ea122dd028a229782dcaf2286b2
2014-10-29 11:56:59 -07:00
Elliott Hughes
ab4d5cf242 POSIX says <signal.h> gets you ucontext_t.
POSIX also says that ucontext_t's uc_sigmask has type sigset_t.

MIPS64 strace needs this.

The #define is to keep chromium off our lawn; otherwise it tries to redefine
all this stuff itself. We should probably clean that up and remove the #define.

(cherry picked from commit 26a8eb50a8)

Bug: 18172268
Change-Id: I49d7d09dabfc6c6926a8e1f4b235d041e2f2fc4d
2014-10-29 11:55:02 -07:00
Elliott Hughes
eedbf70e8e Add in_port_t and move it and in_addr_t to the correct header file.
No one's reported this, but I saw it in an Android port of fuser(1).

We still have lots of problems in our network headers because we
get most of the structs direct from the kernel, and it doesn't use
types like this (which is why we've got away without this one for
so long). One day we should probably look at cleaning that up, but
doing so can wait.

(cherry picked from commit 35d226e05d)

Bug: 18172268
Change-Id: Ice490bfe84afb04722d738128053d4c533b8a664
2014-10-29 11:49:45 -07:00
Christopher Ferris
98d57c95bc Add stpcpy assembler version.
For generic, continue to use the C version of the code.

Bug: 13746695

(cherry picked from commit 7d849ac378)

Change-Id: Iae44785f37f9bb59103ab78fb9f74c92f8a95c7f
2014-10-29 11:07:03 -07:00
Christopher Ferris
1c8ea807eb Cleanup arm assembly.
Remove the old arm directives.
Change the non-local labels to .L labels.
Add cfi directives to strcpy.S.

Bug: 18157900

(cherry picked from commit c8bd2abab2)

Change-Id: Ifa1c3d16553d142eaa0d744af040f0352538106c
2014-10-28 18:19:33 -07:00
Christopher Ferris
0cc59dd303 Add __memcpy_chk assembly for 64 bit.
Bug: 17623887

(cherry picked from commit 8cf61dab5f)

Change-Id: I91e66ca0c26f04b50308059f9c89d388d55f6e3a
2014-10-28 16:18:47 -07:00
Elliott Hughes
86d16a053e Clean up the architecture-specific makefiles.
Group things appropriately and name each group.

Bug: 18160821

(cherry picked from commit 7c02d9428c)

Change-Id: I863242515af44058154d03e2d8c34678e682d66a
2014-10-28 15:13:36 -07:00
Elliott Hughes
b378c27226 No arm source refers to SOFTFLOAT.
So why bother #defining it?

Bug: 18160821

(cherry picked from commit b1a6c319c4)

Change-Id: I9cd9c144ba7071fddda12fa16d1232ad861b66be
2014-10-28 15:13:04 -07:00
Elliott Hughes
22e2c9d963 Fix mips signed/unsigned signal_test.cpp build breakage.
(cherry picked from commit aa13e839f0)

Bug: 17436734
Change-Id: I167fc5d74c49cca7031c5739bc53fdf3bde71887
2014-10-28 14:02:10 -07:00
Christopher Ferris
43dc3a9aae Remove the unnecessary generic-neon code.
Bug: 18156619
(cherry picked from commit 2169e17482)

Change-Id: I4a7f5bb9ad4c27b274f3a3c86c1617ca0578b98f
2014-10-28 12:07:25 -07:00
Elliott Hughes
1ea31a2901 Merge "Don't mask out SA_RESTORER from sa_flags." into lmp-mr1-dev 2014-10-28 15:36:56 +00:00
Elliott Hughes
cd99bbfd50 Merge "Disable tzdata in $ANDROID_DATA." into lmp-mr1-dev 2014-10-28 15:06:31 +00:00
Elliott Hughes
28ea229bb2 Don't mask out SA_RESTORER from sa_flags.
glibc doesn't do this, and we probably shouldn't either.

Bug: 16703540
Bug: 17436734

(cherry picked from commit afe58ad989)

Change-Id: Iada5d0ae814f438cb276f056b2b5e3675f0e3666
2014-10-28 07:55:53 -07:00
Pavel Chupin
8eb8c39299 [x86,x86_64] Fix libgcc unwinding through signal
This change provides __restore/__restore_rt on x86 and __restore_rt on
x86_64 with unwinding information to be able to unwind through signal
frame via libgcc provided unwinding interface. See comments inlined for
more details.

Also remove the test that had a dependency on
__attribute__((cleanup(foo_cleanup))). It doesn't provide us with any
better test coverage than we have from the newer tests, and it doesn't
work well across a variety architectures (presumably because no one uses
this attribute in the real world).

Tested this on host via bionic-unit-tests-run-on-host on both x86 and
x86-64.

Bug: 17436734
Signed-off-by: Pavel Chupin <pavel.v.chupin@intel.com>

(cherry picked from commit 50321e2e66)

Change-Id: Iba90e36958b00c7cc7db5eeebf888dc89ce4d619
2014-10-27 16:42:49 -07:00
Elliott Hughes
190dce9e56 Stack unwinding unit tests.
Bug: 17436734

(cherry picked from commit bee1993a14)

Change-Id: I7205a862ba2c3b474e287f5e9c8982cef4610af9
2014-10-27 16:42:37 -07:00
Elliott Hughes
e5e61a0a92 Use the kernel's sa_restorer for aarch64.
gdb was happy with what we had, but libgcc and libunwind weren't.
libgcc is happy with the kernel's restorer (because of the extra nop),
though libunwind looks like it's going to need code changes regardless.

We could make our restorer more like the kernel's one, but why bother
when we can just let the kernel supply the canonical one?

Bug: 17436734

(cherry picked from commit 1cff9a8964)

Change-Id: Ie13d73fd97395e1979a67c2294e036a97c50000d
2014-10-27 16:42:19 -07:00
Elliott Hughes
5054e1a121 Fix 32-bit arm unwinding through signal frames.
gdb was already okay; libgcc and libunwind need a little extra help.

Bug: 17436734

(cherry picked from commit 148dff3ec6)

Change-Id: I2cc997017acc57c930284af5264f353656b98c7b
2014-10-27 16:41:56 -07:00
Elliott Hughes
7dc2b7b30d Fix signal trampolines.
* LP32 should use sa_restorer too. gdb expects this, and future (>= 3.15) x86
  kernels will apparently stop supporting the case where SA_RESTORER isn't
  set.

* gdb and libunwind care about the exact instruction sequences, so we need to
  modify the code slightly in a few cases to match what they're looking for.

* gdb also cares about the exact function names (for some architectures),
  so we need to use __restore and __restore_rt rather than __sigreturn and
  __rt_sigreturn.

* It's possible that we don't have a VDSO; dl_iterate_phdr shouldn't assume
  that getauxval(AT_SYSINFO_EHDR) will return a non-null pointer.

This fixes unwinding through a signal handler in gdb for all architectures.
It doesn't fix libunwind for arm and arm64. I'll keep investigating that...

(cherry picked from commit 36f451a6d9)

Bug: 17436734
Change-Id: Ic1ea1184db6655c5d96180dc07bcc09628e647cb
2014-10-27 16:41:28 -07:00
Elliott Hughes
4c30130a21 Disable tzdata in $ANDROID_DATA.
Bug: 18139284
Change-Id: I2670dc1791d635139a5d39a438dc08777439476b
2014-10-27 13:38:21 -07:00
Elliott Hughes
aa6cd5819c Use mxcr_mask instead of mxcsr_mask to match glibc.
Bug: 18097559

(cherry picked from commit f485547b92)

Change-Id: I242105faa8210abc9635a951b25b127cd64ed23c
2014-10-24 08:43:34 -07:00
Elliott Hughes
8fab8119dd Update bionic to tzdata2014i.
From the release notes:

   Changes affecting future time stamps

     Pacific/Fiji will observe DST from 2014-11-02 02:00 to
     2015-01-18 03:00.  (Thanks to Ken Rylander for the heads-up.)
     Guess that future years will use a similar pattern.

     A new Zone Pacific/Bougainville, for the part of Papua New
     Guinea that plans to switch from UTC+10 to UTC+11 on
     2014-12-28 at 02:00.  (Thanks to Kiley Walbom for the
     heads-up.)

   Changes affecting time zone abbreviations

     Since Belarus is not changing its clocks even though Moscow
     is, the time zone abbreviation in Europe/Minsk is changing
     from FET to its more-traditional value MSK on 2014-10-26 at
     01:00.  (Thanks to Alexander Bokovoy for the heads-up about
     Belarus.)

     The new abbreviation IDT stands for the pre-1976 use of UT+8
     in Indochina, to distinguish it better from ICT (UT+7).

   Changes affecting past time stamps

     Many time stamps have been corrected for Asia/Ho_Chi_Minh
     before 1976 (thanks to Trần Ngọc Quân for an indirect pointer
     to Trần Tiến Bình's authoritative book).  Asia/Ho_Chi_Minh has
     been added to zone1970.tab, to give tzselect users in Vietnam
     two choices, since north and south Vietnam disagreed after our
     1970 cutoff.

     Asia/Phnom_Penh and Asia/Vientiane have been turned into
     links, as they differed from existing zones only for older
     time stamps.  As usual, these changes affect pre-1970 time
     stamps only.  Their old contents have been moved to the
     'backzone' file.

Bug: 18085936

(cherry picked from commit a05c2a2a70)

Change-Id: If0253cc1515e1bc98e99c6e24eec797836ca7c27
2014-10-22 13:45:25 -07:00
Christopher Ferris
82eeec689f Merge "Fix generic __memcpy_chk implementation." into lmp-mr1-dev 2014-10-22 20:16:18 +00:00
Christopher Ferris
9b7b0d82eb Merge "Fix race condition in timer disarm/delete." into lmp-mr1-dev 2014-10-22 19:43:44 +00:00
Christopher Ferris
f13e1eb92f Fix generic __memcpy_chk implementation.
- Clean up the labels (add .L to make them local).
- Change to using cfi directives.
- Fix unwinding of the __memcpy_chk fail path.

Bug: 18033671

(cherry pick from commit 7123d4371a)

Change-Id: Ife93bcbfc1949ef29fc8e2dc515b7120632b82b1
2014-10-22 12:02:13 -07:00
Dmitriy Ivanov
702ab5b37e Rename library_offset to library_fd_offset
replace lseek() and use pread() instead
 add test for library_fd_offset > file_size case

Bug: 17762003

(cherry picked from commit a6c1279098)

Change-Id: Ie117c745081ee33d07db5341115ff6c8e98b0dec
2014-10-22 16:35:04 +00:00
Ying Wang
3c5c720b0b Build dlext_testzip as custom module.
Use $(BUILD_SYSTEM)/base_rules to build it as custom module, so that
it's exposed to utilities like mm/mmma etc.

Bug: 17887283
Bug: 17762003

(cherry picked from commit 667853d477)

Change-Id: I405797d16f20dc09e5d84b93b6727b634db2fc2c
2014-10-22 08:30:43 +00:00
Christopher Ferris
0724132c32 Fix race condition in timer disarm/delete.
When setting a repeat timer using the SIGEV_THREAD mechanism, it's possible
that the callback can be called after the timer is disarmed or deleted.
This happens because the kernel can generate signals that the timer thread
will continue to handle even after the timer is supposed to be off.

Add two new tests to verify that disarming/deleting doesn't continue to
call the callback.

Modify the repeat test to finish more quickly than before.

Refactor the Counter implementation a bit.

Bug: 18039727
Change-Id: I73192c915cdacf608521b1792c54e5af14a34907
2014-10-21 18:31:02 -07:00
Dmitriy Ivanov
de01780f46 Add file_offset parameter to android_extinfo
Bug: 17762003

(cherry picked from commit 07e5bc152d)

Change-Id: I72d527831384ff5dde013a4c8dfe639fbec165f5
2014-10-21 13:52:49 -07:00
Hans Boehm
c712ceeec4 Make memory_order_acquire visible in global namespace
We were missing that using directive when including <atomic>.

Bug:17736764
Change-Id: Ie8ca92a952749415567bcd5fa21d56629a364660
(cherry picked from commit 76ac4d0853)
2014-10-20 11:41:34 -07:00
Christopher Ferris
59a02860a4 Merge "Return total footprint, not high water mark." into lmp-mr1-dev 2014-10-13 19:36:56 +00:00
Christopher Ferris
f4ada9c9ce Return total footprint, not high water mark.
The mallinfo usmblks value returned by dlmalloc is a little misleading.
It's not the current max, it's the historical high water mark. This
leads to dumpsys meminfo producing native memory numbers that don't add up.
Change this to the real total footprint, not this high water mark.

Bug: 17265653
Change-Id: Id0293a1b50c9b0be8795405049f537a51ab0e8b7
2014-10-13 12:29:30 -07:00
Christopher Ferris
e0fafb019e am c891e240: Add back symbols to fix Greed for Glory franchise.
* commit 'c891e24073830e07ba7373dee554ff2c70e1d313':
  Add back symbols to fix Greed for Glory franchise.
2014-10-10 20:47:00 +00:00
Elliott Hughes
2f25cf373c Fix pthread_attr_getstack under valgrind.
valgrind seems to mess with the stack enough that the kernel will
report "[stack:pid]" rather than "[stack]" in /proc/self/maps, so
switch to the task-specific file instead to force "[stack]". (There
are two conditions in the kernel code that decides which form to
output.)

Bug: 17897476

(cherry picked from commit 9afb2f2106)

Change-Id: I92c331ef6fb5868af49e75bc595710d290a95f5b
2014-10-10 10:57:48 -07:00
Christopher Ferris
7f4618cbc8 am c9734d24: Re-add dlmalloc for 32 bit.
* commit 'c9734d24d92f4737f5ab3808c77d816a1b084582':
  Re-add dlmalloc for 32 bit.
2014-10-09 22:02:00 +00:00
Elliott Hughes
e5d4fc39e3 am 1543fdf6: Work around a bug in Immersion\'s libImmEmulatorJ.so.
* commit '1543fdf616ddebee7819214437527f380e5c743b':
  Work around a bug in Immersion's libImmEmulatorJ.so.
2014-10-08 05:24:46 +00:00
Dan Albert
55ee845b8e Inline helpers need to be exported unmangled.
__open_2() is used by the fortify implementation of open(2) in
fcntl.h, and as such needs an unmangled C name. For some reason
(inlining?), this doesn't cause problems at the default optimization
level, but does for -O0.

The rest of these didn't cause build failures, but they look suspect
and probably will, we just haven't caught them yet.

(cherry-pick of 658727e111 with conflicts
in stdio.h and string.h.)

Bug: 17784968
Change-Id: I7391a7a8999ee204eaf6abd14a3d5373ea419d5b
2014-10-07 18:51:24 -07:00
Nick Kralevich
ce92b41a00 cdefs.h: add artificial attribute to FORTIFY_SOURCE functions
Otherwise the gcc compiler warning doesn't show up.

Add -Wno-error to fortify related tests. Fortify related tests
are expected to be examples of bad programs, and in many
cases shouldn't compile cleanly. Rewriting them to compile
cleanly isn't feasible nor desirable.

Bug: 17784968

(cherry picked from commit 1aaa17802c)

Change-Id: Ib6df1a3f44b55b1fff222e78395c10c51cd39817
2014-10-07 16:37:04 -07:00
Elliott Hughes
b5e7eba6d1 Work around a bug in Immersion's libImmEmulatorJ.so.
This library calls pthread_mutex_lock and pthread_mutex_unlock with a NULL
pthread_mutex_t*. This gives them (and their users) one release to fix things.

Bug: 17443936

(cherry picked from commit 7d3f553f98)

Change-Id: Ie26bbecd3a74d61113b51c18832872499b97ee86
2014-10-07 16:08:46 -07:00
Elliott Hughes
ea8dea8cb7 Merge "Improve <sys/cdefs.h>." into lmp-mr1-dev 2014-10-07 18:51:36 +00:00
Elliott Hughes
d87d401ab1 Improve <sys/cdefs.h>.
Fix and use __RENAME (and lose ___RENAME --- two underscores should be
enough for anybody). This was the point of this change, because I want
to use __RENAME to support the two basename variants and the two
strerror_r variants.

Lose a bunch of macros that weren't being used.

Lose three dead files from the DNS code.

Bug: 17784968

(cherry picked from commit 2cfb4e8e2e)

Change-Id: I5e96146f92c0521248c78c0933bec5e9a9818222
2014-10-07 11:40:09 -07:00
Christopher Ferris
4aace3852d am 2cf15571: am 40bc7cd4: (-s ours) DO NOT MERGE Re-add .save directive for arm assembler code.
* commit '2cf155713aaba451065d593335d544f2ada24ddf':
  DO NOT MERGE  Re-add .save directive for arm assembler code.
2014-10-07 17:42:39 +00:00
Elliott Hughes
6c4e16f634 Merge "further cleanup memcpy fortify implementation" into lmp-mr1-dev 2014-10-07 00:30:34 +00:00
Christopher Ferris
27355affc1 am d11eac34: Force export symbols on all x86 variants in libc.
* commit 'd11eac3455a059a092ceee92eda9905e1d661e94':
  Force export symbols on all x86 variants in libc.
2014-10-07 00:20:10 +00:00
Nick Kralevich
db408bf421 further cleanup memcpy fortify implementation
Bug: 17784968

(cherry picked from commit b84f667e93)

Change-Id: I68fc2cc0a1ee7f0887edf3681eb83ef678de1383
2014-10-06 16:18:32 -07:00
Nick Kralevich
7ad2147a08 string.h: remove unused variable
(cherry picked from commit 48be71d02b)

Bug: 17784968
Change-Id: Iac7732fb4f7fe42977cb9f62472bb636e17e5232
2014-10-06 10:17:01 -07:00
Alex Van Brunt
02542b3bbd am a5087148: Reimplement clock(3) using clock_gettime(3)
* commit 'a508714800242b294291060641ed35d719bdc857':
  Reimplement clock(3) using clock_gettime(3)
2014-10-04 16:44:11 +00:00
Elliott Hughes
22f5a61d95 am ea9800e9: Explain why clock(3) isn\'t broken.
* commit 'ea9800e98598c71fe76c4e2a0d0498b6bd490a83':
  Explain why clock(3) isn't broken.
2014-10-04 00:06:27 +00:00
Ningsheng Jian
04f5f4100c Fix gdb could not get shared library list issue
Get dynamic flags from phdr table's correct entry rather the first
entry, so that the following DT_DEBUG entry can be set.

Also fix the undefined reference to LoadTask::deleter issue under gcc
-O0 option.

Bug: 17524778

(cherry picked from commit e93be99da0)

Change-Id: I347792dab25c7b19c3fc690e03d20899ce1e26e0
2014-10-02 15:35:47 -07:00
Dmitriy Ivanov
1cd0c6777f L-MR1 specific fixes
Reset soinfo version to 0.
 Disable ifunc test for arm64 because of old toolchain
 in lmp-mr1-dev branch

 Note: this commit should be reverted in -plus-aosp branch.

Change-Id: I2d6d996d43bc35d5d4975c745779f43a988b31e6
2014-10-01 16:26:49 -07:00
Dmitriy Ivanov
7d971ec14b Fix unload of recursively linked library
Expanded test for recursive libs. Fixed bug with unnecessary
  soinfo_free of already loaded library.

(cherry picked from commit a6ac54a215)

Change-Id: I6907c723d9fbdf6b2777f3f236b1e29b0843edd6
2014-10-01 16:04:58 -07:00
Dmitriy Ivanov
f4cb631364 Add IFUNC support for arm64 and IRELATIVE reloc
There are number of changes in the way IFUNC related relocations are done:
 1. IRELATIVE relocations are now supported for x86/x86_64 and arm64.
 2. IFUNC relocations are now relying on static linker to generate
    them in correct order - this removes necessety of additional
    relocation pass for ifuncs.
 3. Related to 2: rela?.dyn relocations are preformed before .plt ones.
 4. Ifunc are resolved on symbol lookup this approach allowed to avoid
    mprotect(PROT_WRITE) call on r-x program segments.

Bug: 17399706
Bug: 17177284

(cherry picked from commit 9aea164457)

Change-Id: Ie19d900fc203beb93faf8943b0d06d534a6de4ad
2014-10-01 16:04:31 -07:00
Dmitriy Ivanov
ef1306d777 Refactoring: C++11 style DISABLE_ bionic marcos
Enable the -std=gnu++11 flag for libstdc++ static and
  dynamic libs.

  ScopeGuard uses DISABLE_ macros instead of '= delete';

(cherry picked from commit d9ff722661)

Change-Id: If2573d080770e18b36b56106f2369f7bb682cd3c
2014-10-01 16:03:51 -07:00
Dmitriy Ivanov
61c4147fa8 Reset enviroment for math_tests
Bug: 17390824

(cherry picked from commit 7b956ede3f)

Change-Id: I5d804ceb5e69533584161bfed6787529cd8296fb
2014-10-01 16:03:40 -07:00
Dmitriy Ivanov
ae69a9584b Load libraries in breadth-first order
This patch fixes the problem with symbol search order
  for dlsym(RTLD_DEFAULT/RTLD_NEXT, .) by loading libraries
  and ld_preloads in correct order.

Bug: https://code.google.com/p/android/issues/detail?id=74255
Attempt: 2

(cherry picked from commit 14669a939d)

Change-Id: Id87540c96a2242220967b6fa5d84ddcd829e2b97
2014-10-01 16:01:28 -07:00
Dmitriy Ivanov
c0133a73b6 Revert "Load libraries in breadth-first order"
This reverts commit a3ad450a2e.

(cherry picked from commit 498eb18b82)

Change-Id: Iec7eab83d0c0ed1604e1e8ea3f9e9d0ce1d29680
2014-10-01 16:00:52 -07:00
Dmitriy Ivanov
8de1ddece0 Fix order of soinfo links (repairs libcxx tests).
(cherry picked from commit b2a30ee8d2)

Change-Id: I59c5333bc050cbbea14051cea9220be2f64ee383
2014-10-01 16:00:41 -07:00
Dmitriy Ivanov
59c12a6527 Load libraries in breadth-first order
This patch fixes the problem with symbol search order
  for dlsym(RTLD_DEFAULT/RTLD_NEXT, .) by loading libraries
  and ld_preloads in correct order.

Bug: https://code.google.com/p/android/issues/detail?id=74255

(cherry picked from commit a3ad450a2e)

Change-Id: I1125de10272c84e4f075cbc72859c1f6b3e89943
2014-10-01 16:00:29 -07:00
Chih-Hung Hsieh
81fe2b16dc Enable clang compilation with libc but not linker.
Clang is still disabled for x86 and x86_64 long double code,
for x86_64 special assembly instruction, and the linker module.

BUG: 17163651
BUG: 17302991
BUG: 17403674

(cherry picked from commit b58db8b083)

Change-Id: I916c05056d37a9c287b0a5ae3b1a209d98c8f70e
2014-10-01 15:57:09 -07:00
Dmitriy Ivanov
7210c41fdc Encapsulate soinfo_link_image and soinfo_relocate
Also get rid of needed[] array for these functions

(cherry picked from commit 29bbc9dd4c)

Change-Id: Id208621f66afa2e02a6b3facacee7d874466d81b
2014-10-01 15:56:44 -07:00
Dmitriy Ivanov
4466bd72fb Implement LinkedList::visit()
(cherry picked from commit a492605849)

Change-Id: I59554be45c910bfe33494016595a5ade9daad230
2014-10-01 15:56:23 -07:00
Dmitriy Ivanov
ff01f6fcce Introduce size-based r/w allocators
(cherry picked from commit 0cd83ebb0e)

Change-Id: Ib037bd5313c9a78b6051482f14e789aa820b4dd1
2014-10-01 15:55:58 -07:00
Dmitriy Ivanov
4d01d08c29 Erase elements in LinkedList::remove_if
(cherry picked from commit 4bea498544)

Change-Id: I1ffe248bc2b7572f38fbd987e9c6db5ecbd4559d
2014-10-01 15:55:35 -07:00
Dmitriy Ivanov
cfad7ae934 Replace NULL with nullptr
(cherry picked from commit 851135bf99)

Change-Id: Ic4997907680db7472ef38ffb0f0ca66fff37b797
2014-10-01 15:54:26 -07:00
Dmitriy Ivanov
5dfe802d0d Remove unnecessary calls to LinkedList::clear()
(cherry picked from commit 608217e167)

Change-Id: I031359d79b2e77977ace197ef410e41539dc0ce6
2014-10-01 15:53:07 -07:00
Dmitriy Ivanov
93c3f4203c Enable __cxa_atexit && __cxa_finalize for linker
This allows adding destructors to classes used
 for global variables.

(cherry picked from commit 14241402de)

Change-Id: I1d8776130d1e01a8c53d23a2949f5010f4c96b16
2014-10-01 15:52:38 -07:00
Dmitriy Ivanov
3bbd218ef1 Bump soinfo version
This includes:
 1. Placing has_ifunc after fields with version = 0
 2. Switch to has_min_version(v) function.
 3. Minor soinfo initialization refactoring (placement new + ctor)

(cherry picked from commit 0d15094287)

Change-Id: Idf135fdd3d4826b5653f32add2adc6db5d4a4f95
2014-10-01 15:52:15 -07:00
Dmitriy Ivanov
bd321c1106 Run constructors before resolving ifunc functions
Bug: 17177284

(cherry picked from commit 9598b8c415)

Change-Id: I2c9631ee1cd77f8cf95ec0216a35b605c8786454
2014-10-01 15:51:47 -07:00
Brigid Smith
31b88da843 Added test for ifunc support in dynamic linker.
ifuncs now work in i386 and x86_64 when called in the same library as
well as in a different library.

Bug:6657325
(cherry picked from commit c5a13efa9b)

Change-Id: I321d780bc2f9bd1baa749e1acacd2683aefe827b
2014-10-01 15:50:38 -07:00
Elliott Hughes
e4f8962ab5 Merge "Update bionic to tzdata 2014h." into lmp-mr1-dev 2014-10-01 18:02:51 +00:00
Elliott Hughes
d18205049d Update bionic to tzdata 2014h.
From the release notes:

  Changes affecting past time stamps

    America/Jamaica's 1974 spring-forward transition was Jan. 6, not Apr. 28.

    Shanks says Asia/Novokuznetsk switched from LMT (not "NMT") on 1924-05-01,
    not 1920-01-06.  The old entry was based on a misinterpretation of Shanks.

    Some more zones have been turned into links, when they differed
    from existing zones only for older time stamps.  As usual,
    these changes affect UTC offsets in pre-1970 time stamps only.
    Their old contents have been moved to the 'backzone' file.
    The affected zones are: Africa/Blantyre, Africa/Bujumbura,
    Africa/Gaborone, Africa/Harare, Africa/Kigali, Africa/Lubumbashi,
    Africa/Lusaka, Africa/Maseru, and Africa/Mbabane.

Bug: 17731498

(cherry picked from commit 0c8fb51e6b)

Change-Id: Icf8a9cbd309951b4ffc20c74eb1e78c1e39c222f
2014-10-01 10:21:07 -07:00
Elliott Hughes
b5f5b0e418 Fix update-tzdata.py to rebuild icu4c .dat file.
Bug: 17731498

(cherry picked from commit f8896c6c93)

Change-Id: If97e1ccf593a2ed6c2356077e660d6fd88a05875
2014-10-01 10:07:24 -07:00
137 changed files with 5438 additions and 3569 deletions

View File

@@ -60,6 +60,8 @@ libc_common_src_files := \
bionic/siginterrupt.c \
bionic/sigsetmask.c \
bionic/system_properties_compat.c \
stdio/findfp.c \
stdio/fread.c \
stdio/snprintf.c\
stdio/sprintf.c \
@@ -389,14 +391,12 @@ libc_upstream_openbsd_src_files := \
upstream-openbsd/lib/libc/stdio/fgetwc.c \
upstream-openbsd/lib/libc/stdio/fgetws.c \
upstream-openbsd/lib/libc/stdio/fileno.c \
upstream-openbsd/lib/libc/stdio/findfp.c \
upstream-openbsd/lib/libc/stdio/fprintf.c \
upstream-openbsd/lib/libc/stdio/fpurge.c \
upstream-openbsd/lib/libc/stdio/fputc.c \
upstream-openbsd/lib/libc/stdio/fputs.c \
upstream-openbsd/lib/libc/stdio/fputwc.c \
upstream-openbsd/lib/libc/stdio/fputws.c \
upstream-openbsd/lib/libc/stdio/fread.c \
upstream-openbsd/lib/libc/stdio/freopen.c \
upstream-openbsd/lib/libc/stdio/fscanf.c \
upstream-openbsd/lib/libc/stdio/fseek.c \
@@ -503,7 +503,10 @@ ifneq ($(TARGET_USES_LOGD),false)
libc_common_cflags += -DTARGET_USES_LOGD
endif
use_clang := false
use_clang := $(USE_CLANG_PLATFORM_BUILD)
ifeq ($(use_clang),)
use_clang := false
endif
# Try to catch typical 32-bit assumptions that break with 64-bit pointers.
libc_common_cflags += \
@@ -689,6 +692,7 @@ LOCAL_ADDITIONAL_DEPENDENCIES := $(libc_common_additional_dependencies)
LOCAL_SYSTEM_SHARED_LIBRARIES :=
$(eval $(call patch-up-arch-specific-flags,LOCAL_CFLAGS,libc_common_cflags))
$(eval $(call patch-up-arch-specific-flags,LOCAL_SRC_FILES,libc_freebsd_src_files))
include $(BUILD_STATIC_LIBRARY)
@@ -733,6 +737,13 @@ include $(BUILD_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_SRC_FILES := $(libc_upstream_openbsd_src_files)
ifneq (,$(filter $(TARGET_ARCH),x86 x86_64))
# Clang has wrong long double size or LDBL_MANT_DIG, http://b/17163651.
LOCAL_CLANG := false
else
LOCAL_CLANG := $(use_clang)
endif
LOCAL_CFLAGS := \
$(libc_common_cflags) \
-Wno-sign-compare -Wno-uninitialized -Wno-unused-parameter \
@@ -746,11 +757,11 @@ LOCAL_CONLYFLAGS := $(libc_common_conlyflags)
LOCAL_CPPFLAGS := $(libc_common_cppflags)
LOCAL_C_INCLUDES := $(libc_common_c_includes)
LOCAL_MODULE := libc_openbsd
LOCAL_CLANG := $(use_clang)
LOCAL_ADDITIONAL_DEPENDENCIES := $(libc_common_additional_dependencies)
LOCAL_SYSTEM_SHARED_LIBRARIES :=
$(eval $(call patch-up-arch-specific-flags,LOCAL_CFLAGS,libc_common_cflags))
$(eval $(call patch-up-arch-specific-flags,LOCAL_SRC_FILES,libc_openbsd_src_files))
include $(BUILD_STATIC_LIBRARY)
@@ -765,6 +776,13 @@ include $(CLEAR_VARS)
LOCAL_SRC_FILES_32 := $(libc_upstream_openbsd_gdtoa_src_files_32)
LOCAL_SRC_FILES_64 := $(libc_upstream_openbsd_gdtoa_src_files_64)
ifneq (,$(filter $(TARGET_ARCH),x86 x86_64))
# Clang has wrong long double size or LDBL_MANT_DIG, http://b/17163651.
LOCAL_CLANG := false
else
LOCAL_CLANG := $(use_clang)
endif
LOCAL_CFLAGS := \
$(libc_common_cflags) \
-Wno-sign-compare -Wno-uninitialized \
@@ -778,7 +796,6 @@ LOCAL_CONLYFLAGS := $(libc_common_conlyflags)
LOCAL_CPPFLAGS := $(libc_common_cppflags)
LOCAL_C_INCLUDES := $(libc_common_c_includes)
LOCAL_MODULE := libc_gdtoa
LOCAL_CLANG := $(use_clang)
LOCAL_ADDITIONAL_DEPENDENCIES := $(libc_common_additional_dependencies)
LOCAL_SYSTEM_SHARED_LIBRARIES :=
@@ -796,6 +813,11 @@ LOCAL_SRC_FILES := $(libc_bionic_src_files)
LOCAL_CFLAGS := $(libc_common_cflags) \
-Wframe-larger-than=2048 \
ifeq ($(TARGET_ARCH),x86_64)
# Clang assembler has problem with ssse3-strcmp-slm.S, http://b/17302991
LOCAL_CLANG_ASFLAGS += -no-integrated-as
endif
LOCAL_CONLYFLAGS := $(libc_common_conlyflags)
LOCAL_CPPFLAGS := $(libc_common_cppflags)
LOCAL_C_INCLUDES := $(libc_common_c_includes)
@@ -1144,6 +1166,7 @@ libstdcxx_common_src_files := \
include $(CLEAR_VARS)
LOCAL_C_INCLUDES := $(libc_common_c_includes)
LOCAL_CFLAGS := $(libc_common_cflags)
LOCAL_CPPFLAGS := $(libc_common_cppflags)
LOCAL_SRC_FILES := $(libstdcxx_common_src_files)
LOCAL_MODULE:= libstdc++
LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
@@ -1156,6 +1179,7 @@ include $(BUILD_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_C_INCLUDES := $(libc_common_c_includes)
LOCAL_CFLAGS := $(libc_common_cflags)
LOCAL_CPPFLAGS := $(libc_common_cppflags)
LOCAL_SRC_FILES := $(libstdcxx_common_src_files)
LOCAL_MODULE:= libstdc++
LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk

View File

@@ -1,22 +1,35 @@
# arm specific configs
# 32-bit arm.
# These are used by the 32-bit targets, but not the 64-bit ones.
libc_common_src_files_arm := \
#
# Various kinds of LP32 cruft.
#
libc_bionic_src_files_arm += \
bionic/mmap.cpp \
libc_common_src_files_arm += \
bionic/legacy_32_bit_support.cpp \
bionic/ndk_cruft.cpp \
bionic/time64.c \
libc_netbsd_src_files_arm += \
upstream-netbsd/common/lib/libc/hash/sha1/sha1.c \
libc_openbsd_src_files_arm += \
upstream-openbsd/lib/libc/stdio/putw.c \
# These are shared by all the 32-bit targets, but not the 64-bit ones.
libc_bionic_src_files_arm := \
bionic/mmap.cpp
#
# Default implementations of functions that are commonly optimized.
#
libc_common_src_files_arm += \
libc_bionic_src_files_arm += \
bionic/memchr.c \
bionic/memrchr.c \
bionic/strchr.cpp \
bionic/strnlen.c \
bionic/strrchr.cpp \
libc_freebsd_src_files_arm += \
upstream-freebsd/lib/libc/string/wcscat.c \
upstream-freebsd/lib/libc/string/wcschr.c \
upstream-freebsd/lib/libc/string/wcscmp.c \
@@ -25,8 +38,9 @@ libc_common_src_files_arm += \
upstream-freebsd/lib/libc/string/wcsrchr.c \
upstream-freebsd/lib/libc/string/wmemcmp.c \
upstream-freebsd/lib/libc/string/wmemmove.c \
libc_openbsd_src_files_arm += \
upstream-openbsd/lib/libc/string/bcopy.c \
upstream-openbsd/lib/libc/string/stpcpy.c \
upstream-openbsd/lib/libc/string/stpncpy.c \
upstream-openbsd/lib/libc/string/strlcat.c \
upstream-openbsd/lib/libc/string/strlcpy.c \
@@ -34,20 +48,10 @@ libc_common_src_files_arm += \
upstream-openbsd/lib/libc/string/strncmp.c \
upstream-openbsd/lib/libc/string/strncpy.c \
# The C++ fortify function implementations for which there is an
# arm assembler version.
#
# Fortify implementations of libc functions.
# libc_common_src_files_arm +=
# bionic/__memcpy_chk.cpp \
# bionic/__memset_chk.cpp \
# bionic/__strcpy_chk.cpp \
# bionic/__strcat_chk.cpp \
# Inherently architecture-specific code.
#
libc_common_cflags_arm := -DSOFTFLOAT
##########################################
### CPU specific source files
libc_bionic_src_files_arm += \
arch-arm/bionic/abort_arm.S \
arch-arm/bionic/atomics_arm.c \
@@ -55,6 +59,7 @@ libc_bionic_src_files_arm += \
arch-arm/bionic/_exit_with_stack_teardown.S \
arch-arm/bionic/libgcc_compat.c \
arch-arm/bionic/memcmp.S \
arch-arm/bionic/__restore.S \
arch-arm/bionic/_setjmp.S \
arch-arm/bionic/setjmp.S \
arch-arm/bionic/sigsetjmp.S \
@@ -63,9 +68,6 @@ libc_bionic_src_files_arm += \
libc_arch_static_src_files_arm := arch-arm/bionic/exidx_static.c
libc_arch_dynamic_src_files_arm := arch-arm/bionic/exidx_dynamic.c
libc_netbsd_src_files_arm := \
upstream-netbsd/common/lib/libc/hash/sha1/sha1.c \
## CPU variant specific source files
ifeq ($(strip $(TARGET_$(my_2nd_arch_prefix)CPU_VARIANT)),)
$(warning TARGET_$(my_2nd_arch_prefix)ARCH is arm, but TARGET_$(my_2nd_arch_prefix)CPU_VARIANT is not defined)

View File

@@ -0,0 +1,61 @@
/*
* Copyright (C) 2014 The Android Open Source Project
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <private/bionic_asm.h>
// gdb is smart enough to unwind through signal frames with just the regular
// CFI information but libgcc and libunwind both need extra help. We do this
// by using .fnstart/.fnend and inserting a nop before both __restore and
// __restore_rt (but covered by the .fnstart/.fnend) so that although they're
// not inside the functions from objdump's point of view, an unwinder that
// blindly looks at the previous instruction (but is then smart enough to check
// the DWARF information to find out where it landed) gets the right answer.
// We need to place .fnstart ourselves (but we may as well keep the free .fnend).
#undef __bionic_asm_custom_entry
#define __bionic_asm_custom_entry(f)
.fnstart
.save {r0-r15}
.pad #32
nop
ENTRY_PRIVATE(__restore)
// This function must have exactly this instruction sequence.
mov r7, #__NR_sigreturn
swi #0
END(__restore)
.fnstart
.save {r0-r15}
.pad #160
nop
ENTRY_PRIVATE(__restore_rt)
// This function must have exactly this instruction sequence.
mov r7, #__NR_rt_sigreturn
swi #0
END(__restore_rt)

View File

@@ -40,12 +40,10 @@
ENTRY(__strcat_chk)
pld [r0, #0]
push {r0, lr}
.save {r0, lr}
.cfi_def_cfa_offset 8
.cfi_rel_offset r0, 0
.cfi_rel_offset lr, 4
push {r4, r5}
.save {r4, r5}
.cfi_adjust_cfa_offset 8
.cfi_rel_offset r4, 0
.cfi_rel_offset r5, 4
@@ -195,9 +193,6 @@ END(__strcat_chk)
#include "memcpy_base.S"
ENTRY_PRIVATE(__strcat_chk_failed)
.save {r0, lr}
.save {r4, r5}
.cfi_def_cfa_offset 8
.cfi_rel_offset r0, 0
.cfi_rel_offset lr, 4

View File

@@ -39,7 +39,6 @@
ENTRY(__strcpy_chk)
pld [r0, #0]
push {r0, lr}
.save {r0, lr}
.cfi_def_cfa_offset 8
.cfi_rel_offset r0, 0
.cfi_rel_offset lr, 4
@@ -161,7 +160,6 @@ END(__strcpy_chk)
#include "memcpy_base.S"
ENTRY_PRIVATE(__strcpy_chk_failed)
.save {r0, lr}
.cfi_def_cfa_offset 8
.cfi_rel_offset r0, 0
.cfi_rel_offset lr, 4

View File

@@ -72,7 +72,6 @@ END(__memcpy_chk)
ENTRY(memcpy)
pld [r1, #64]
push {r0, lr}
.save {r0, lr}
.cfi_def_cfa_offset 8
.cfi_rel_offset r0, 0
.cfi_rel_offset lr, 4
@@ -85,7 +84,6 @@ END(memcpy)
ENTRY_PRIVATE(__memcpy_chk_fail)
// Preserve lr for backtrace.
push {lr}
.save {lr}
.cfi_def_cfa_offset 4
.cfi_rel_offset lr, 0

View File

@@ -54,7 +54,6 @@
*/
ENTRY_PRIVATE(MEMCPY_BASE)
.save {r0, lr}
.cfi_def_cfa_offset 8
.cfi_rel_offset r0, 0
.cfi_rel_offset lr, 4
@@ -172,7 +171,6 @@ ENTRY_PRIVATE(MEMCPY_BASE)
END(MEMCPY_BASE)
ENTRY_PRIVATE(MEMCPY_BASE_ALIGNED)
.save {r0, lr}
.cfi_def_cfa_offset 8
.cfi_rel_offset r0, 0
.cfi_rel_offset lr, 4
@@ -181,17 +179,14 @@ ENTRY_PRIVATE(MEMCPY_BASE_ALIGNED)
// i.e., not keeping the stack looking like users expect
// (highest numbered register at highest address).
strd r4, r5, [sp, #-8]!
.save {r4, r5}
.cfi_adjust_cfa_offset 8
.cfi_rel_offset r4, 0
.cfi_rel_offset r5, 4
strd r6, r7, [sp, #-8]!
.save {r6, r7}
.cfi_adjust_cfa_offset 8
.cfi_rel_offset r6, 0
.cfi_rel_offset r7, 0
strd r8, r9, [sp, #-8]!
.save {r8, r9}
.cfi_adjust_cfa_offset 8
.cfi_rel_offset r8, 0
.cfi_rel_offset r9, 4

View File

@@ -44,7 +44,6 @@ ENTRY(__memset_chk)
bls .L_done
// Preserve lr for backtrace.
.save {lr}
push {lr}
.cfi_def_cfa_offset 4
.cfi_rel_offset lr, 0
@@ -68,7 +67,6 @@ ENTRY(bzero)
END(bzero)
ENTRY(memset)
.save {r0}
stmfd sp!, {r0}
.cfi_def_cfa_offset 4
.cfi_rel_offset r0, 0

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2013 The Android Open Source Project
* Copyright (C) 2014 The Android Open Source Project
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -26,9 +26,5 @@
* SUCH DAMAGE.
*/
#include <private/bionic_asm.h>
ENTRY_PRIVATE(__rt_sigreturn)
movl $__NR_rt_sigreturn, %eax
syscall
END(__rt_sigreturn)
#define STPCPY
#include "string_copy.S"

View File

@@ -168,7 +168,6 @@ ENTRY(strcmp)
bne .L_do_align
/* Fast path. */
.save {r4-r7}
init
.L_doubleword_aligned:

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2013 The Android Open Source Project
* Copyright (C) 2014 The Android Open Source Project
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -25,427 +25,6 @@
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
/*
* Copyright (c) 2013 ARM Ltd
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the company may not be used to endorse or promote
* products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY ARM LTD ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL ARM LTD BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <private/bionic_asm.h>
.syntax unified
.thumb
.thumb_func
.macro m_push
push {r0, r4, r5, lr}
.endm // m_push
.macro m_pop
pop {r0, r4, r5, pc}
.endm // m_pop
.macro m_copy_byte reg, cmd, label
ldrb \reg, [r1], #1
strb \reg, [r0], #1
\cmd \reg, \label
.endm // m_copy_byte
ENTRY(strcpy)
// For short copies, hard-code checking the first 8 bytes since this
// new code doesn't win until after about 8 bytes.
m_push
m_copy_byte reg=r2, cmd=cbz, label=strcpy_finish
m_copy_byte reg=r3, cmd=cbz, label=strcpy_finish
m_copy_byte reg=r4, cmd=cbz, label=strcpy_finish
m_copy_byte reg=r5, cmd=cbz, label=strcpy_finish
m_copy_byte reg=r2, cmd=cbz, label=strcpy_finish
m_copy_byte reg=r3, cmd=cbz, label=strcpy_finish
m_copy_byte reg=r4, cmd=cbz, label=strcpy_finish
m_copy_byte reg=r5, cmd=cbnz, label=strcpy_continue
strcpy_finish:
m_pop
strcpy_continue:
pld [r1, #0]
ands r3, r0, #7
beq strcpy_check_src_align
// Align to a double word (64 bits).
rsb r3, r3, #8
lsls ip, r3, #31
beq strcpy_align_to_32
ldrb r2, [r1], #1
strb r2, [r0], #1
cbz r2, strcpy_complete
strcpy_align_to_32:
bcc strcpy_align_to_64
ldrb r2, [r1], #1
strb r2, [r0], #1
cbz r2, strcpy_complete
ldrb r2, [r1], #1
strb r2, [r0], #1
cbz r2, strcpy_complete
strcpy_align_to_64:
tst r3, #4
beq strcpy_check_src_align
ldr r2, [r1], #4
sub ip, r2, #0x01010101
bic ip, ip, r2
ands ip, ip, #0x80808080
bne strcpy_zero_in_first_register
str r2, [r0], #4
strcpy_check_src_align:
// At this point dst is aligned to a double word, check if src
// is also aligned to a double word.
ands r3, r1, #7
bne strcpy_unaligned_copy
.p2align 2
strcpy_mainloop:
ldrd r2, r3, [r1], #8
pld [r1, #64]
sub ip, r2, #0x01010101
bic ip, ip, r2
ands ip, ip, #0x80808080
bne strcpy_zero_in_first_register
sub ip, r3, #0x01010101
bic ip, ip, r3
ands ip, ip, #0x80808080
bne strcpy_zero_in_second_register
strd r2, r3, [r0], #8
b strcpy_mainloop
strcpy_complete:
m_pop
strcpy_zero_in_first_register:
lsls lr, ip, #17
bne strcpy_copy1byte
bcs strcpy_copy2bytes
lsls ip, ip, #1
bne strcpy_copy3bytes
strcpy_copy4bytes:
// Copy 4 bytes to the destiniation.
str r2, [r0]
m_pop
strcpy_copy1byte:
strb r2, [r0]
m_pop
strcpy_copy2bytes:
strh r2, [r0]
m_pop
strcpy_copy3bytes:
strh r2, [r0], #2
lsr r2, #16
strb r2, [r0]
m_pop
strcpy_zero_in_second_register:
lsls lr, ip, #17
bne strcpy_copy5bytes
bcs strcpy_copy6bytes
lsls ip, ip, #1
bne strcpy_copy7bytes
// Copy 8 bytes to the destination.
strd r2, r3, [r0]
m_pop
strcpy_copy5bytes:
str r2, [r0], #4
strb r3, [r0]
m_pop
strcpy_copy6bytes:
str r2, [r0], #4
strh r3, [r0]
m_pop
strcpy_copy7bytes:
str r2, [r0], #4
strh r3, [r0], #2
lsr r3, #16
strb r3, [r0]
m_pop
strcpy_unaligned_copy:
// Dst is aligned to a double word, while src is at an unknown alignment.
// There are 7 different versions of the unaligned copy code
// to prevent overreading the src. The mainloop of every single version
// will store 64 bits per loop. The difference is how much of src can
// be read without potentially crossing a page boundary.
tbb [pc, r3]
strcpy_unaligned_branchtable:
.byte 0
.byte ((strcpy_unalign7 - strcpy_unaligned_branchtable)/2)
.byte ((strcpy_unalign6 - strcpy_unaligned_branchtable)/2)
.byte ((strcpy_unalign5 - strcpy_unaligned_branchtable)/2)
.byte ((strcpy_unalign4 - strcpy_unaligned_branchtable)/2)
.byte ((strcpy_unalign3 - strcpy_unaligned_branchtable)/2)
.byte ((strcpy_unalign2 - strcpy_unaligned_branchtable)/2)
.byte ((strcpy_unalign1 - strcpy_unaligned_branchtable)/2)
.p2align 2
// Can read 7 bytes before possibly crossing a page.
strcpy_unalign7:
ldr r2, [r1], #4
sub ip, r2, #0x01010101
bic ip, ip, r2
ands ip, ip, #0x80808080
bne strcpy_zero_in_first_register
ldrb r3, [r1]
cbz r3, strcpy_unalign7_copy5bytes
ldrb r4, [r1, #1]
cbz r4, strcpy_unalign7_copy6bytes
ldrb r5, [r1, #2]
cbz r5, strcpy_unalign7_copy7bytes
ldr r3, [r1], #4
pld [r1, #64]
lsrs ip, r3, #24
strd r2, r3, [r0], #8
beq strcpy_unalign_return
b strcpy_unalign7
strcpy_unalign7_copy5bytes:
str r2, [r0], #4
strb r3, [r0]
strcpy_unalign_return:
m_pop
strcpy_unalign7_copy6bytes:
str r2, [r0], #4
strb r3, [r0], #1
strb r4, [r0], #1
m_pop
strcpy_unalign7_copy7bytes:
str r2, [r0], #4
strb r3, [r0], #1
strb r4, [r0], #1
strb r5, [r0], #1
m_pop
.p2align 2
// Can read 6 bytes before possibly crossing a page.
strcpy_unalign6:
ldr r2, [r1], #4
sub ip, r2, #0x01010101
bic ip, ip, r2
ands ip, ip, #0x80808080
bne strcpy_zero_in_first_register
ldrb r4, [r1]
cbz r4, strcpy_unalign_copy5bytes
ldrb r5, [r1, #1]
cbz r5, strcpy_unalign_copy6bytes
ldr r3, [r1], #4
pld [r1, #64]
tst r3, #0xff0000
beq strcpy_copy7bytes
lsrs ip, r3, #24
strd r2, r3, [r0], #8
beq strcpy_unalign_return
b strcpy_unalign6
.p2align 2
// Can read 5 bytes before possibly crossing a page.
strcpy_unalign5:
ldr r2, [r1], #4
sub ip, r2, #0x01010101
bic ip, ip, r2
ands ip, ip, #0x80808080
bne strcpy_zero_in_first_register
ldrb r4, [r1]
cbz r4, strcpy_unalign_copy5bytes
ldr r3, [r1], #4
pld [r1, #64]
sub ip, r3, #0x01010101
bic ip, ip, r3
ands ip, ip, #0x80808080
bne strcpy_zero_in_second_register
strd r2, r3, [r0], #8
b strcpy_unalign5
strcpy_unalign_copy5bytes:
str r2, [r0], #4
strb r4, [r0]
m_pop
strcpy_unalign_copy6bytes:
str r2, [r0], #4
strb r4, [r0], #1
strb r5, [r0]
m_pop
.p2align 2
// Can read 4 bytes before possibly crossing a page.
strcpy_unalign4:
ldr r2, [r1], #4
sub ip, r2, #0x01010101
bic ip, ip, r2
ands ip, ip, #0x80808080
bne strcpy_zero_in_first_register
ldr r3, [r1], #4
pld [r1, #64]
sub ip, r3, #0x01010101
bic ip, ip, r3
ands ip, ip, #0x80808080
bne strcpy_zero_in_second_register
strd r2, r3, [r0], #8
b strcpy_unalign4
.p2align 2
// Can read 3 bytes before possibly crossing a page.
strcpy_unalign3:
ldrb r2, [r1]
cbz r2, strcpy_unalign3_copy1byte
ldrb r3, [r1, #1]
cbz r3, strcpy_unalign3_copy2bytes
ldrb r4, [r1, #2]
cbz r4, strcpy_unalign3_copy3bytes
ldr r2, [r1], #4
ldr r3, [r1], #4
pld [r1, #64]
lsrs lr, r2, #24
beq strcpy_copy4bytes
sub ip, r3, #0x01010101
bic ip, ip, r3
ands ip, ip, #0x80808080
bne strcpy_zero_in_second_register
strd r2, r3, [r0], #8
b strcpy_unalign3
strcpy_unalign3_copy1byte:
strb r2, [r0]
m_pop
strcpy_unalign3_copy2bytes:
strb r2, [r0], #1
strb r3, [r0]
m_pop
strcpy_unalign3_copy3bytes:
strb r2, [r0], #1
strb r3, [r0], #1
strb r4, [r0]
m_pop
.p2align 2
// Can read 2 bytes before possibly crossing a page.
strcpy_unalign2:
ldrb r2, [r1]
cbz r2, strcpy_unalign_copy1byte
ldrb r4, [r1, #1]
cbz r4, strcpy_unalign_copy2bytes
ldr r2, [r1], #4
ldr r3, [r1], #4
pld [r1, #64]
tst r2, #0xff0000
beq strcpy_copy3bytes
lsrs ip, r2, #24
beq strcpy_copy4bytes
sub ip, r3, #0x01010101
bic ip, ip, r3
ands ip, ip, #0x80808080
bne strcpy_zero_in_second_register
strd r2, r3, [r0], #8
b strcpy_unalign2
.p2align 2
// Can read 1 byte before possibly crossing a page.
strcpy_unalign1:
ldrb r2, [r1]
cbz r2, strcpy_unalign_copy1byte
ldr r2, [r1], #4
ldr r3, [r1], #4
pld [r1, #64]
sub ip, r2, #0x01010101
bic ip, ip, r2
ands ip, ip, #0x80808080
bne strcpy_zero_in_first_register
sub ip, r3, #0x01010101
bic ip, ip, r3
ands ip, ip, #0x80808080
bne strcpy_zero_in_second_register
strd r2, r3, [r0], #8
b strcpy_unalign1
strcpy_unalign_copy1byte:
strb r2, [r0]
m_pop
strcpy_unalign_copy2bytes:
strb r2, [r0], #1
strb r4, [r0]
m_pop
END(strcpy)
#define STRCPY
#include "string_copy.S"

View File

@@ -0,0 +1,513 @@
/*
* Copyright (C) 2013 The Android Open Source Project
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
/*
* Copyright (c) 2013 ARM Ltd
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the company may not be used to endorse or promote
* products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY ARM LTD ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL ARM LTD BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#if !defined(STPCPY) && !defined(STRCPY)
#error "Either STPCPY or STRCPY must be defined."
#endif
#include <private/bionic_asm.h>
.syntax unified
.thumb
.thumb_func
#if defined(STPCPY)
.macro m_push
push {r4, r5, lr}
.cfi_def_cfa_offset 12
.cfi_rel_offset r4, 0
.cfi_rel_offset r5, 4
.cfi_rel_offset lr, 8
.endm // m_push
#else
.macro m_push
push {r0, r4, r5, lr}
.cfi_def_cfa_offset 16
.cfi_rel_offset r0, 0
.cfi_rel_offset r4, 4
.cfi_rel_offset r5, 8
.cfi_rel_offset lr, 12
.endm // m_push
#endif
#if defined(STPCPY)
.macro m_pop
pop {r4, r5, pc}
.endm // m_pop
#else
.macro m_pop
pop {r0, r4, r5, pc}
.endm // m_pop
#endif
.macro m_copy_byte reg, cmd, label
ldrb \reg, [r1], #1
strb \reg, [r0], #1
\cmd \reg, \label
.endm // m_copy_byte
#if defined(STPCPY)
ENTRY(stpcpy)
#else
ENTRY(strcpy)
#endif
// For short copies, hard-code checking the first 8 bytes since this
// new code doesn't win until after about 8 bytes.
m_push
m_copy_byte reg=r2, cmd=cbz, label=.Lstringcopy_finish
m_copy_byte reg=r3, cmd=cbz, label=.Lstringcopy_finish
m_copy_byte reg=r4, cmd=cbz, label=.Lstringcopy_finish
m_copy_byte reg=r5, cmd=cbz, label=.Lstringcopy_finish
m_copy_byte reg=r2, cmd=cbz, label=.Lstringcopy_finish
m_copy_byte reg=r3, cmd=cbz, label=.Lstringcopy_finish
m_copy_byte reg=r4, cmd=cbz, label=.Lstringcopy_finish
m_copy_byte reg=r5, cmd=cbnz, label=.Lstringcopy_continue
.Lstringcopy_finish:
#if defined(STPCPY)
sub r0, r0, #1
#endif
m_pop
.Lstringcopy_continue:
pld [r1, #0]
ands r3, r0, #7
beq .Lstringcopy_check_src_align
// Align to a double word (64 bits).
rsb r3, r3, #8
lsls ip, r3, #31
beq .Lstringcopy_align_to_32
ldrb r2, [r1], #1
strb r2, [r0], #1
cbz r2, .Lstringcopy_complete
.Lstringcopy_align_to_32:
bcc .Lstringcopy_align_to_64
ldrb r2, [r1], #1
strb r2, [r0], #1
cbz r2, .Lstringcopy_complete
ldrb r2, [r1], #1
strb r2, [r0], #1
cbz r2, .Lstringcopy_complete
.Lstringcopy_align_to_64:
tst r3, #4
beq .Lstringcopy_check_src_align
ldr r2, [r1], #4
sub ip, r2, #0x01010101
bic ip, ip, r2
ands ip, ip, #0x80808080
bne .Lstringcopy_zero_in_first_register
str r2, [r0], #4
.Lstringcopy_check_src_align:
// At this point dst is aligned to a double word, check if src
// is also aligned to a double word.
ands r3, r1, #7
bne .Lstringcopy_unaligned_copy
.p2align 2
.Lstringcopy_mainloop:
ldrd r2, r3, [r1], #8
pld [r1, #64]
sub ip, r2, #0x01010101
bic ip, ip, r2
ands ip, ip, #0x80808080
bne .Lstringcopy_zero_in_first_register
sub ip, r3, #0x01010101
bic ip, ip, r3
ands ip, ip, #0x80808080
bne .Lstringcopy_zero_in_second_register
strd r2, r3, [r0], #8
b .Lstringcopy_mainloop
.Lstringcopy_complete:
#if defined(STPCPY)
sub r0, r0, #1
#endif
m_pop
.Lstringcopy_zero_in_first_register:
lsls lr, ip, #17
bne .Lstringcopy_copy1byte
bcs .Lstringcopy_copy2bytes
lsls ip, ip, #1
bne .Lstringcopy_copy3bytes
.Lstringcopy_copy4bytes:
// Copy 4 bytes to the destiniation.
#if defined(STPCPY)
str r2, [r0], #3
#else
str r2, [r0]
#endif
m_pop
.Lstringcopy_copy1byte:
strb r2, [r0]
m_pop
.Lstringcopy_copy2bytes:
#if defined(STPCPY)
strh r2, [r0], #1
#else
strh r2, [r0]
#endif
m_pop
.Lstringcopy_copy3bytes:
strh r2, [r0], #2
lsr r2, #16
strb r2, [r0]
m_pop
.Lstringcopy_zero_in_second_register:
lsls lr, ip, #17
bne .Lstringcopy_copy5bytes
bcs .Lstringcopy_copy6bytes
lsls ip, ip, #1
bne .Lstringcopy_copy7bytes
// Copy 8 bytes to the destination.
strd r2, r3, [r0]
#if defined(STPCPY)
add r0, r0, #7
#endif
m_pop
.Lstringcopy_copy5bytes:
str r2, [r0], #4
strb r3, [r0]
m_pop
.Lstringcopy_copy6bytes:
str r2, [r0], #4
#if defined(STPCPY)
strh r3, [r0], #1
#else
strh r3, [r0]
#endif
m_pop
.Lstringcopy_copy7bytes:
str r2, [r0], #4
strh r3, [r0], #2
lsr r3, #16
strb r3, [r0]
m_pop
.Lstringcopy_unaligned_copy:
// Dst is aligned to a double word, while src is at an unknown alignment.
// There are 7 different versions of the unaligned copy code
// to prevent overreading the src. The mainloop of every single version
// will store 64 bits per loop. The difference is how much of src can
// be read without potentially crossing a page boundary.
tbb [pc, r3]
.Lstringcopy_unaligned_branchtable:
.byte 0
.byte ((.Lstringcopy_unalign7 - .Lstringcopy_unaligned_branchtable)/2)
.byte ((.Lstringcopy_unalign6 - .Lstringcopy_unaligned_branchtable)/2)
.byte ((.Lstringcopy_unalign5 - .Lstringcopy_unaligned_branchtable)/2)
.byte ((.Lstringcopy_unalign4 - .Lstringcopy_unaligned_branchtable)/2)
.byte ((.Lstringcopy_unalign3 - .Lstringcopy_unaligned_branchtable)/2)
.byte ((.Lstringcopy_unalign2 - .Lstringcopy_unaligned_branchtable)/2)
.byte ((.Lstringcopy_unalign1 - .Lstringcopy_unaligned_branchtable)/2)
.p2align 2
// Can read 7 bytes before possibly crossing a page.
.Lstringcopy_unalign7:
ldr r2, [r1], #4
sub ip, r2, #0x01010101
bic ip, ip, r2
ands ip, ip, #0x80808080
bne .Lstringcopy_zero_in_first_register
ldrb r3, [r1]
cbz r3, .Lstringcopy_unalign7_copy5bytes
ldrb r4, [r1, #1]
cbz r4, .Lstringcopy_unalign7_copy6bytes
ldrb r5, [r1, #2]
cbz r5, .Lstringcopy_unalign7_copy7bytes
ldr r3, [r1], #4
pld [r1, #64]
lsrs ip, r3, #24
strd r2, r3, [r0], #8
#if defined(STPCPY)
beq .Lstringcopy_finish
#else
beq .Lstringcopy_unalign_return
#endif
b .Lstringcopy_unalign7
.Lstringcopy_unalign7_copy5bytes:
str r2, [r0], #4
strb r3, [r0]
.Lstringcopy_unalign_return:
m_pop
.Lstringcopy_unalign7_copy6bytes:
str r2, [r0], #4
strb r3, [r0], #1
strb r4, [r0]
m_pop
.Lstringcopy_unalign7_copy7bytes:
str r2, [r0], #4
strb r3, [r0], #1
strb r4, [r0], #1
strb r5, [r0]
m_pop
.p2align 2
// Can read 6 bytes before possibly crossing a page.
.Lstringcopy_unalign6:
ldr r2, [r1], #4
sub ip, r2, #0x01010101
bic ip, ip, r2
ands ip, ip, #0x80808080
bne .Lstringcopy_zero_in_first_register
ldrb r4, [r1]
cbz r4, .Lstringcopy_unalign_copy5bytes
ldrb r5, [r1, #1]
cbz r5, .Lstringcopy_unalign_copy6bytes
ldr r3, [r1], #4
pld [r1, #64]
tst r3, #0xff0000
beq .Lstringcopy_copy7bytes
lsrs ip, r3, #24
strd r2, r3, [r0], #8
#if defined(STPCPY)
beq .Lstringcopy_finish
#else
beq .Lstringcopy_unalign_return
#endif
b .Lstringcopy_unalign6
.p2align 2
// Can read 5 bytes before possibly crossing a page.
.Lstringcopy_unalign5:
ldr r2, [r1], #4
sub ip, r2, #0x01010101
bic ip, ip, r2
ands ip, ip, #0x80808080
bne .Lstringcopy_zero_in_first_register
ldrb r4, [r1]
cbz r4, .Lstringcopy_unalign_copy5bytes
ldr r3, [r1], #4
pld [r1, #64]
sub ip, r3, #0x01010101
bic ip, ip, r3
ands ip, ip, #0x80808080
bne .Lstringcopy_zero_in_second_register
strd r2, r3, [r0], #8
b .Lstringcopy_unalign5
.Lstringcopy_unalign_copy5bytes:
str r2, [r0], #4
strb r4, [r0]
m_pop
.Lstringcopy_unalign_copy6bytes:
str r2, [r0], #4
strb r4, [r0], #1
strb r5, [r0]
m_pop
.p2align 2
// Can read 4 bytes before possibly crossing a page.
.Lstringcopy_unalign4:
ldr r2, [r1], #4
sub ip, r2, #0x01010101
bic ip, ip, r2
ands ip, ip, #0x80808080
bne .Lstringcopy_zero_in_first_register
ldr r3, [r1], #4
pld [r1, #64]
sub ip, r3, #0x01010101
bic ip, ip, r3
ands ip, ip, #0x80808080
bne .Lstringcopy_zero_in_second_register
strd r2, r3, [r0], #8
b .Lstringcopy_unalign4
.p2align 2
// Can read 3 bytes before possibly crossing a page.
.Lstringcopy_unalign3:
ldrb r2, [r1]
cbz r2, .Lstringcopy_unalign3_copy1byte
ldrb r3, [r1, #1]
cbz r3, .Lstringcopy_unalign3_copy2bytes
ldrb r4, [r1, #2]
cbz r4, .Lstringcopy_unalign3_copy3bytes
ldr r2, [r1], #4
ldr r3, [r1], #4
pld [r1, #64]
lsrs lr, r2, #24
beq .Lstringcopy_copy4bytes
sub ip, r3, #0x01010101
bic ip, ip, r3
ands ip, ip, #0x80808080
bne .Lstringcopy_zero_in_second_register
strd r2, r3, [r0], #8
b .Lstringcopy_unalign3
.Lstringcopy_unalign3_copy1byte:
strb r2, [r0]
m_pop
.Lstringcopy_unalign3_copy2bytes:
strb r2, [r0], #1
strb r3, [r0]
m_pop
.Lstringcopy_unalign3_copy3bytes:
strb r2, [r0], #1
strb r3, [r0], #1
strb r4, [r0]
m_pop
.p2align 2
// Can read 2 bytes before possibly crossing a page.
.Lstringcopy_unalign2:
ldrb r2, [r1]
cbz r2, .Lstringcopy_unalign_copy1byte
ldrb r4, [r1, #1]
cbz r4, .Lstringcopy_unalign_copy2bytes
ldr r2, [r1], #4
ldr r3, [r1], #4
pld [r1, #64]
tst r2, #0xff0000
beq .Lstringcopy_copy3bytes
lsrs ip, r2, #24
beq .Lstringcopy_copy4bytes
sub ip, r3, #0x01010101
bic ip, ip, r3
ands ip, ip, #0x80808080
bne .Lstringcopy_zero_in_second_register
strd r2, r3, [r0], #8
b .Lstringcopy_unalign2
.p2align 2
// Can read 1 byte before possibly crossing a page.
.Lstringcopy_unalign1:
ldrb r2, [r1]
cbz r2, .Lstringcopy_unalign_copy1byte
ldr r2, [r1], #4
ldr r3, [r1], #4
pld [r1, #64]
sub ip, r2, #0x01010101
bic ip, ip, r2
ands ip, ip, #0x80808080
bne .Lstringcopy_zero_in_first_register
sub ip, r3, #0x01010101
bic ip, ip, r3
ands ip, ip, #0x80808080
bne .Lstringcopy_zero_in_second_register
strd r2, r3, [r0], #8
b .Lstringcopy_unalign1
.Lstringcopy_unalign_copy1byte:
strb r2, [r0]
m_pop
.Lstringcopy_unalign_copy2bytes:
strb r2, [r0], #1
strb r4, [r0]
m_pop
#if defined(STPCPY)
END(stpcpy)
#else
END(strcpy)
#endif

View File

@@ -1,10 +1,11 @@
libc_bionic_src_files_arm += \
arch-arm/cortex-a15/bionic/memcpy.S \
arch-arm/cortex-a15/bionic/memset.S \
arch-arm/cortex-a15/bionic/stpcpy.S \
arch-arm/cortex-a15/bionic/strcat.S \
arch-arm/cortex-a15/bionic/__strcat_chk.S \
arch-arm/cortex-a15/bionic/strcmp.S \
arch-arm/cortex-a15/bionic/strcpy.S \
arch-arm/cortex-a15/bionic/strlen.S \
arch-arm/cortex-a15/bionic/__strcat_chk.S \
arch-arm/cortex-a15/bionic/__strcpy_chk.S \
arch-arm/cortex-a15/bionic/strlen.S \
bionic/memmove.c \

View File

@@ -40,12 +40,10 @@
ENTRY(__strcat_chk)
pld [r0, #0]
push {r0, lr}
.save {r0, lr}
.cfi_def_cfa_offset 8
.cfi_rel_offset r0, 0
.cfi_rel_offset lr, 4
push {r4, r5}
.save {r4, r5}
.cfi_adjust_cfa_offset 8
.cfi_rel_offset r4, 0
.cfi_rel_offset r5, 4
@@ -199,8 +197,6 @@ END(__strcat_chk)
#include "memcpy_base.S"
ENTRY_PRIVATE(__strcat_chk_fail)
.save {r0, lr}
.save {r4, r5}
.cfi_def_cfa_offset 8
.cfi_rel_offset r0, 0
.cfi_rel_offset lr, 4

View File

@@ -39,7 +39,6 @@
ENTRY(__strcpy_chk)
pld [r0, #0]
push {r0, lr}
.save {r0, lr}
.cfi_def_cfa_offset 8
.cfi_rel_offset r0, 0
.cfi_rel_offset lr, 4
@@ -165,7 +164,6 @@ END(__strcpy_chk)
#include "memcpy_base.S"
ENTRY_PRIVATE(__strcpy_chk_fail)
.save {r0, lr}
.cfi_def_cfa_offset 8
.cfi_rel_offset r0, 0
.cfi_rel_offset lr, 4

View File

@@ -50,7 +50,6 @@ END(__memcpy_chk)
ENTRY(memcpy)
pld [r1, #0]
stmfd sp!, {r0, lr}
.save {r0, lr}
.cfi_def_cfa_offset 8
.cfi_rel_offset r0, 0
.cfi_rel_offset lr, 4
@@ -64,7 +63,6 @@ END(memcpy)
ENTRY_PRIVATE(__memcpy_chk_fail)
// Preserve lr for backtrace.
push {lr}
.save {lr}
.cfi_def_cfa_offset 4
.cfi_rel_offset lr, 0

View File

@@ -33,7 +33,6 @@
*/
ENTRY_PRIVATE(MEMCPY_BASE)
.save {r0, lr}
.cfi_def_cfa_offset 8
.cfi_rel_offset r0, 0
.cfi_rel_offset lr, 4
@@ -139,14 +138,12 @@ ENTRY_PRIVATE(MEMCPY_BASE)
END(MEMCPY_BASE)
ENTRY_PRIVATE(MEMCPY_BASE_ALIGNED)
.save {r0, lr}
.cfi_def_cfa_offset 8
.cfi_rel_offset r0, 0
.cfi_rel_offset lr, 4
/* Simple arm-only copy loop to handle aligned copy operations */
stmfd sp!, {r4-r8}
.save {r4-r8}
.cfi_adjust_cfa_offset 20
.cfi_rel_offset r4, 0
.cfi_rel_offset r5, 4

View File

@@ -42,7 +42,6 @@ ENTRY(__memset_chk)
// Preserve lr for backtrace.
push {lr}
.save {lr}
.cfi_def_cfa_offset 4
.cfi_rel_offset lr, 0
@@ -72,7 +71,6 @@ ENTRY(memset)
bhi __memset_large_copy
stmfd sp!, {r0}
.save {r0}
.cfi_def_cfa_offset 4
.cfi_rel_offset r0, 0
@@ -114,7 +112,6 @@ ENTRY_PRIVATE(__memset_large_copy)
* offset = (4-(src&3))&3 = -src & 3
*/
stmfd sp!, {r0, r4-r7, lr}
.save {r0, r4-r7, lr}
.cfi_def_cfa_offset 24
.cfi_rel_offset r0, 0
.cfi_rel_offset r4, 4

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2013 The Android Open Source Project
* Copyright (C) 2014 The Android Open Source Project
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -26,9 +26,5 @@
* SUCH DAMAGE.
*/
#include <private/bionic_asm.h>
ENTRY_PRIVATE(__rt_sigreturn)
mov x8, __NR_rt_sigreturn
svc #0
END(__rt_sigreturn)
#define STPCPY
#include "string_copy.S"

View File

@@ -168,7 +168,6 @@ ENTRY(strcmp)
bne .L_do_align
/* Fast path. */
.save {r4-r7}
init
.L_doubleword_aligned:

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2013 The Android Open Source Project
* Copyright (C) 2014 The Android Open Source Project
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -25,432 +25,6 @@
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
/*
* Copyright (c) 2013 ARM Ltd
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the company may not be used to endorse or promote
* products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY ARM LTD ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL ARM LTD BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <private/bionic_asm.h>
.syntax unified
.thumb
.thumb_func
.macro m_push
push {r0, r4, r5, lr}
.endm // m_push
.macro m_ret inst
\inst {r0, r4, r5, pc}
.endm // m_ret
.macro m_copy_byte reg, cmd, label
ldrb \reg, [r1], #1
strb \reg, [r0], #1
\cmd \reg, \label
.endm // m_copy_byte
ENTRY(strcpy)
// Unroll the first 8 bytes that will be copied.
m_push
m_copy_byte reg=r2, cmd=cbz, label=strcpy_finish
m_copy_byte reg=r3, cmd=cbz, label=strcpy_finish
m_copy_byte reg=r4, cmd=cbz, label=strcpy_finish
m_copy_byte reg=r5, cmd=cbz, label=strcpy_finish
m_copy_byte reg=r2, cmd=cbz, label=strcpy_finish
m_copy_byte reg=r3, cmd=cbz, label=strcpy_finish
m_copy_byte reg=r4, cmd=cbz, label=strcpy_finish
m_copy_byte reg=r5, cmd=cbnz, label=strcpy_continue
strcpy_finish:
m_ret inst=pop
strcpy_continue:
pld [r1, #0]
ands r3, r0, #7
bne strcpy_align_dst
strcpy_check_src_align:
// At this point dst is aligned to a double word, check if src
// is also aligned to a double word.
ands r3, r1, #7
bne strcpy_unaligned_copy
.p2align 2
strcpy_mainloop:
ldmia r1!, {r2, r3}
pld [r1, #64]
sub ip, r2, #0x01010101
bic ip, ip, r2
ands ip, ip, #0x80808080
bne strcpy_zero_in_first_register
sub ip, r3, #0x01010101
bic ip, ip, r3
ands ip, ip, #0x80808080
bne strcpy_zero_in_second_register
stmia r0!, {r2, r3}
b strcpy_mainloop
strcpy_zero_in_first_register:
lsls lr, ip, #17
itt ne
strbne r2, [r0]
m_ret inst=popne
itt cs
strhcs r2, [r0]
m_ret inst=popcs
lsls ip, ip, #1
itt eq
streq r2, [r0]
m_ret inst=popeq
strh r2, [r0], #2
lsr r3, r2, #16
strb r3, [r0]
m_ret inst=pop
strcpy_zero_in_second_register:
lsls lr, ip, #17
ittt ne
stmiane r0!, {r2}
strbne r3, [r0]
m_ret inst=popne
ittt cs
strcs r2, [r0], #4
strhcs r3, [r0]
m_ret inst=popcs
lsls ip, ip, #1
itt eq
stmiaeq r0, {r2, r3}
m_ret inst=popeq
stmia r0!, {r2}
strh r3, [r0], #2
lsr r4, r3, #16
strb r4, [r0]
m_ret inst=pop
strcpy_align_dst:
// Align to a double word (64 bits).
rsb r3, r3, #8
lsls ip, r3, #31
beq strcpy_align_to_32
ldrb r2, [r1], #1
strb r2, [r0], #1
cbz r2, strcpy_complete
strcpy_align_to_32:
bcc strcpy_align_to_64
ldrb r4, [r1], #1
strb r4, [r0], #1
cmp r4, #0
it eq
m_ret inst=popeq
ldrb r5, [r1], #1
strb r5, [r0], #1
cmp r5, #0
it eq
m_ret inst=popeq
strcpy_align_to_64:
tst r3, #4
beq strcpy_check_src_align
ldr r2, [r1], #4
sub ip, r2, #0x01010101
bic ip, ip, r2
ands ip, ip, #0x80808080
bne strcpy_zero_in_first_register
stmia r0!, {r2}
b strcpy_check_src_align
strcpy_complete:
m_ret inst=pop
strcpy_unaligned_copy:
// Dst is aligned to a double word, while src is at an unknown alignment.
// There are 7 different versions of the unaligned copy code
// to prevent overreading the src. The mainloop of every single version
// will store 64 bits per loop. The difference is how much of src can
// be read without potentially crossing a page boundary.
tbb [pc, r3]
strcpy_unaligned_branchtable:
.byte 0
.byte ((strcpy_unalign7 - strcpy_unaligned_branchtable)/2)
.byte ((strcpy_unalign6 - strcpy_unaligned_branchtable)/2)
.byte ((strcpy_unalign5 - strcpy_unaligned_branchtable)/2)
.byte ((strcpy_unalign4 - strcpy_unaligned_branchtable)/2)
.byte ((strcpy_unalign3 - strcpy_unaligned_branchtable)/2)
.byte ((strcpy_unalign2 - strcpy_unaligned_branchtable)/2)
.byte ((strcpy_unalign1 - strcpy_unaligned_branchtable)/2)
.p2align 2
// Can read 7 bytes before possibly crossing a page.
strcpy_unalign7:
ldr r2, [r1], #4
sub ip, r2, #0x01010101
bic ip, ip, r2
ands ip, ip, #0x80808080
bne strcpy_zero_in_first_register
ldrb r3, [r1]
cbz r3, strcpy_unalign7_copy5bytes
ldrb r4, [r1, #1]
cbz r4, strcpy_unalign7_copy6bytes
ldrb r5, [r1, #2]
cbz r5, strcpy_unalign7_copy7bytes
ldr r3, [r1], #4
pld [r1, #64]
lsrs ip, r3, #24
stmia r0!, {r2, r3}
beq strcpy_unalign_return
b strcpy_unalign7
strcpy_unalign7_copy5bytes:
stmia r0!, {r2}
strb r3, [r0]
strcpy_unalign_return:
m_ret inst=pop
strcpy_unalign7_copy6bytes:
stmia r0!, {r2}
strb r3, [r0], #1
strb r4, [r0], #1
m_ret inst=pop
strcpy_unalign7_copy7bytes:
stmia r0!, {r2}
strb r3, [r0], #1
strb r4, [r0], #1
strb r5, [r0], #1
m_ret inst=pop
.p2align 2
// Can read 6 bytes before possibly crossing a page.
strcpy_unalign6:
ldr r2, [r1], #4
sub ip, r2, #0x01010101
bic ip, ip, r2
ands ip, ip, #0x80808080
bne strcpy_zero_in_first_register
ldrb r4, [r1]
cbz r4, strcpy_unalign_copy5bytes
ldrb r5, [r1, #1]
cbz r5, strcpy_unalign_copy6bytes
ldr r3, [r1], #4
pld [r1, #64]
tst r3, #0xff0000
beq strcpy_unalign6_copy7bytes
lsrs ip, r3, #24
stmia r0!, {r2, r3}
beq strcpy_unalign_return
b strcpy_unalign6
strcpy_unalign6_copy7bytes:
stmia r0!, {r2}
strh r3, [r0], #2
lsr r3, #16
strb r3, [r0]
m_ret inst=pop
.p2align 2
// Can read 5 bytes before possibly crossing a page.
strcpy_unalign5:
ldr r2, [r1], #4
sub ip, r2, #0x01010101
bic ip, ip, r2
ands ip, ip, #0x80808080
bne strcpy_zero_in_first_register
ldrb r4, [r1]
cbz r4, strcpy_unalign_copy5bytes
ldr r3, [r1], #4
pld [r1, #64]
sub ip, r3, #0x01010101
bic ip, ip, r3
ands ip, ip, #0x80808080
bne strcpy_zero_in_second_register
stmia r0!, {r2, r3}
b strcpy_unalign5
strcpy_unalign_copy5bytes:
stmia r0!, {r2}
strb r4, [r0]
m_ret inst=pop
strcpy_unalign_copy6bytes:
stmia r0!, {r2}
strb r4, [r0], #1
strb r5, [r0]
m_ret inst=pop
.p2align 2
// Can read 4 bytes before possibly crossing a page.
strcpy_unalign4:
ldmia r1!, {r2}
sub ip, r2, #0x01010101
bic ip, ip, r2
ands ip, ip, #0x80808080
bne strcpy_zero_in_first_register
ldmia r1!, {r3}
pld [r1, #64]
sub ip, r3, #0x01010101
bic ip, ip, r3
ands ip, ip, #0x80808080
bne strcpy_zero_in_second_register
stmia r0!, {r2, r3}
b strcpy_unalign4
.p2align 2
// Can read 3 bytes before possibly crossing a page.
strcpy_unalign3:
ldrb r2, [r1]
cbz r2, strcpy_unalign3_copy1byte
ldrb r3, [r1, #1]
cbz r3, strcpy_unalign3_copy2bytes
ldrb r4, [r1, #2]
cbz r4, strcpy_unalign3_copy3bytes
ldr r2, [r1], #4
ldr r3, [r1], #4
pld [r1, #64]
lsrs lr, r2, #24
beq strcpy_unalign_copy4bytes
sub ip, r3, #0x01010101
bic ip, ip, r3
ands ip, ip, #0x80808080
bne strcpy_zero_in_second_register
stmia r0!, {r2, r3}
b strcpy_unalign3
strcpy_unalign3_copy1byte:
strb r2, [r0]
m_ret inst=pop
strcpy_unalign3_copy2bytes:
strb r2, [r0], #1
strb r3, [r0]
m_ret inst=pop
strcpy_unalign3_copy3bytes:
strb r2, [r0], #1
strb r3, [r0], #1
strb r4, [r0]
m_ret inst=pop
.p2align 2
// Can read 2 bytes before possibly crossing a page.
strcpy_unalign2:
ldrb r2, [r1]
cbz r2, strcpy_unalign_copy1byte
ldrb r3, [r1, #1]
cbz r3, strcpy_unalign_copy2bytes
ldr r2, [r1], #4
ldr r3, [r1], #4
pld [r1, #64]
tst r2, #0xff0000
beq strcpy_unalign_copy3bytes
lsrs ip, r2, #24
beq strcpy_unalign_copy4bytes
sub ip, r3, #0x01010101
bic ip, ip, r3
ands ip, ip, #0x80808080
bne strcpy_zero_in_second_register
stmia r0!, {r2, r3}
b strcpy_unalign2
.p2align 2
// Can read 1 byte before possibly crossing a page.
strcpy_unalign1:
ldrb r2, [r1]
cbz r2, strcpy_unalign_copy1byte
ldr r2, [r1], #4
ldr r3, [r1], #4
pld [r1, #64]
sub ip, r2, #0x01010101
bic ip, ip, r2
ands ip, ip, #0x80808080
bne strcpy_zero_in_first_register
sub ip, r3, #0x01010101
bic ip, ip, r3
ands ip, ip, #0x80808080
bne strcpy_zero_in_second_register
stmia r0!, {r2, r3}
b strcpy_unalign1
strcpy_unalign_copy1byte:
strb r2, [r0]
m_ret inst=pop
strcpy_unalign_copy2bytes:
strb r2, [r0], #1
strb r3, [r0]
m_ret inst=pop
strcpy_unalign_copy3bytes:
strh r2, [r0], #2
lsr r2, #16
strb r2, [r0]
m_ret inst=pop
strcpy_unalign_copy4bytes:
stmia r0, {r2}
m_ret inst=pop
END(strcpy)
#define STRCPY
#include "string_copy.S"

View File

@@ -0,0 +1,535 @@
/*
* Copyright (C) 2013 The Android Open Source Project
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
/*
* Copyright (c) 2013 ARM Ltd
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the company may not be used to endorse or promote
* products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY ARM LTD ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL ARM LTD BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#if !defined(STPCPY) && !defined(STRCPY)
#error "Either STPCPY or STRCPY must be defined."
#endif
#include <private/bionic_asm.h>
.syntax unified
.thumb
.thumb_func
#if defined(STPCPY)
.macro m_push
push {r4, r5, lr}
.cfi_def_cfa_offset 12
.cfi_rel_offset r4, 0
.cfi_rel_offset r5, 4
.cfi_rel_offset lr, 8
.endm // m_push
#else
.macro m_push
push {r0, r4, r5, lr}
.cfi_def_cfa_offset 16
.cfi_rel_offset r0, 0
.cfi_rel_offset r4, 4
.cfi_rel_offset r5, 8
.cfi_rel_offset lr, 12
.endm // m_push
#endif
#if defined(STPCPY)
.macro m_ret inst
\inst {r4, r5, pc}
.endm // m_ret
#else
.macro m_ret inst
\inst {r0, r4, r5, pc}
.endm // m_ret
#endif
.macro m_copy_byte reg, cmd, label
ldrb \reg, [r1], #1
strb \reg, [r0], #1
\cmd \reg, \label
.endm // m_copy_byte
#if defined(STPCPY)
ENTRY(stpcpy)
#else
ENTRY(strcpy)
#endif
// Unroll the first 8 bytes that will be copied.
m_push
m_copy_byte reg=r2, cmd=cbz, label=.Lstringcopy_finish
m_copy_byte reg=r3, cmd=cbz, label=.Lstringcopy_finish
m_copy_byte reg=r4, cmd=cbz, label=.Lstringcopy_finish
m_copy_byte reg=r5, cmd=cbz, label=.Lstringcopy_finish
m_copy_byte reg=r2, cmd=cbz, label=.Lstringcopy_finish
m_copy_byte reg=r3, cmd=cbz, label=.Lstringcopy_finish
m_copy_byte reg=r4, cmd=cbz, label=.Lstringcopy_finish
m_copy_byte reg=r5, cmd=cbnz, label=.Lstringcopy_continue
.Lstringcopy_finish:
#if defined(STPCPY)
sub r0, r0, #1
#endif
m_ret inst=pop
.Lstringcopy_continue:
pld [r1, #0]
ands r3, r0, #7
bne .Lstringcopy_align_dst
.Lstringcopy_check_src_align:
// At this point dst is aligned to a double word, check if src
// is also aligned to a double word.
ands r3, r1, #7
bne .Lstringcopy_unaligned_copy
.p2align 2
.Lstringcopy_mainloop:
ldmia r1!, {r2, r3}
pld [r1, #64]
sub ip, r2, #0x01010101
bic ip, ip, r2
ands ip, ip, #0x80808080
bne .Lstringcopy_zero_in_first_register
sub ip, r3, #0x01010101
bic ip, ip, r3
ands ip, ip, #0x80808080
bne .Lstringcopy_zero_in_second_register
stmia r0!, {r2, r3}
b .Lstringcopy_mainloop
.Lstringcopy_zero_in_first_register:
lsls lr, ip, #17
itt ne
strbne r2, [r0]
m_ret inst=popne
itt cs
#if defined(STPCPY)
strhcs r2, [r0], #1
#else
strhcs r2, [r0]
#endif
m_ret inst=popcs
lsls ip, ip, #1
itt eq
#if defined(STPCPY)
streq r2, [r0], #3
#else
streq r2, [r0]
#endif
m_ret inst=popeq
strh r2, [r0], #2
lsr r3, r2, #16
strb r3, [r0]
m_ret inst=pop
.Lstringcopy_zero_in_second_register:
lsls lr, ip, #17
ittt ne
stmiane r0!, {r2}
strbne r3, [r0]
m_ret inst=popne
ittt cs
strcs r2, [r0], #4
#if defined(STPCPY)
strhcs r3, [r0], #1
#else
strhcs r3, [r0]
#endif
m_ret inst=popcs
lsls ip, ip, #1
#if defined(STPCPY)
ittt eq
#else
itt eq
#endif
stmiaeq r0, {r2, r3}
#if defined(STPCPY)
addeq r0, r0, #7
#endif
m_ret inst=popeq
stmia r0!, {r2}
strh r3, [r0], #2
lsr r4, r3, #16
strb r4, [r0]
m_ret inst=pop
.Lstringcopy_align_dst:
// Align to a double word (64 bits).
rsb r3, r3, #8
lsls ip, r3, #31
beq .Lstringcopy_align_to_32
ldrb r2, [r1], #1
strb r2, [r0], #1
cbz r2, .Lstringcopy_complete
.Lstringcopy_align_to_32:
bcc .Lstringcopy_align_to_64
ldrb r4, [r1], #1
strb r4, [r0], #1
cmp r4, #0
#if defined(STPCPY)
itt eq
subeq r0, r0, #1
#else
it eq
#endif
m_ret inst=popeq
ldrb r5, [r1], #1
strb r5, [r0], #1
cmp r5, #0
#if defined(STPCPY)
itt eq
subeq r0, r0, #1
#else
it eq
#endif
m_ret inst=popeq
.Lstringcopy_align_to_64:
tst r3, #4
beq .Lstringcopy_check_src_align
ldr r2, [r1], #4
sub ip, r2, #0x01010101
bic ip, ip, r2
ands ip, ip, #0x80808080
bne .Lstringcopy_zero_in_first_register
stmia r0!, {r2}
b .Lstringcopy_check_src_align
.Lstringcopy_complete:
#if defined(STPCPY)
sub r0, r0, #1
#endif
m_ret inst=pop
.Lstringcopy_unaligned_copy:
// Dst is aligned to a double word, while src is at an unknown alignment.
// There are 7 different versions of the unaligned copy code
// to prevent overreading the src. The mainloop of every single version
// will store 64 bits per loop. The difference is how much of src can
// be read without potentially crossing a page boundary.
tbb [pc, r3]
.Lstringcopy_unaligned_branchtable:
.byte 0
.byte ((.Lstringcopy_unalign7 - .Lstringcopy_unaligned_branchtable)/2)
.byte ((.Lstringcopy_unalign6 - .Lstringcopy_unaligned_branchtable)/2)
.byte ((.Lstringcopy_unalign5 - .Lstringcopy_unaligned_branchtable)/2)
.byte ((.Lstringcopy_unalign4 - .Lstringcopy_unaligned_branchtable)/2)
.byte ((.Lstringcopy_unalign3 - .Lstringcopy_unaligned_branchtable)/2)
.byte ((.Lstringcopy_unalign2 - .Lstringcopy_unaligned_branchtable)/2)
.byte ((.Lstringcopy_unalign1 - .Lstringcopy_unaligned_branchtable)/2)
.p2align 2
// Can read 7 bytes before possibly crossing a page.
.Lstringcopy_unalign7:
ldr r2, [r1], #4
sub ip, r2, #0x01010101
bic ip, ip, r2
ands ip, ip, #0x80808080
bne .Lstringcopy_zero_in_first_register
ldrb r3, [r1]
cbz r3, .Lstringcopy_unalign7_copy5bytes
ldrb r4, [r1, #1]
cbz r4, .Lstringcopy_unalign7_copy6bytes
ldrb r5, [r1, #2]
cbz r5, .Lstringcopy_unalign7_copy7bytes
ldr r3, [r1], #4
pld [r1, #64]
lsrs ip, r3, #24
stmia r0!, {r2, r3}
#if defined(STPCPY)
beq .Lstringcopy_finish
#else
beq .Lstringcopy_unalign_return
#endif
b .Lstringcopy_unalign7
.Lstringcopy_unalign7_copy5bytes:
stmia r0!, {r2}
strb r3, [r0]
.Lstringcopy_unalign_return:
m_ret inst=pop
.Lstringcopy_unalign7_copy6bytes:
stmia r0!, {r2}
strb r3, [r0], #1
strb r4, [r0]
m_ret inst=pop
.Lstringcopy_unalign7_copy7bytes:
stmia r0!, {r2}
strb r3, [r0], #1
strb r4, [r0], #1
strb r5, [r0]
m_ret inst=pop
.p2align 2
// Can read 6 bytes before possibly crossing a page.
.Lstringcopy_unalign6:
ldr r2, [r1], #4
sub ip, r2, #0x01010101
bic ip, ip, r2
ands ip, ip, #0x80808080
bne .Lstringcopy_zero_in_first_register
ldrb r4, [r1]
cbz r4, .Lstringcopy_unalign_copy5bytes
ldrb r5, [r1, #1]
cbz r5, .Lstringcopy_unalign_copy6bytes
ldr r3, [r1], #4
pld [r1, #64]
tst r3, #0xff0000
beq .Lstringcopy_unalign6_copy7bytes
lsrs ip, r3, #24
stmia r0!, {r2, r3}
#if defined(STPCPY)
beq .Lstringcopy_finish
#else
beq .Lstringcopy_unalign_return
#endif
b .Lstringcopy_unalign6
.Lstringcopy_unalign6_copy7bytes:
stmia r0!, {r2}
strh r3, [r0], #2
lsr r3, #16
strb r3, [r0]
m_ret inst=pop
.p2align 2
// Can read 5 bytes before possibly crossing a page.
.Lstringcopy_unalign5:
ldr r2, [r1], #4
sub ip, r2, #0x01010101
bic ip, ip, r2
ands ip, ip, #0x80808080
bne .Lstringcopy_zero_in_first_register
ldrb r4, [r1]
cbz r4, .Lstringcopy_unalign_copy5bytes
ldr r3, [r1], #4
pld [r1, #64]
sub ip, r3, #0x01010101
bic ip, ip, r3
ands ip, ip, #0x80808080
bne .Lstringcopy_zero_in_second_register
stmia r0!, {r2, r3}
b .Lstringcopy_unalign5
.Lstringcopy_unalign_copy5bytes:
stmia r0!, {r2}
strb r4, [r0]
m_ret inst=pop
.Lstringcopy_unalign_copy6bytes:
stmia r0!, {r2}
strb r4, [r0], #1
strb r5, [r0]
m_ret inst=pop
.p2align 2
// Can read 4 bytes before possibly crossing a page.
.Lstringcopy_unalign4:
ldmia r1!, {r2}
sub ip, r2, #0x01010101
bic ip, ip, r2
ands ip, ip, #0x80808080
bne .Lstringcopy_zero_in_first_register
ldmia r1!, {r3}
pld [r1, #64]
sub ip, r3, #0x01010101
bic ip, ip, r3
ands ip, ip, #0x80808080
bne .Lstringcopy_zero_in_second_register
stmia r0!, {r2, r3}
b .Lstringcopy_unalign4
.p2align 2
// Can read 3 bytes before possibly crossing a page.
.Lstringcopy_unalign3:
ldrb r2, [r1]
cbz r2, .Lstringcopy_unalign3_copy1byte
ldrb r3, [r1, #1]
cbz r3, .Lstringcopy_unalign3_copy2bytes
ldrb r4, [r1, #2]
cbz r4, .Lstringcopy_unalign3_copy3bytes
ldr r2, [r1], #4
ldr r3, [r1], #4
pld [r1, #64]
lsrs lr, r2, #24
beq .Lstringcopy_unalign_copy4bytes
sub ip, r3, #0x01010101
bic ip, ip, r3
ands ip, ip, #0x80808080
bne .Lstringcopy_zero_in_second_register
stmia r0!, {r2, r3}
b .Lstringcopy_unalign3
.Lstringcopy_unalign3_copy1byte:
strb r2, [r0]
m_ret inst=pop
.Lstringcopy_unalign3_copy2bytes:
strb r2, [r0], #1
strb r3, [r0]
m_ret inst=pop
.Lstringcopy_unalign3_copy3bytes:
strb r2, [r0], #1
strb r3, [r0], #1
strb r4, [r0]
m_ret inst=pop
.p2align 2
// Can read 2 bytes before possibly crossing a page.
.Lstringcopy_unalign2:
ldrb r2, [r1]
cbz r2, .Lstringcopy_unalign_copy1byte
ldrb r3, [r1, #1]
cbz r3, .Lstringcopy_unalign_copy2bytes
ldr r2, [r1], #4
ldr r3, [r1], #4
pld [r1, #64]
tst r2, #0xff0000
beq .Lstringcopy_unalign_copy3bytes
lsrs ip, r2, #24
beq .Lstringcopy_unalign_copy4bytes
sub ip, r3, #0x01010101
bic ip, ip, r3
ands ip, ip, #0x80808080
bne .Lstringcopy_zero_in_second_register
stmia r0!, {r2, r3}
b .Lstringcopy_unalign2
.p2align 2
// Can read 1 byte before possibly crossing a page.
.Lstringcopy_unalign1:
ldrb r2, [r1]
cbz r2, .Lstringcopy_unalign_copy1byte
ldr r2, [r1], #4
ldr r3, [r1], #4
pld [r1, #64]
sub ip, r2, #0x01010101
bic ip, ip, r2
ands ip, ip, #0x80808080
bne .Lstringcopy_zero_in_first_register
sub ip, r3, #0x01010101
bic ip, ip, r3
ands ip, ip, #0x80808080
bne .Lstringcopy_zero_in_second_register
stmia r0!, {r2, r3}
b .Lstringcopy_unalign1
.Lstringcopy_unalign_copy1byte:
strb r2, [r0]
m_ret inst=pop
.Lstringcopy_unalign_copy2bytes:
strb r2, [r0], #1
strb r3, [r0]
m_ret inst=pop
.Lstringcopy_unalign_copy3bytes:
strh r2, [r0], #2
lsr r2, #16
strb r2, [r0]
m_ret inst=pop
.Lstringcopy_unalign_copy4bytes:
stmia r0, {r2}
#if defined(STPCPY)
add r0, r0, #3
#endif
m_ret inst=pop
#if defined(STPCPY)
END(stpcpy)
#else
END(strcpy)
#endif

View File

@@ -1,10 +1,11 @@
libc_bionic_src_files_arm += \
arch-arm/cortex-a9/bionic/memcpy.S \
arch-arm/cortex-a9/bionic/memset.S \
arch-arm/cortex-a9/bionic/stpcpy.S \
arch-arm/cortex-a9/bionic/strcat.S \
arch-arm/cortex-a9/bionic/__strcat_chk.S \
arch-arm/cortex-a9/bionic/strcmp.S \
arch-arm/cortex-a9/bionic/strcpy.S \
arch-arm/cortex-a9/bionic/strlen.S \
arch-arm/cortex-a9/bionic/__strcat_chk.S \
arch-arm/cortex-a9/bionic/__strcpy_chk.S \
arch-arm/cortex-a9/bionic/strlen.S \
bionic/memmove.c \

View File

@@ -40,12 +40,10 @@
ENTRY(__strcat_chk)
pld [r0, #0]
push {r0, lr}
.save {r0, lr}
.cfi_def_cfa_offset 8
.cfi_rel_offset r0, 0
.cfi_rel_offset lr, 4
push {r4, r5}
.save {r4, r5}
.cfi_adjust_cfa_offset 8
.cfi_rel_offset r4, 0
.cfi_rel_offset r5, 4
@@ -195,9 +193,6 @@ END(__strcat_chk)
#include "memcpy_base.S"
ENTRY_PRIVATE(__strcat_chk_failed)
.save {r0, lr}
.save {r4, r5}
.cfi_def_cfa_offset 8
.cfi_rel_offset r0, 0
.cfi_rel_offset lr, 4

View File

@@ -39,7 +39,6 @@
ENTRY(__strcpy_chk)
pld [r0, #0]
push {r0, lr}
.save {r0, lr}
.cfi_def_cfa_offset 8
.cfi_rel_offset r0, 0
.cfi_rel_offset lr, 4
@@ -161,7 +160,6 @@ END(__strcpy_chk)
#include "memcpy_base.S"
ENTRY_PRIVATE(__strcpy_chk_failed)
.save {r0, lr}
.cfi_def_cfa_offset 8
.cfi_rel_offset r0, 0
.cfi_rel_offset lr, 4

View File

@@ -72,7 +72,6 @@ END(__memcpy_chk)
ENTRY(memcpy)
pld [r1, #64]
push {r0, lr}
.save {r0, lr}
.cfi_def_cfa_offset 8
.cfi_rel_offset r0, 0
.cfi_rel_offset lr, 4
@@ -85,7 +84,6 @@ END(memcpy)
ENTRY_PRIVATE(__memcpy_chk_fail)
// Preserve lr for backtrace.
push {lr}
.save {lr}
.cfi_def_cfa_offset 4
.cfi_rel_offset lr, 0

View File

@@ -7,7 +7,8 @@ libc_bionic_src_files_arm += \
# Use cortex-a15 versions of strcat/strcpy/strlen.
libc_bionic_src_files_arm += \
arch-arm/cortex-a15/bionic/stpcpy.S \
arch-arm/cortex-a15/bionic/strcat.S \
arch-arm/cortex-a15/bionic/strcmp.S \
arch-arm/cortex-a15/bionic/strcpy.S \
arch-arm/cortex-a15/bionic/strlen.S \
arch-arm/cortex-a15/bionic/strcmp.S \

View File

@@ -39,7 +39,7 @@
ENTRY(__memcpy_chk)
cmp r2, r3
bgt fortify_check_failed
bhi __memcpy_chk_fail
// Fall through to memcpy...
END(__memcpy_chk)
@@ -49,11 +49,14 @@ ENTRY(memcpy)
* ARM ABI. Since we have to save R0, we might as well save R4
* which we can use for better pipelining of the reads below
*/
.save {r0, r4, lr}
stmfd sp!, {r0, r4, lr}
.cfi_def_cfa_offset 12
.cfi_rel_offset r0, 0
.cfi_rel_offset r4, 4
.cfi_rel_offset lr, 8
/* Making room for r5-r11 which will be spilled later */
.pad #28
sub sp, sp, #28
.cfi_adjust_cfa_offset 28
// preload the destination because we'll align it to a cache line
// with small writes. Also start the source "pump".
@@ -63,14 +66,14 @@ ENTRY(memcpy)
/* it simplifies things to take care of len<4 early */
cmp r2, #4
blo copy_last_3_and_return
blo .Lcopy_last_3_and_return
/* compute the offset to align the source
* offset = (4-(src&3))&3 = -src & 3
*/
rsb r3, r1, #0
ands r3, r3, #3
beq src_aligned
beq .Lsrc_aligned
/* align source to 32 bits. We need to insert 2 instructions between
* a ldr[b|h] and str[b|h] because byte and half-word instructions
@@ -85,12 +88,12 @@ ENTRY(memcpy)
strcsb r4, [r0], #1
strcsb r12,[r0], #1
src_aligned:
.Lsrc_aligned:
/* see if src and dst are aligned together (congruent) */
eor r12, r0, r1
tst r12, #3
bne non_congruent
bne .Lnon_congruent
/* Use post-incriment mode for stm to spill r5-r11 to reserved stack
* frame. Don't update sp.
@@ -100,7 +103,7 @@ src_aligned:
/* align the destination to a cache-line */
rsb r3, r0, #0
ands r3, r3, #0x1C
beq congruent_aligned32
beq .Lcongruent_aligned32
cmp r3, r2
andhi r3, r2, #0x1C
@@ -115,14 +118,14 @@ src_aligned:
strne r10,[r0], #4
sub r2, r2, r3
congruent_aligned32:
.Lcongruent_aligned32:
/*
* here source is aligned to 32 bytes.
*/
cached_aligned32:
.Lcached_aligned32:
subs r2, r2, #32
blo less_than_32_left
blo .Lless_than_32_left
/*
* We preload a cache-line up to 64 bytes ahead. On the 926, this will
@@ -160,10 +163,7 @@ cached_aligned32:
add r2, r2, #32
less_than_32_left:
.Lless_than_32_left:
/*
* less than 32 bytes left at this point (length in r2)
*/
@@ -197,7 +197,7 @@ less_than_32_left:
/********************************************************************/
non_congruent:
.Lnon_congruent:
/*
* here source is aligned to 4 bytes
* but destination is not.
@@ -207,9 +207,9 @@ non_congruent:
* partial words in the shift queue)
*/
cmp r2, #4
blo copy_last_3_and_return
blo .Lcopy_last_3_and_return
/* Use post-incriment mode for stm to spill r5-r11 to reserved stack
/* Use post-increment mode for stm to spill r5-r11 to reserved stack
* frame. Don't update sp.
*/
stmea sp, {r5-r11}
@@ -236,7 +236,7 @@ non_congruent:
movcs r3, r3, lsr #8
cmp r2, #4
blo partial_word_tail
blo .Lpartial_word_tail
/* Align destination to 32 bytes (cache line boundary) */
1: tst r0, #0x1c
@@ -248,11 +248,11 @@ non_congruent:
str r4, [r0], #4
cmp r2, #4
bhs 1b
blo partial_word_tail
blo .Lpartial_word_tail
/* copy 32 bytes at a time */
2: subs r2, r2, #32
blo less_than_thirtytwo
blo .Lless_than_thirtytwo
/* Use immediate mode for the shifts, because there is an extra cycle
* for register shifts, which could account for up to 50% of
@@ -260,11 +260,11 @@ non_congruent:
*/
cmp r12, #24
beq loop24
beq .Lloop24
cmp r12, #8
beq loop8
beq .Lloop8
loop16:
.Lloop16:
ldr r12, [r1], #4
1: mov r4, r12
ldmia r1!, { r5,r6,r7, r8,r9,r10,r11}
@@ -289,9 +289,9 @@ loop16:
stmia r0!, {r3,r4,r5,r6, r7,r8,r9,r10}
mov r3, r11, lsr #16
bhs 1b
b less_than_thirtytwo
b .Lless_than_thirtytwo
loop8:
.Lloop8:
ldr r12, [r1], #4
1: mov r4, r12
ldmia r1!, { r5,r6,r7, r8,r9,r10,r11}
@@ -316,9 +316,9 @@ loop8:
stmia r0!, {r3,r4,r5,r6, r7,r8,r9,r10}
mov r3, r11, lsr #8
bhs 1b
b less_than_thirtytwo
b .Lless_than_thirtytwo
loop24:
.Lloop24:
ldr r12, [r1], #4
1: mov r4, r12
ldmia r1!, { r5,r6,r7, r8,r9,r10,r11}
@@ -345,12 +345,12 @@ loop24:
bhs 1b
less_than_thirtytwo:
.Lless_than_thirtytwo:
/* copy the last 0 to 31 bytes of the source */
rsb r12, lr, #32 /* we corrupted r12, recompute it */
add r2, r2, #32
cmp r2, #4
blo partial_word_tail
blo .Lpartial_word_tail
1: ldr r5, [r1], #4
sub r2, r2, #4
@@ -360,7 +360,7 @@ less_than_thirtytwo:
cmp r2, #4
bhs 1b
partial_word_tail:
.Lpartial_word_tail:
/* we have a partial word in the input buffer */
movs r5, lr, lsl #(31-3)
strmib r3, [r0], #1
@@ -372,7 +372,7 @@ partial_word_tail:
/* Refill spilled registers from the stack. Don't update sp. */
ldmfd sp, {r5-r11}
copy_last_3_and_return:
.Lcopy_last_3_and_return:
movs r2, r2, lsl #31 /* copy remaining 0, 1, 2 or 3 bytes */
ldrmib r2, [r1], #1
ldrcsb r3, [r1], #1
@@ -385,9 +385,15 @@ copy_last_3_and_return:
add sp, sp, #28
ldmfd sp!, {r0, r4, lr}
bx lr
END(memcpy)
// Only reached when the __memcpy_chk check fails.
fortify_check_failed:
ENTRY_PRIVATE(__memcpy_chk_fail)
// Preserve lr for backtrace.
push {lr}
.cfi_def_cfa_offset 4
.cfi_rel_offset lr, 0
ldr r0, error_message
ldr r1, error_code
1:
@@ -397,7 +403,7 @@ error_code:
.word BIONIC_EVENT_MEMCPY_BUFFER_OVERFLOW
error_message:
.word error_string-(1b+8)
END(memcpy)
END(__memcpy_chk_fail)
.data
error_string:

View File

@@ -7,4 +7,5 @@ libc_bionic_src_files_arm += \
bionic/memmove.c \
bionic/__strcat_chk.cpp \
bionic/__strcpy_chk.cpp \
upstream-openbsd/lib/libc/string/stpcpy.c \
upstream-openbsd/lib/libc/string/strcat.c \

View File

@@ -40,12 +40,10 @@
ENTRY(__strcat_chk)
pld [r0, #0]
push {r0, lr}
.save {r0, lr}
.cfi_def_cfa_offset 8
.cfi_rel_offset r0, 0
.cfi_rel_offset lr, 4
push {r4, r5}
.save {r4, r5}
.cfi_adjust_cfa_offset 8
.cfi_rel_offset r4, 0
.cfi_rel_offset r5, 4
@@ -194,8 +192,6 @@ END(__strcat_chk)
#include "memcpy_base.S"
ENTRY_PRIVATE(__strcat_chk_failed)
.save {r0, lr}
.save {r4, r5}
.cfi_def_cfa_offset 8
.cfi_rel_offset r0, 0
.cfi_rel_offset lr, 4

View File

@@ -39,7 +39,6 @@
ENTRY(__strcpy_chk)
pld [r0, #0]
push {r0, lr}
.save {r0, lr}
.cfi_def_cfa_offset 8
.cfi_rel_offset r0, 0
.cfi_rel_offset lr, 4
@@ -161,7 +160,6 @@ END(__strcpy_chk)
#include "memcpy_base.S"
ENTRY_PRIVATE(__strcpy_chk_failed)
.save {r0, lr}
.cfi_def_cfa_offset 8
.cfi_rel_offset r0, 0
.cfi_rel_offset lr, 4

View File

@@ -53,7 +53,6 @@ END(__memcpy_chk)
ENTRY(memcpy)
pld [r1, #64]
stmfd sp!, {r0, lr}
.save {r0, lr}
.cfi_def_cfa_offset 8
.cfi_rel_offset r0, 0
.cfi_rel_offset lr, 4
@@ -66,7 +65,6 @@ END(memcpy)
ENTRY_PRIVATE(__memcpy_chk_fail)
// Preserve lr for backtrace.
push {lr}
.save {lr}
.cfi_def_cfa_offset 4
.cfi_rel_offset lr, 0

View File

@@ -36,7 +36,6 @@
// Assumes neon instructions and a cache line size of 32 bytes.
ENTRY_PRIVATE(MEMCPY_BASE)
.save {r0, lr}
.cfi_def_cfa_offset 8
.cfi_rel_offset r0, 0
.cfi_rel_offset lr, 4

View File

@@ -43,7 +43,6 @@ ENTRY(__memset_chk)
bls .L_done
// Preserve lr for backtrace.
.save {lr}
push {lr}
.cfi_def_cfa_offset 4
.cfi_rel_offset lr, 0
@@ -69,7 +68,6 @@ END(bzero)
/* memset() returns its first argument. */
ENTRY(memset)
.save {r0}
stmfd sp!, {r0}
.cfi_def_cfa_offset 4
.cfi_rel_offset r0, 0

View File

@@ -168,7 +168,6 @@ ENTRY(strcmp)
bne .L_do_align
/* Fast path. */
.save {r4-r7}
init
.L_doubleword_aligned:

View File

@@ -7,6 +7,7 @@ libc_bionic_src_files_arm += \
# Use cortex-a15 versions of strcat/strcpy/strlen and standard memmove
libc_bionic_src_files_arm += \
arch-arm/cortex-a15/bionic/stpcpy.S \
arch-arm/cortex-a15/bionic/strcat.S \
arch-arm/cortex-a15/bionic/strcpy.S \
arch-arm/cortex-a15/bionic/strlen.S \

View File

@@ -1,8 +1,17 @@
# arm64 specific configs
# 64-bit arm.
libc_common_src_files_arm64 := \
#
# Default implementations of functions that are commonly optimized.
#
libc_bionic_src_files_arm64 += \
bionic/__memset_chk.cpp \
bionic/__strcpy_chk.cpp \
bionic/__strcat_chk.cpp \
bionic/memrchr.c \
bionic/strrchr.cpp \
libc_freebsd_src_files_arm64 += \
upstream-freebsd/lib/libc/string/wcscat.c \
upstream-freebsd/lib/libc/string/wcschr.c \
upstream-freebsd/lib/libc/string/wcscmp.c \
@@ -10,6 +19,8 @@ libc_common_src_files_arm64 := \
upstream-freebsd/lib/libc/string/wcslen.c \
upstream-freebsd/lib/libc/string/wcsrchr.c \
upstream-freebsd/lib/libc/string/wmemcmp.c \
libc_openbsd_src_files_arm64 += \
upstream-openbsd/lib/libc/string/stpncpy.c \
upstream-openbsd/lib/libc/string/strcat.c \
upstream-openbsd/lib/libc/string/strlcat.c \
@@ -17,19 +28,13 @@ libc_common_src_files_arm64 := \
upstream-openbsd/lib/libc/string/strncat.c \
upstream-openbsd/lib/libc/string/strncpy.c \
# Fortify implementations of libc functions.
libc_common_src_files_arm64 += \
bionic/__memcpy_chk.cpp \
bionic/__memset_chk.cpp \
bionic/__strcpy_chk.cpp \
bionic/__strcat_chk.cpp \
#
# Inherently architecture-specific code.
#
##########################################
### CPU specific source files
libc_bionic_src_files_arm64 := \
libc_bionic_src_files_arm64 += \
arch-arm64/bionic/__bionic_clone.S \
arch-arm64/bionic/_exit_with_stack_teardown.S \
arch-arm64/bionic/__rt_sigreturn.S \
arch-arm64/bionic/_setjmp.S \
arch-arm64/bionic/setjmp.S \
arch-arm64/bionic/__set_tls.c \
@@ -53,7 +58,7 @@ ifeq ($(strip $(TARGET_CPU_VARIANT)),)
endif
cpu_variant_mk := $(LOCAL_PATH)/arch-arm64/$(TARGET_CPU_VARIANT)/$(TARGET_CPU_VARIANT).mk
ifeq ($(wildcard $(cpu_variant_mk)),)
$(error "TARGET_CPU_VARIANT not set or set to an unknown value. Possible values are generic, generic-neon, denver64. Use generic for devices that do not have a CPU similar to any of the supported cpu variants.")
$(error "TARGET_CPU_VARIANT not set or set to an unknown value. Possible values are generic, denver64. Use generic for devices that do not have a CPU similar to any of the supported cpu variants.")
endif
include $(cpu_variant_mk)
libc_common_additional_dependencies += $(cpu_variank_mk)

View File

@@ -1,205 +1,63 @@
/* Copyright (c) 2012, Linaro Limited
All rights reserved.
Copyright (c) 2014, NVIDIA Corporation. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the Linaro nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/* Assumptions:
/*
* Copyright (C) 2008 The Android Open Source Project
* All rights reserved.
*
* denver, ARMv8-a, AArch64
* Unaligned accesses
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
// Prototype: void *memcpy (void *dst, const void *src, size_t count).
#include <private/bionic_asm.h>
#include <private/libc_events.h>
#define dstin x0
#define src x1
#define count x2
#define tmp1 x3
#define tmp1w w3
#define tmp2 x4
#define tmp2w w4
#define tmp3 x5
#define tmp3w w5
#define dst x6
ENTRY(__memcpy_chk)
cmp x2, x3
b.hi __memcpy_chk_fail
#define A_l x7
#define A_h x8
#define B_l x9
#define B_h x10
#define C_l x11
#define C_h x12
#define D_l x13
#define D_h x14
#define QA_l q0
#define QA_h q1
#define QB_l q2
#define QB_h q3
// Fall through to memcpy...
END(__memcpy_chk)
ENTRY(memcpy)
mov dst, dstin
cmp count, #64
b.ge .Lcpy_not_short
cmp count, #15
b.le .Ltail15tiny
/* Deal with small copies quickly by dropping straight into the
* exit block. */
.Ltail63:
/* Copy up to 48 bytes of data. At this point we only need the
* bottom 6 bits of count to be accurate. */
ands tmp1, count, #0x30
b.eq .Ltail15
add dst, dst, tmp1
add src, src, tmp1
cmp tmp1w, #0x20
b.eq 1f
b.lt 2f
ldp A_l, A_h, [src, #-48]
stp A_l, A_h, [dst, #-48]
1:
ldp A_l, A_h, [src, #-32]
stp A_l, A_h, [dst, #-32]
2:
ldp A_l, A_h, [src, #-16]
stp A_l, A_h, [dst, #-16]
.Ltail15:
ands count, count, #15
beq 1f
add src, src, count
ldp A_l, A_h, [src, #-16]
add dst, dst, count
stp A_l, A_h, [dst, #-16]
1:
ret
.Ltail15tiny:
/* Copy up to 15 bytes of data. Does not assume additional data
being copied. */
tbz count, #3, 1f
ldr tmp1, [src], #8
str tmp1, [dst], #8
1:
tbz count, #2, 1f
ldr tmp1w, [src], #4
str tmp1w, [dst], #4
1:
tbz count, #1, 1f
ldrh tmp1w, [src], #2
strh tmp1w, [dst], #2
1:
tbz count, #0, 1f
ldrb tmp1w, [src]
strb tmp1w, [dst]
1:
ret
.Lcpy_not_short:
/* We don't much care about the alignment of DST, but we want SRC
* to be 128-bit (16 byte) aligned so that we don't cross cache line
* boundaries on both loads and stores. */
neg tmp2, src
ands tmp2, tmp2, #15 /* Bytes to reach alignment. */
b.eq 2f
sub count, count, tmp2
/* Copy more data than needed; it's faster than jumping
* around copying sub-Quadword quantities. We know that
* it can't overrun. */
ldp A_l, A_h, [src]
add src, src, tmp2
stp A_l, A_h, [dst]
add dst, dst, tmp2
/* There may be less than 63 bytes to go now. */
cmp count, #63
b.le .Ltail63
2:
subs count, count, #128
b.ge .Lcpy_body_large
/* Less than 128 bytes to copy, so handle 64 here and then jump
* to the tail. */
ldp QA_l, QA_h, [src]
ldp QB_l, QB_h, [src, #32]
stp QA_l, QA_h, [dst]
stp QB_l, QB_h, [dst, #32]
tst count, #0x3f
add src, src, #64
add dst, dst, #64
b.ne .Ltail63
ret
/* Critical loop. Start at a new cache line boundary. Assuming
* 64 bytes per line this ensures the entire loop is in one line. */
.p2align 6
.Lcpy_body_large:
cmp count, 65536
bhi .Lcpy_body_huge
/* There are at least 128 bytes to copy. */
ldp QA_l, QA_h, [src, #0]
sub dst, dst, #32 /* Pre-bias. */
ldp QB_l, QB_h, [src, #32]! /* src += 64 - Pre-bias. */
1:
stp QA_l, QA_h, [dst, #32]
ldp QA_l, QA_h, [src, #32]
stp QB_l, QB_h, [dst, #64]!
ldp QB_l, QB_h, [src, #64]!
subs count, count, #64
b.ge 1b
stp QA_l, QA_h, [dst, #32]
stp QB_l, QB_h, [dst, #64]
add src, src, #32
add dst, dst, #64 + 32
tst count, #0x3f
b.ne .Ltail63
ret
.Lcpy_body_huge:
/* There are at least 128 bytes to copy. */
ldp QA_l, QA_h, [src, #0]
sub dst, dst, #32 /* Pre-bias. */
ldp QB_l, QB_h, [src, #32]!
1:
stnp QA_l, QA_h, [dst, #32]
stnp QB_l, QB_h, [dst, #64]
ldp QA_l, QA_h, [src, #32]
ldp QB_l, QB_h, [src, #64]!
add dst, dst, #64
subs count, count, #64
b.ge 1b
stnp QA_l, QA_h, [dst, #32]
stnp QB_l, QB_h, [dst, #64]
add src, src, #32
add dst, dst, #64 + 32
tst count, #0x3f
b.ne .Ltail63
ret
#include "memcpy_base.S"
END(memcpy)
ENTRY_PRIVATE(__memcpy_chk_fail)
// Preserve for accurate backtrace.
stp x29, x30, [sp, -16]!
.cfi_def_cfa_offset 16
.cfi_rel_offset x29, 0
.cfi_rel_offset x30, 8
adrp x0, error_string
add x0, x0, :lo12:error_string
ldr x1, error_code
bl __fortify_chk_fail
error_code:
.word BIONIC_EVENT_MEMCPY_BUFFER_OVERFLOW
END(__memcpy_chk_fail)
.data
.align 2
error_string:
.string "memcpy: prevented write past end of buffer"

View File

@@ -0,0 +1,199 @@
/* Copyright (c) 2012, Linaro Limited
All rights reserved.
Copyright (c) 2014, NVIDIA Corporation. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the Linaro nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/* Assumptions:
*
* denver, ARMv8-a, AArch64
* Unaligned accesses
*
*/
#define dstin x0
#define src x1
#define count x2
#define tmp1 x3
#define tmp1w w3
#define tmp2 x4
#define tmp2w w4
#define tmp3 x5
#define tmp3w w5
#define dst x6
#define A_l x7
#define A_h x8
#define B_l x9
#define B_h x10
#define C_l x11
#define C_h x12
#define D_l x13
#define D_h x14
#define QA_l q0
#define QA_h q1
#define QB_l q2
#define QB_h q3
mov dst, dstin
cmp count, #64
b.ge .Lcpy_not_short
cmp count, #15
b.le .Ltail15tiny
/* Deal with small copies quickly by dropping straight into the
* exit block. */
.Ltail63:
/* Copy up to 48 bytes of data. At this point we only need the
* bottom 6 bits of count to be accurate. */
ands tmp1, count, #0x30
b.eq .Ltail15
add dst, dst, tmp1
add src, src, tmp1
cmp tmp1w, #0x20
b.eq 1f
b.lt 2f
ldp A_l, A_h, [src, #-48]
stp A_l, A_h, [dst, #-48]
1:
ldp A_l, A_h, [src, #-32]
stp A_l, A_h, [dst, #-32]
2:
ldp A_l, A_h, [src, #-16]
stp A_l, A_h, [dst, #-16]
.Ltail15:
ands count, count, #15
beq 1f
add src, src, count
ldp A_l, A_h, [src, #-16]
add dst, dst, count
stp A_l, A_h, [dst, #-16]
1:
ret
.Ltail15tiny:
/* Copy up to 15 bytes of data. Does not assume additional data
being copied. */
tbz count, #3, 1f
ldr tmp1, [src], #8
str tmp1, [dst], #8
1:
tbz count, #2, 1f
ldr tmp1w, [src], #4
str tmp1w, [dst], #4
1:
tbz count, #1, 1f
ldrh tmp1w, [src], #2
strh tmp1w, [dst], #2
1:
tbz count, #0, 1f
ldrb tmp1w, [src]
strb tmp1w, [dst]
1:
ret
.Lcpy_not_short:
/* We don't much care about the alignment of DST, but we want SRC
* to be 128-bit (16 byte) aligned so that we don't cross cache line
* boundaries on both loads and stores. */
neg tmp2, src
ands tmp2, tmp2, #15 /* Bytes to reach alignment. */
b.eq 2f
sub count, count, tmp2
/* Copy more data than needed; it's faster than jumping
* around copying sub-Quadword quantities. We know that
* it can't overrun. */
ldp A_l, A_h, [src]
add src, src, tmp2
stp A_l, A_h, [dst]
add dst, dst, tmp2
/* There may be less than 63 bytes to go now. */
cmp count, #63
b.le .Ltail63
2:
subs count, count, #128
b.ge .Lcpy_body_large
/* Less than 128 bytes to copy, so handle 64 here and then jump
* to the tail. */
ldp QA_l, QA_h, [src]
ldp QB_l, QB_h, [src, #32]
stp QA_l, QA_h, [dst]
stp QB_l, QB_h, [dst, #32]
tst count, #0x3f
add src, src, #64
add dst, dst, #64
b.ne .Ltail63
ret
/* Critical loop. Start at a new cache line boundary. Assuming
* 64 bytes per line this ensures the entire loop is in one line. */
.p2align 6
.Lcpy_body_large:
cmp count, 65536
bhi .Lcpy_body_huge
/* There are at least 128 bytes to copy. */
ldp QA_l, QA_h, [src, #0]
sub dst, dst, #32 /* Pre-bias. */
ldp QB_l, QB_h, [src, #32]! /* src += 64 - Pre-bias. */
1:
stp QA_l, QA_h, [dst, #32]
ldp QA_l, QA_h, [src, #32]
stp QB_l, QB_h, [dst, #64]!
ldp QB_l, QB_h, [src, #64]!
subs count, count, #64
b.ge 1b
stp QA_l, QA_h, [dst, #32]
stp QB_l, QB_h, [dst, #64]
add src, src, #32
add dst, dst, #64 + 32
tst count, #0x3f
b.ne .Ltail63
ret
.Lcpy_body_huge:
/* There are at least 128 bytes to copy. */
ldp QA_l, QA_h, [src, #0]
sub dst, dst, #32 /* Pre-bias. */
ldp QB_l, QB_h, [src, #32]!
1:
stnp QA_l, QA_h, [dst, #32]
stnp QB_l, QB_h, [dst, #64]
ldp QA_l, QA_h, [src, #32]
ldp QB_l, QB_h, [src, #64]!
add dst, dst, #64
subs count, count, #64
b.ge 1b
stnp QA_l, QA_h, [dst, #32]
stnp QB_l, QB_h, [dst, #64]
add src, src, #32
add dst, dst, #64 + 32
tst count, #0x3f
b.ne .Ltail63
ret

View File

@@ -1,13 +0,0 @@
libc_bionic_src_files_arm64 += \
arch-arm64/generic/bionic/memchr.S \
arch-arm64/generic/bionic/memcmp.S \
arch-arm64/generic/bionic/memmove.S \
arch-arm64/generic/bionic/memset.S \
arch-arm64/generic/bionic/stpcpy.S \
arch-arm64/generic/bionic/strchr.S \
arch-arm64/generic/bionic/strcmp.S \
arch-arm64/generic/bionic/strcpy.S \
arch-arm64/generic/bionic/strlen.S \
arch-arm64/generic/bionic/strncmp.S \
arch-arm64/generic/bionic/strnlen.S \
arch-arm64/generic-neon/bionic/memcpy.S \

View File

@@ -1,184 +1,63 @@
/* Copyright (c) 2012, Linaro Limited
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the Linaro nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/* Assumptions:
/*
* Copyright (C) 2008 The Android Open Source Project
* All rights reserved.
*
* ARMv8-a, AArch64
* Unaligned accesses
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
// Prototype: void *memcpy (void *dst, const void *src, size_t count).
#include <private/bionic_asm.h>
#include <private/libc_events.h>
#define dstin x0
#define src x1
#define count x2
#define tmp1 x3
#define tmp1w w3
#define tmp2 x4
#define tmp2w w4
#define tmp3 x5
#define tmp3w w5
#define dst x6
ENTRY(__memcpy_chk)
cmp x2, x3
b.hi __memcpy_chk_fail
#define A_l x7
#define A_h x8
#define B_l x9
#define B_h x10
#define C_l x11
#define C_h x12
#define D_l x13
#define D_h x14
// Fall through to memcpy...
END(__memcpy_chk)
ENTRY(memcpy)
mov dst, dstin
cmp count, #64
b.ge .Lcpy_not_short
cmp count, #15
b.le .Ltail15tiny
/* Deal with small copies quickly by dropping straight into the
* exit block. */
.Ltail63:
/* Copy up to 48 bytes of data. At this point we only need the
* bottom 6 bits of count to be accurate. */
ands tmp1, count, #0x30
b.eq .Ltail15
add dst, dst, tmp1
add src, src, tmp1
cmp tmp1w, #0x20
b.eq 1f
b.lt 2f
ldp A_l, A_h, [src, #-48]
stp A_l, A_h, [dst, #-48]
1:
ldp A_l, A_h, [src, #-32]
stp A_l, A_h, [dst, #-32]
2:
ldp A_l, A_h, [src, #-16]
stp A_l, A_h, [dst, #-16]
.Ltail15:
ands count, count, #15
beq 1f
add src, src, count
ldp A_l, A_h, [src, #-16]
add dst, dst, count
stp A_l, A_h, [dst, #-16]
1:
ret
.Ltail15tiny:
/* Copy up to 15 bytes of data. Does not assume additional data
being copied. */
tbz count, #3, 1f
ldr tmp1, [src], #8
str tmp1, [dst], #8
1:
tbz count, #2, 1f
ldr tmp1w, [src], #4
str tmp1w, [dst], #4
1:
tbz count, #1, 1f
ldrh tmp1w, [src], #2
strh tmp1w, [dst], #2
1:
tbz count, #0, 1f
ldrb tmp1w, [src]
strb tmp1w, [dst]
1:
ret
.Lcpy_not_short:
/* We don't much care about the alignment of DST, but we want SRC
* to be 128-bit (16 byte) aligned so that we don't cross cache line
* boundaries on both loads and stores. */
neg tmp2, src
ands tmp2, tmp2, #15 /* Bytes to reach alignment. */
b.eq 2f
sub count, count, tmp2
/* Copy more data than needed; it's faster than jumping
* around copying sub-Quadword quantities. We know that
* it can't overrun. */
ldp A_l, A_h, [src]
add src, src, tmp2
stp A_l, A_h, [dst]
add dst, dst, tmp2
/* There may be less than 63 bytes to go now. */
cmp count, #63
b.le .Ltail63
2:
subs count, count, #128
b.ge .Lcpy_body_large
/* Less than 128 bytes to copy, so handle 64 here and then jump
* to the tail. */
ldp A_l, A_h, [src]
ldp B_l, B_h, [src, #16]
ldp C_l, C_h, [src, #32]
ldp D_l, D_h, [src, #48]
stp A_l, A_h, [dst]
stp B_l, B_h, [dst, #16]
stp C_l, C_h, [dst, #32]
stp D_l, D_h, [dst, #48]
tst count, #0x3f
add src, src, #64
add dst, dst, #64
b.ne .Ltail63
ret
/* Critical loop. Start at a new cache line boundary. Assuming
* 64 bytes per line this ensures the entire loop is in one line. */
.p2align 6
.Lcpy_body_large:
/* There are at least 128 bytes to copy. */
ldp A_l, A_h, [src, #0]
sub dst, dst, #16 /* Pre-bias. */
ldp B_l, B_h, [src, #16]
ldp C_l, C_h, [src, #32]
ldp D_l, D_h, [src, #48]! /* src += 64 - Pre-bias. */
1:
stp A_l, A_h, [dst, #16]
ldp A_l, A_h, [src, #16]
stp B_l, B_h, [dst, #32]
ldp B_l, B_h, [src, #32]
stp C_l, C_h, [dst, #48]
ldp C_l, C_h, [src, #48]
stp D_l, D_h, [dst, #64]!
ldp D_l, D_h, [src, #64]!
subs count, count, #64
b.ge 1b
stp A_l, A_h, [dst, #16]
stp B_l, B_h, [dst, #32]
stp C_l, C_h, [dst, #48]
stp D_l, D_h, [dst, #64]
add src, src, #16
add dst, dst, #64 + 16
tst count, #0x3f
b.ne .Ltail63
ret
#include "memcpy_base.S"
END(memcpy)
ENTRY_PRIVATE(__memcpy_chk_fail)
// Preserve for accurate backtrace.
stp x29, x30, [sp, -16]!
.cfi_def_cfa_offset 16
.cfi_rel_offset x29, 0
.cfi_rel_offset x30, 8
adrp x0, error_string
add x0, x0, :lo12:error_string
ldr x1, error_code
bl __fortify_chk_fail
error_code:
.word BIONIC_EVENT_MEMCPY_BUFFER_OVERFLOW
END(__memcpy_chk_fail)
.data
.align 2
error_string:
.string "memcpy: prevented write past end of buffer"

View File

@@ -32,8 +32,6 @@
*
*/
#include <private/bionic_asm.h>
#define dstin x0
#define src x1
#define count x2
@@ -54,13 +52,6 @@
#define D_l x13
#define D_h x14
#define QA_l q0
#define QA_h q1
#define QB_l q2
#define QB_h q3
ENTRY(memcpy)
mov dst, dstin
cmp count, #64
b.ge .Lcpy_not_short
@@ -142,10 +133,14 @@ ENTRY(memcpy)
b.ge .Lcpy_body_large
/* Less than 128 bytes to copy, so handle 64 here and then jump
* to the tail. */
ldp QA_l, QA_h, [src]
ldp QB_l, QB_h, [src, #32]
stp QA_l, QA_h, [dst]
stp QB_l, QB_h, [dst, #32]
ldp A_l, A_h, [src]
ldp B_l, B_h, [src, #16]
ldp C_l, C_h, [src, #32]
ldp D_l, D_h, [src, #48]
stp A_l, A_h, [dst]
stp B_l, B_h, [dst, #16]
stp C_l, C_h, [dst, #32]
stp D_l, D_h, [dst, #48]
tst count, #0x3f
add src, src, #64
add dst, dst, #64
@@ -157,23 +152,28 @@ ENTRY(memcpy)
.p2align 6
.Lcpy_body_large:
/* There are at least 128 bytes to copy. */
ldp QA_l, QA_h, [src, #0]
sub dst, dst, #32 /* Pre-bias. */
ldp QB_l, QB_h, [src, #32]! /* src += 64 - Pre-bias. */
ldp A_l, A_h, [src, #0]
sub dst, dst, #16 /* Pre-bias. */
ldp B_l, B_h, [src, #16]
ldp C_l, C_h, [src, #32]
ldp D_l, D_h, [src, #48]! /* src += 64 - Pre-bias. */
1:
stp QA_l, QA_h, [dst, #32]
ldp QA_l, QA_h, [src, #32]
stp QB_l, QB_h, [dst, #64]!
ldp QB_l, QB_h, [src, #64]!
stp A_l, A_h, [dst, #16]
ldp A_l, A_h, [src, #16]
stp B_l, B_h, [dst, #32]
ldp B_l, B_h, [src, #32]
stp C_l, C_h, [dst, #48]
ldp C_l, C_h, [src, #48]
stp D_l, D_h, [dst, #64]!
ldp D_l, D_h, [src, #64]!
subs count, count, #64
b.ge 1b
stp QA_l, QA_h, [dst, #32]
stp QB_l, QB_h, [dst, #64]
add src, src, #32
add dst, dst, #64 + 32
stp A_l, A_h, [dst, #16]
stp B_l, B_h, [dst, #32]
stp C_l, C_h, [dst, #48]
stp D_l, D_h, [dst, #64]
add src, src, #16
add dst, dst, #64 + 16
tst count, #0x3f
b.ne .Ltail63
ret
END(memcpy)

View File

@@ -99,6 +99,7 @@
#define R_AARCH64_RELATIVE 1027 /* Adjust by program base. */
#define R_AARCH64_TLS_TPREL64 1030
#define R_AARCH64_TLS_DTPREL32 1031
#define R_AARCH64_IRELATIVE 1032
#define R_TYPE(name) __CONCAT(R_AARCH64_,name)

View File

@@ -1,17 +1,32 @@
# mips specific configs
# 32-bit mips.
# These are shared by all the 32-bit targets, but not the 64-bit ones.
libc_common_src_files_mips := \
#
# Various kinds of LP32 cruft.
#
libc_bionic_src_files_mips += \
bionic/mmap.cpp \
libc_common_src_files_mips += \
bionic/legacy_32_bit_support.cpp \
bionic/ndk_cruft.cpp \
bionic/time64.c \
libc_netbsd_src_files_mips += \
upstream-netbsd/common/lib/libc/hash/sha1/sha1.c \
libc_openbsd_src_files_mips += \
upstream-openbsd/lib/libc/stdio/putw.c \
# These are shared by all the 32-bit targets, but not the 64-bit ones.
libc_bionic_src_files_mips += \
bionic/mmap.cpp
#
# Default implementations of functions that are commonly optimized.
#
libc_common_src_files_mips += \
libc_bionic_src_files_mips += \
bionic/__memcpy_chk.cpp \
bionic/__memset_chk.cpp \
bionic/__strcpy_chk.cpp \
bionic/__strcat_chk.cpp \
bionic/memchr.c \
bionic/memcmp.c \
bionic/memmove.c \
@@ -19,6 +34,8 @@ libc_common_src_files_mips += \
bionic/strchr.cpp \
bionic/strnlen.c \
bionic/strrchr.cpp \
libc_freebsd_src_files_mips += \
upstream-freebsd/lib/libc/string/wcscat.c \
upstream-freebsd/lib/libc/string/wcschr.c \
upstream-freebsd/lib/libc/string/wcscmp.c \
@@ -27,6 +44,8 @@ libc_common_src_files_mips += \
upstream-freebsd/lib/libc/string/wcsrchr.c \
upstream-freebsd/lib/libc/string/wmemcmp.c \
upstream-freebsd/lib/libc/string/wmemmove.c \
libc_openbsd_src_files_mips += \
upstream-openbsd/lib/libc/string/bcopy.c \
upstream-openbsd/lib/libc/string/stpcpy.c \
upstream-openbsd/lib/libc/string/stpncpy.c \
@@ -39,16 +58,10 @@ libc_common_src_files_mips += \
upstream-openbsd/lib/libc/string/strncmp.c \
upstream-openbsd/lib/libc/string/strncpy.c \
# Fortify implementations of libc functions.
libc_common_src_files_mips += \
bionic/__memcpy_chk.cpp \
bionic/__memset_chk.cpp \
bionic/__strcpy_chk.cpp \
bionic/__strcat_chk.cpp \
#
# Inherently architecture-specific code.
#
##########################################
### CPU specific source files
libc_bionic_src_files_mips += \
arch-mips/bionic/__bionic_clone.S \
arch-mips/bionic/bzero.S \
@@ -69,13 +82,12 @@ libc_bionic_src_files_mips += \
else
libc_bionic_src_files_mips += \
bionic/memcpy.cpp \
bionic/memset.c
libc_common_src_files_mips += \
upstream-openbsd/lib/libc/string/strlen.c
endif
bionic/memset.c \
libc_netbsd_src_files_mips := \
upstream-netbsd/common/lib/libc/hash/sha1/sha1.c \
libc_openbsd_src_files_mips += \
upstream-openbsd/lib/libc/string/strlen.c \
endif
libc_crt_target_cflags_mips := \
$($(my_2nd_arch_prefix)TARGET_GLOBAL_CFLAGS) \

View File

@@ -1,13 +1,25 @@
# mips64 specific configs
# 64-bit mips.
libc_common_src_files_mips64 := \
#
# Default implementations of functions that are commonly optimized.
#
libc_bionic_src_files_mips64 += \
bionic/__memcpy_chk.cpp \
bionic/__memset_chk.cpp \
bionic/__strcpy_chk.cpp \
bionic/__strcat_chk.cpp \
bionic/memchr.c \
bionic/memcmp.c \
bionic/memcpy.cpp \
bionic/memmove.c \
bionic/memrchr.c \
bionic/memset.c \
bionic/strchr.cpp \
bionic/strnlen.c \
bionic/strrchr.cpp \
libc_freebsd_src_files_mips64 += \
upstream-freebsd/lib/libc/string/wcscat.c \
upstream-freebsd/lib/libc/string/wcschr.c \
upstream-freebsd/lib/libc/string/wcscmp.c \
@@ -16,6 +28,8 @@ libc_common_src_files_mips64 := \
upstream-freebsd/lib/libc/string/wcsrchr.c \
upstream-freebsd/lib/libc/string/wmemcmp.c \
upstream-freebsd/lib/libc/string/wmemmove.c \
libc_openbsd_src_files_mips64 += \
upstream-openbsd/lib/libc/string/stpcpy.c \
upstream-openbsd/lib/libc/string/stpncpy.c \
upstream-openbsd/lib/libc/string/strcat.c \
@@ -28,17 +42,11 @@ libc_common_src_files_mips64 := \
upstream-openbsd/lib/libc/string/strncmp.c \
upstream-openbsd/lib/libc/string/strncpy.c \
# Fortify implementations of libc functions.
libc_common_src_files_mips64 += \
bionic/__memcpy_chk.cpp \
bionic/__memset_chk.cpp \
bionic/__strcpy_chk.cpp \
bionic/__strcat_chk.cpp \
#
# Inherently architecture-specific code.
#
##########################################
### CPU specific source files
libc_bionic_src_files_mips64 := \
libc_bionic_src_files_mips64 += \
arch-mips64/bionic/__bionic_clone.S \
arch-mips64/bionic/_exit_with_stack_teardown.S \
arch-mips64/bionic/__get_sp.S \
@@ -48,25 +56,18 @@ libc_bionic_src_files_mips64 := \
arch-mips64/bionic/syscall.S \
arch-mips64/bionic/vfork.S \
# FIXME TODO
## libc_bionic_src_files_mips64 += arch-mips64/string/memcpy.S
## libc_bionic_src_files_mips64 += arch-mips64/string/memset.S
libc_bionic_src_files_mips64 += bionic/memcpy.cpp
libc_bionic_src_files_mips64 += bionic/memset.c
libc_crt_target_cflags_mips64 := \
$($(my_2nd_arch_prefix)TARGET_GLOBAL_CFLAGS) \
-I$(LOCAL_PATH)/arch-mips64/include
-I$(LOCAL_PATH)/arch-mips64/include \
libc_crt_target_crtbegin_file_mips64 := \
$(LOCAL_PATH)/arch-mips64/bionic/crtbegin.c
$(LOCAL_PATH)/arch-mips64/bionic/crtbegin.c \
libc_crt_target_crtbegin_so_file_mips64 := \
$(LOCAL_PATH)/arch-common/bionic/crtbegin_so.c
$(LOCAL_PATH)/arch-common/bionic/crtbegin_so.c \
libc_crt_target_so_cflags_mips64 := \
-fPIC
-fPIC \
libc_crt_target_ldflags_mips64 := \
-melf64ltsmip
-melf64ltsmip \

View File

@@ -0,0 +1,135 @@
/*
* Copyright (C) 2014 The Android Open Source Project
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <private/bionic_asm.h>
// DWARF constants.
#define DW_CFA_def_cfa_expression 0x0f
#define DW_CFA_expression 0x10
#define DW_EH_PE_pcrel 0x10
#define DW_EH_PE_sdata4 0x0b
#define DW_OP_breg4 0x74
#define DW_OP_deref 0x06
// Offsets into struct sigcontext.
#define OFFSET_EDI 16
#define OFFSET_ESI 20
#define OFFSET_EBP 24
#define OFFSET_ESP 28
#define OFFSET_EBX 32
#define OFFSET_EDX 36
#define OFFSET_ECX 40
#define OFFSET_EAX 44
#define OFFSET_EIP 56
// Non-standard DWARF constants for the x86 registers.
#define DW_x86_REG_EAX 0
#define DW_x86_REG_ECX 1
#define DW_x86_REG_EDX 2
#define DW_x86_REG_EBX 3
#define DW_x86_REG_EBP 5
#define DW_x86_REG_ESI 6
#define DW_x86_REG_EDI 7
#define DW_x86_REG_EIP 8
#define cfi_signal_frame_start(f) \
.section .eh_frame,"a",@progbits; \
.L ## f ## _START_EH_FRAME: \
.long 2f - 1f; /* CIE length. */ \
1:.long 0; /* CIE ID. */ \
.byte 1; /* Version. */ \
.string "zRS"; /* Augmentation string. */ \
.uleb128 1; /* Code alignment factor. */ \
.sleb128 -4; /* Data alignment factor. */ \
.uleb128 DW_x86_REG_EIP; /* Return address register. */ \
.uleb128 1; /* 1 byte of augmentation data. */ \
.byte (DW_EH_PE_pcrel|DW_EH_PE_sdata4); /* FDE encoding. */ \
.align 8; \
2: \
.long .L ## f ## _END_FDE - .L ## f ## _START_FDE; /* FDE length. */ \
.L ## f ## _START_FDE: \
.long .L ## f ## _START_FDE - .L ## f ## _START_EH_FRAME; /* CIE location. */ \
.long (.L ## f ## _START - 1) - .; /* pcrel start address (see FDE encoding above). */ \
.long .L ## f ## _END - (.L ## f ## _START - 1); /* Function this FDE applies to. */ \
.uleb128 0; /* FDE augmentation length. */ \
#define cfi_signal_frame_end(f) \
.L ## f ## _END_FDE: \
#define cfi_def_cfa(offset) \
.byte DW_CFA_def_cfa_expression; \
.uleb128 2f-1f; \
1:.byte DW_OP_breg4; \
.sleb128 offset; \
.byte DW_OP_deref; \
2: \
#define cfi_offset(reg_number,offset) \
.byte DW_CFA_expression; \
.uleb128 reg_number; \
.uleb128 2f-1f; \
1:.byte DW_OP_breg4; \
.sleb128 offset; \
2: \
ENTRY_PRIVATE(__restore)
.L__restore_START:
popl %eax
movl $__NR_sigreturn, %eax
int $0x80
.L__restore_END:
END(__restore)
cfi_signal_frame_start(__restore)
cfi_def_cfa(OFFSET_ESP + 4)
cfi_offset(DW_x86_REG_EDI, OFFSET_EDI + 4)
cfi_offset(DW_x86_REG_ESI, OFFSET_ESI + 4)
cfi_offset(DW_x86_REG_EBP, OFFSET_EBP + 4)
cfi_offset(DW_x86_REG_EBX, OFFSET_EBX + 4)
cfi_offset(DW_x86_REG_EDX, OFFSET_EDX + 4)
cfi_offset(DW_x86_REG_ECX, OFFSET_ECX + 4)
cfi_offset(DW_x86_REG_EAX, OFFSET_EAX + 4)
cfi_offset(DW_x86_REG_EIP, OFFSET_EIP + 4)
cfi_signal_frame_end(__restore)
ENTRY_PRIVATE(__restore_rt)
.L__restore_rt_START:
movl $__NR_rt_sigreturn, %eax
int $0x80
.L__restore_rt_END:
END(__restore_rt)
cfi_signal_frame_start(__restore_rt)
cfi_def_cfa(OFFSET_ESP + 160)
cfi_offset(DW_x86_REG_EDI, OFFSET_EDI + 160)
cfi_offset(DW_x86_REG_ESI, OFFSET_ESI + 160)
cfi_offset(DW_x86_REG_EBP, OFFSET_EBP + 160)
cfi_offset(DW_x86_REG_EBX, OFFSET_EBX + 160)
cfi_offset(DW_x86_REG_EDX, OFFSET_EDX + 160)
cfi_offset(DW_x86_REG_ECX, OFFSET_ECX + 160)
cfi_offset(DW_x86_REG_EAX, OFFSET_EAX + 160)
cfi_offset(DW_x86_REG_EIP, OFFSET_EIP + 160)
cfi_signal_frame_end(__restore_rt)

View File

@@ -59,5 +59,6 @@
#define R_386_TLS_GOTDESC 39
#define R_386_TLS_DESC_CALL 40
#define R_386_TLS_DESC 41
#define R_386_IRELATIVE 42
#define R_TYPE(name) __CONCAT(R_386_,name)

View File

@@ -1,31 +1,45 @@
# x86 specific configs
# 32-bit x86.
# These are shared by all the 32-bit targets, but not the 64-bit ones.
libc_common_src_files_x86 := \
#
# Various kinds of LP32 cruft.
#
libc_bionic_src_files_x86 += \
bionic/mmap.cpp \
libc_common_src_files_x86 += \
bionic/legacy_32_bit_support.cpp \
bionic/ndk_cruft.cpp \
bionic/time64.c \
libc_netbsd_src_files_x86 += \
upstream-netbsd/common/lib/libc/hash/sha1/sha1.c \
libc_openbsd_src_files_x86 += \
upstream-openbsd/lib/libc/stdio/putw.c \
# Fortify implementations of libc functions.
#
# Default implementations of functions that are commonly optimized.
#
libc_common_src_files_x86 += \
bionic/__memcpy_chk.cpp \
bionic/__memset_chk.cpp \
bionic/__strcpy_chk.cpp \
bionic/__strcat_chk.cpp \
libc_freebsd_src_files_x86 += \
upstream-freebsd/lib/libc/string/wmemmove.c \
#
# Inherently architecture-specific functions.
#
# These are shared by all the 32-bit targets, but not the 64-bit ones.
libc_bionic_src_files_x86 := \
bionic/mmap.cpp
##########################################
### CPU specific source files
libc_bionic_src_files_x86 += \
arch-x86/bionic/__bionic_clone.S \
arch-x86/bionic/_exit_with_stack_teardown.S \
arch-x86/bionic/libgcc_compat.c \
arch-x86/bionic/__restore.S \
arch-x86/bionic/_setjmp.S \
arch-x86/bionic/setjmp.S \
arch-x86/bionic/__set_tls.c \
@@ -41,9 +55,6 @@ endif
include $(arch_variant_mk)
libc_common_additional_dependencies += $(arch_variant_mk)
libc_netbsd_src_files_x86 := \
upstream-netbsd/common/lib/libc/hash/sha1/sha1.c \
arch_variant_mk :=
libc_crt_target_cflags_x86 := \

View File

@@ -0,0 +1,143 @@
/*
* Copyright (C) 2013 The Android Open Source Project
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <private/bionic_asm.h>
// DWARF constants.
#define DW_CFA_def_cfa_expression 0x0f
#define DW_CFA_expression 0x10
#define DW_EH_PE_pcrel 0x10
#define DW_EH_PE_sdata4 0x0b
#define DW_OP_breg4 0x74
#define DW_OP_breg7 0x77
#define DW_OP_deref 0x06
// Offsets into struct ucontext_t of uc_mcontext.gregs[x].
#define OFFSET_R8 40
#define OFFSET_R9 48
#define OFFSET_R10 56
#define OFFSET_R11 64
#define OFFSET_R12 72
#define OFFSET_R13 80
#define OFFSET_R14 88
#define OFFSET_R15 96
#define OFFSET_RDI 104
#define OFFSET_RSI 112
#define OFFSET_RBP 120
#define OFFSET_RSP 160
#define OFFSET_RBX 128
#define OFFSET_RDX 136
#define OFFSET_RAX 144
#define OFFSET_RCX 152
#define OFFSET_RIP 168
// Non-standard DWARF constants for the x86-64 registers.
#define DW_x86_64_RAX 0
#define DW_x86_64_RDX 1
#define DW_x86_64_RCX 2
#define DW_x86_64_RBX 3
#define DW_x86_64_RSI 4
#define DW_x86_64_RDI 5
#define DW_x86_64_RBP 6
#define DW_x86_64_RSP 7
#define DW_x86_64_R8 8
#define DW_x86_64_R9 9
#define DW_x86_64_R10 10
#define DW_x86_64_R11 11
#define DW_x86_64_R12 12
#define DW_x86_64_R13 13
#define DW_x86_64_R14 14
#define DW_x86_64_R15 15
#define DW_x86_64_RIP 16
#define cfi_signal_frame_start(f) \
.section .eh_frame,"a",@progbits; \
.L ## f ## _START_EH_FRAME: \
.long 2f - 1f; /* CIE length. */ \
1:.long 0; /* CIE ID. */ \
.byte 1; /* Version. */ \
.string "zRS"; /* Augmentation string. */ \
.uleb128 1; /* Code alignment factor. */ \
.sleb128 -8; /* Data alignment factor. */ \
.uleb128 DW_x86_64_RIP; /* Return address register. */ \
.uleb128 1; /* 1 byte of augmentation data. */ \
.byte (DW_EH_PE_pcrel | DW_EH_PE_sdata4); /* FDE encoding. */ \
.align 8; \
2: \
.long .L ## f ## _END_FDE - .L ## f ## _START_FDE; /* FDE length. */ \
.L ## f ## _START_FDE: \
.long .L ## f ## _START_FDE - .L ## f ## _START_EH_FRAME; /* CIE location. */ \
.long (.L ## f ## _START - 1) - .; /* pcrel start address (see FDE encoding above). */ \
.long .L ## f ## _END - (.L ## f ## _START - 1); /* Function this FDE applies to. */ \
.uleb128 0; /* FDE augmentation length. */ \
#define cfi_signal_frame_end(f) \
.L ## f ## _END_FDE: \
#define cfi_def_cfa(offset) \
.byte DW_CFA_def_cfa_expression; \
.uleb128 2f-1f; \
1:.byte DW_OP_breg7; \
.sleb128 offset; \
.byte DW_OP_deref; \
2: \
#define cfi_offset(reg_number,offset) \
.byte DW_CFA_expression; \
.uleb128 reg_number; \
.uleb128 2f-1f; \
1:.byte DW_OP_breg7; \
.sleb128 offset; \
2: \
ENTRY_PRIVATE(__restore_rt)
.L__restore_rt_START:
mov $__NR_rt_sigreturn, %rax
syscall
.L__restore_rt_END:
END(__restore_rt)
cfi_signal_frame_start(__restore_rt)
cfi_def_cfa(OFFSET_RSP)
cfi_offset(DW_x86_64_R8, OFFSET_R8)
cfi_offset(DW_x86_64_R9, OFFSET_R9)
cfi_offset(DW_x86_64_R10, OFFSET_R10)
cfi_offset(DW_x86_64_R11, OFFSET_R11)
cfi_offset(DW_x86_64_R12, OFFSET_R12)
cfi_offset(DW_x86_64_R13, OFFSET_R13)
cfi_offset(DW_x86_64_R14, OFFSET_R14)
cfi_offset(DW_x86_64_R15, OFFSET_R15)
cfi_offset(DW_x86_64_RDI, OFFSET_RDI)
cfi_offset(DW_x86_64_RSI, OFFSET_RSI)
cfi_offset(DW_x86_64_RBP, OFFSET_RBP)
cfi_offset(DW_x86_64_RSP, OFFSET_RSP)
cfi_offset(DW_x86_64_RBX, OFFSET_RBX)
cfi_offset(DW_x86_64_RDX, OFFSET_RDX)
cfi_offset(DW_x86_64_RAX, OFFSET_RAX)
cfi_offset(DW_x86_64_RCX, OFFSET_RCX)
cfi_offset(DW_x86_64_RIP, OFFSET_RIP)
cfi_signal_frame_end(__restore_rt)

View File

@@ -46,6 +46,8 @@
#define R_X86_64_GOTTPOFF 22
#define R_X86_64_TPOFF32 23
#define R_X86_64_IRELATIVE 37
#define R_TYPE(name) __CONCAT(R_X86_64_,name)
#else /* !__i386__ */

View File

@@ -1,11 +1,21 @@
# x86_64 specific configs
# 64-bit x86.
libc_common_src_files_x86_64 := \
#
# Default implementations of functions that are commonly optimized.
#
libc_bionic_src_files_x86_64 += \
bionic/__memcpy_chk.cpp \
bionic/__memset_chk.cpp \
bionic/__strcpy_chk.cpp \
bionic/__strcat_chk.cpp \
bionic/memchr.c \
bionic/memrchr.c \
bionic/strchr.cpp \
bionic/strnlen.c \
bionic/strrchr.cpp \
libc_freebsd_src_files_x86_64 += \
upstream-freebsd/lib/libc/string/wcscat.c \
upstream-freebsd/lib/libc/string/wcschr.c \
upstream-freebsd/lib/libc/string/wcscmp.c \
@@ -14,23 +24,19 @@ libc_common_src_files_x86_64 := \
upstream-freebsd/lib/libc/string/wcsrchr.c \
upstream-freebsd/lib/libc/string/wmemcmp.c \
upstream-freebsd/lib/libc/string/wmemmove.c \
libc_openbsd_src_files_x86_64 += \
upstream-openbsd/lib/libc/string/strlcat.c \
upstream-openbsd/lib/libc/string/strlcpy.c \
# Fortify implementations of libc functions.
libc_common_src_files_x86_64 += \
bionic/__memcpy_chk.cpp \
bionic/__memset_chk.cpp \
bionic/__strcpy_chk.cpp \
bionic/__strcat_chk.cpp \
#
# Inherently architecture-specific code.
#
##########################################
### CPU specific source files
libc_bionic_src_files_x86_64 := \
libc_bionic_src_files_x86_64 += \
arch-x86_64/bionic/__bionic_clone.S \
arch-x86_64/bionic/_exit_with_stack_teardown.S \
arch-x86_64/bionic/__rt_sigreturn.S \
arch-x86_64/bionic/__restore_rt.S \
arch-x86_64/bionic/_setjmp.S \
arch-x86_64/bionic/setjmp.S \
arch-x86_64/bionic/__set_tls.c \
@@ -38,6 +44,10 @@ libc_bionic_src_files_x86_64 := \
arch-x86_64/bionic/syscall.S \
arch-x86_64/bionic/vfork.S \
#
# Optimized memory/string functions.
#
libc_bionic_src_files_x86_64 += \
arch-x86_64/string/sse2-memcpy-slm.S \
arch-x86_64/string/sse2-memmove-slm.S \
@@ -55,15 +65,15 @@ libc_bionic_src_files_x86_64 += \
libc_crt_target_cflags_x86_64 += \
-m64 \
-I$(LOCAL_PATH)/arch-x86_64/include
-I$(LOCAL_PATH)/arch-x86_64/include \
libc_crt_target_ldflags_x86_64 := -melf_x86_64
libc_crt_target_ldflags_x86_64 := -melf_x86_64 \
libc_crt_target_crtbegin_file_x86_64 := \
$(LOCAL_PATH)/arch-common/bionic/crtbegin.c
$(LOCAL_PATH)/arch-common/bionic/crtbegin.c \
libc_crt_target_crtbegin_so_file_x86_64 := \
$(LOCAL_PATH)/arch-common/bionic/crtbegin_so.c
$(LOCAL_PATH)/arch-common/bionic/crtbegin_so.c \
libc_crt_target_so_cflags_x86_64 := \
-fPIC
-fPIC \

View File

@@ -43,8 +43,8 @@
* This fgets check is called if _FORTIFY_SOURCE is defined and
* greater than 0.
*/
extern "C" char* __fgets_chk(char* dest, int supplied_size,
FILE* stream, size_t dest_len_from_compiler) {
char* __fgets_chk(char* dest, int supplied_size, FILE* stream,
size_t dest_len_from_compiler) {
if (supplied_size < 0) {
__fortify_chk_fail("fgets: buffer size < 0", 0);
}

View File

@@ -32,9 +32,9 @@
#include <sys/socket.h>
#include "private/libc_logging.h"
extern "C"
ssize_t __recvfrom_chk(int socket, void* buf, size_t len, size_t buflen, unsigned int flags,
const struct sockaddr* src_addr, socklen_t* addrlen) {
ssize_t __recvfrom_chk(int socket, void* buf, size_t len, size_t buflen,
int flags, const struct sockaddr* src_addr,
socklen_t* addrlen) {
if (__predict_false(len > buflen)) {
__fortify_chk_fail("recvfrom: prevented write past end of buffer", 0);
}

View File

@@ -62,6 +62,11 @@ int dl_iterate_phdr(int (*cb)(struct dl_phdr_info* info, size_t size, void* data
// Try the VDSO if that didn't work.
ElfW(Ehdr)* ehdr_vdso = reinterpret_cast<ElfW(Ehdr)*>(getauxval(AT_SYSINFO_EHDR));
if (ehdr_vdso == nullptr) {
// There is no VDSO, so there's nowhere left to look.
return rc;
}
struct dl_phdr_info vdso_info;
vdso_info.dlpi_addr = 0;
vdso_info.dlpi_name = NULL;

View File

@@ -36,12 +36,20 @@
// struct __sfileext (see fileext.h).
void flockfile(FILE* fp) {
if (!__sdidinit) {
__sinit();
}
if (fp != NULL) {
pthread_mutex_lock(&_FLOCK(fp));
}
}
int ftrylockfile(FILE* fp) {
if (!__sdidinit) {
__sinit();
}
// The specification for ftrylockfile() says it returns 0 on success,
// or non-zero on error. So return an errno code directly on error.
if (fp == NULL) {
@@ -52,6 +60,10 @@ int ftrylockfile(FILE* fp) {
}
void funlockfile(FILE* fp) {
if (!__sdidinit) {
__sinit();
}
if (fp != NULL) {
pthread_mutex_unlock(&_FLOCK(fp));
}

View File

@@ -62,6 +62,7 @@ struct PosixTimer {
pthread_t callback_thread;
void (*callback)(sigval_t);
sigval_t callback_argument;
volatile bool armed;
};
static __kernel_timer_t to_kernel_timer_id(timer_t timer) {
@@ -83,7 +84,7 @@ static void* __timer_thread_start(void* arg) {
continue;
}
if (si.si_code == SI_TIMER) {
if (si.si_code == SI_TIMER && timer->armed) {
// This signal was sent because a timer fired, so call the callback.
timer->callback(timer->callback_argument);
} else if (si.si_code == SI_TKILL) {
@@ -95,6 +96,9 @@ static void* __timer_thread_start(void* arg) {
}
static void __timer_thread_stop(PosixTimer* timer) {
// Immediately mark the timer as disarmed so even if some events
// continue to happen, the callback won't be called.
timer->armed = false;
pthread_kill(timer->callback_thread, TIMER_SIGNAL);
}
@@ -121,6 +125,7 @@ int timer_create(clockid_t clock_id, sigevent* evp, timer_t* timer_id) {
// Otherwise, this must be SIGEV_THREAD timer...
timer->callback = evp->sigev_notify_function;
timer->callback_argument = evp->sigev_value;
timer->armed = false;
// Check arguments that the kernel doesn't care about but we do.
if (timer->callback == NULL) {
@@ -200,7 +205,18 @@ int timer_gettime(timer_t id, itimerspec* ts) {
// http://pubs.opengroup.org/onlinepubs/9699919799/functions/timer_getoverrun.html
int timer_settime(timer_t id, int flags, const itimerspec* ts, itimerspec* ots) {
return __timer_settime(to_kernel_timer_id(id), flags, ts, ots);
PosixTimer* timer= reinterpret_cast<PosixTimer*>(id);
int rc = __timer_settime(timer->kernel_timer_id, flags, ts, ots);
if (rc == 0) {
// Mark the timer as either being armed or disarmed. This avoids the
// callback being called after the disarm for SIGEV_THREAD timers only.
if (ts->it_value.tv_sec != 0 || ts->it_value.tv_nsec != 0) {
timer->armed = true;
} else {
timer->armed = false;
}
}
return rc;
}
// http://pubs.opengroup.org/onlinepubs/9699919799/functions/timer_getoverrun.html

View File

@@ -31,6 +31,7 @@
#include <inttypes.h>
#include <stdio.h>
#include <sys/resource.h>
#include <unistd.h>
#include "private/bionic_string_utils.h"
#include "private/ErrnoRestorer.h"
@@ -126,8 +127,12 @@ static int __pthread_attr_getstack_main_thread(void** stack_base, size_t* stack_
stack_limit.rlim_cur = 8 * 1024 * 1024;
}
// It doesn't matter which thread we are; we're just looking for "[stack]".
FILE* fp = fopen("/proc/self/maps", "re");
// It shouldn't matter which thread we are because we're just looking for "[stack]", but
// valgrind seems to mess with the stack enough that the kernel will report "[stack:pid]"
// instead if you look in /proc/self/maps, so we need to look in /proc/pid/task/pid/maps.
char path[64];
snprintf(path, sizeof(path), "/proc/self/task/%d/maps", getpid());
FILE* fp = fopen(path, "re");
if (fp == NULL) {
return errno;
}
@@ -143,7 +148,7 @@ static int __pthread_attr_getstack_main_thread(void** stack_base, size_t* stack_
}
}
}
__libc_fatal("No [stack] line found in /proc/self/maps!");
__libc_fatal("No [stack] line found in \"%s\"!", path);
}
int pthread_attr_getstack(const pthread_attr_t* attr, void** stack_base, size_t* stack_size) {

View File

@@ -28,27 +28,32 @@
#include <signal.h>
#if __LP64__
extern "C" void __rt_sigreturn(void);
extern "C" void __restore_rt(void);
extern "C" void __restore(void);
#if defined(__LP64__)
extern "C" int __rt_sigaction(int, const struct __kernel_sigaction*, struct __kernel_sigaction*, size_t);
#else
extern "C" int __sigaction(int, const struct sigaction*, struct sigaction*);
#endif
int sigaction(int signal, const struct sigaction* bionic_new_action, struct sigaction* bionic_old_action) {
#if __LP64__
__kernel_sigaction kernel_new_action;
if (bionic_new_action != NULL) {
kernel_new_action.sa_flags = bionic_new_action->sa_flags;
kernel_new_action.sa_handler = bionic_new_action->sa_handler;
kernel_new_action.sa_mask = bionic_new_action->sa_mask;
#ifdef SA_RESTORER
#if defined(SA_RESTORER)
kernel_new_action.sa_restorer = bionic_new_action->sa_restorer;
#if defined(__aarch64__)
// arm64 has sa_restorer, but unwinding works best if you just let the
// kernel supply the default restorer from [vdso]. gdb doesn't care, but
// libgcc needs the nop that the kernel includes before the actual code.
// (We could add that ourselves, but why bother?)
#else
if (!(kernel_new_action.sa_flags & SA_RESTORER)) {
kernel_new_action.sa_flags |= SA_RESTORER;
kernel_new_action.sa_restorer = &__rt_sigreturn;
kernel_new_action.sa_restorer = &__restore_rt;
}
#endif
#endif
}
@@ -62,19 +67,36 @@ int sigaction(int signal, const struct sigaction* bionic_new_action, struct siga
bionic_old_action->sa_flags = kernel_old_action.sa_flags;
bionic_old_action->sa_handler = kernel_old_action.sa_handler;
bionic_old_action->sa_mask = kernel_old_action.sa_mask;
#ifdef SA_RESTORER
#if defined(SA_RESTORER)
bionic_old_action->sa_restorer = kernel_old_action.sa_restorer;
if (bionic_old_action->sa_restorer == &__rt_sigreturn) {
bionic_old_action->sa_flags &= ~SA_RESTORER;
}
#endif
}
return result;
#else
// The 32-bit ABI is broken. struct sigaction includes a too-small sigset_t.
// TODO: if we also had correct struct sigaction definitions available, we could copy in and out.
return __sigaction(signal, bionic_new_action, bionic_old_action);
#endif
}
#else
extern "C" int __sigaction(int, const struct sigaction*, struct sigaction*);
int sigaction(int signal, const struct sigaction* bionic_new_action, struct sigaction* bionic_old_action) {
// The 32-bit ABI is broken. struct sigaction includes a too-small sigset_t,
// so we have to use sigaction(2) rather than rt_sigaction(2).
struct sigaction kernel_new_action;
if (bionic_new_action != NULL) {
kernel_new_action.sa_flags = bionic_new_action->sa_flags;
kernel_new_action.sa_handler = bionic_new_action->sa_handler;
kernel_new_action.sa_mask = bionic_new_action->sa_mask;
#if defined(SA_RESTORER)
kernel_new_action.sa_restorer = bionic_new_action->sa_restorer;
if (!(kernel_new_action.sa_flags & SA_RESTORER)) {
kernel_new_action.sa_flags |= SA_RESTORER;
kernel_new_action.sa_restorer = (kernel_new_action.sa_flags & SA_SIGINFO) ? &__restore_rt : &__restore;
}
#endif
}
return __sigaction(signal, (bionic_new_action != NULL) ? &kernel_new_action : NULL, bionic_old_action);
}
#endif

View File

@@ -150,7 +150,7 @@ static int __sysconf_monotonic_clock() {
return (rc == -1) ? -1 : _POSIX_VERSION;
}
int sysconf(int name) {
long sysconf(int name) {
switch (name) {
#ifdef _POSIX_ARG_MAX
case _SC_ARG_MAX: return _POSIX_ARG_MAX;

View File

@@ -475,8 +475,8 @@ static const prop_info *find_property(prop_bt *const trie, const char *name,
static int send_prop_msg(const prop_msg *msg)
{
const int fd = socket(AF_LOCAL, SOCK_STREAM, 0);
if (fd < 0) {
const int fd = socket(AF_LOCAL, SOCK_STREAM | SOCK_CLOEXEC, 0);
if (fd == -1) {
return -1;
}

View File

@@ -75,6 +75,9 @@ int android_getnameinfofornet(const struct sockaddr *, socklen_t, char *, size_t
/* delete the cache associated with a certain network */
extern void _resolv_delete_cache_for_net(unsigned netid);
/* set a port range for exclusion in the random_bind */
int _resolv_set_port_exclusion_range(in_port_t min, in_port_t max) __used_in_netd;
__END_DECLS
#endif /* _RESOLV_NETID_H */

View File

@@ -1,38 +0,0 @@
/* $NetBSD: __dn_comp.c,v 1.4 2005/09/13 01:44:10 christos Exp $ */
/*
* written by matthew green, 22/04/97.
* public domain.
*/
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
__RCSID("$NetBSD: __dn_comp.c,v 1.4 2005/09/13 01:44:10 christos Exp $");
#endif /* LIBC_SCCS and not lint */
#if defined(__indr_reference)
__indr_reference(__dn_comp,dn_comp)
#else
#include <sys/types.h>
#include <netinet/in.h>
#ifdef ANDROID_CHANGES
#include "resolv_private.h"
#else
#include <resolv.h>
#endif
/* XXX THIS IS A MESS! SEE <resolv.h> XXX */
#undef dn_comp
int dn_comp(const char *, u_char *, int, u_char **, u_char **);
int
dn_comp(const char *exp_dn, u_char *comp_dn, u_char **dnptrs,
u_char **lastdnptr, int length)
{
return __dn_comp(exp_dn, comp_dn, length, dnptrs, lastdnptr);
}
#endif

View File

@@ -1,33 +0,0 @@
/* $NetBSD: __res_close.c,v 1.4 2005/09/13 01:44:10 christos Exp $ */
/*
* written by matthew green, 22/04/97.
* public domain.
*/
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
__RCSID("$NetBSD: __res_close.c,v 1.4 2005/09/13 01:44:10 christos Exp $");
#endif /* LIBC_SCCS and not lint */
#if defined(__indr_reference)
__indr_reference(__res_close, res_close)
#else
#include <sys/types.h>
#include <netinet/in.h>
#include "resolv_private.h"
/* XXX THIS IS A MESS! SEE <resolv.h> XXX */
#undef res_close
void res_close(void);
void
res_close(void)
{
__res_close();
}
#endif

View File

@@ -1,37 +0,0 @@
/* $NetBSD: __res_send.c,v 1.4 2005/09/13 01:44:10 christos Exp $ */
/*
* written by matthew green, 22/04/97.
* public domain.
*/
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
__RCSID("$NetBSD: __res_send.c,v 1.4 2005/09/13 01:44:10 christos Exp $");
#endif
#if defined(__indr_reference)
__indr_reference(__res_send, res_send)
#else
#include <sys/types.h>
#include <netinet/in.h>
#ifdef ANDROID_CHANGES
#include "resolv_private.h"
#else
#include <resolv.h>
#endif
/* XXX THIS IS A MESS! SEE <resolv.h> XXX */
#undef res_send
int res_send(const u_char *, int, u_char *, int);
int
res_send(const u_char *buf, int buflen, u_char *ans, int anssiz)
{
return __res_send(buf, buflen, ans, anssiz);
}
#endif

View File

@@ -137,6 +137,10 @@ __RCSID("$NetBSD: res_send.c,v 1.9 2006/01/24 17:41:25 christos Exp $");
#define EXT(res) ((res)->_u._ext)
#define DBG 0
#define MAX_PORT (1 << (sizeof(in_port_t)*8))-1
#define DNS_MIN_PORT (IPPORT_RESERVED+1)
#define DNS_MAX_EXCLUDED_PORTS 5000
static const int highestFD = FD_SETSIZE - 1;
/* Forward. */
@@ -164,6 +168,27 @@ static int retrying_select(const int sock, fd_set *readset, fd_set *writeset,
const struct timespec *finish);
/* BIONIC-BEGIN: implement source port randomization */
static volatile in_port_t exclusion_min = 0;
static volatile in_port_t exclusion_max = 0;
int _resolv_set_port_exclusion_range(in_port_t min, in_port_t max)
{
if (min == 0 && max == 0) {
exclusion_min = exclusion_max = 0;
return 0;
}
if (min < DNS_MIN_PORT || min > max
|| (max - min > DNS_MAX_EXCLUDED_PORTS)) {
errno = ERANGE;
return -1;
}
exclusion_min = min;
exclusion_max = max;
return 0;
}
typedef union {
struct sockaddr sa;
struct sockaddr_in sin;
@@ -197,7 +222,13 @@ random_bind( int s, int family )
/* first try to bind to a random source port a few times */
for (j = 0; j < 10; j++) {
/* find a random port between 1025 .. 65534 */
int port = 1025 + (res_randomid() % (65535-1025));
in_port_t port;
do {
port = DNS_MIN_PORT + (res_randomid() % (MAX_PORT - DNS_MIN_PORT));
} while (exclusion_min
&& exclusion_max
&& port >= exclusion_min && port <= exclusion_max);
if (family == AF_INET)
u.sin.sin_port = htons(port);
else
@@ -402,6 +433,10 @@ res_nsend(res_state statp,
}
if (statp->nscount == 0) {
// We have no nameservers configured, so there's no point trying.
// Tell the cache the query failed, or any retries and anyone else asking the same
// question will block for PENDING_REQUEST_TIMEOUT seconds instead of failing fast.
_resolv_cache_query_failed(statp->netid, buf, buflen);
errno = ESRCH;
return (-1);
}

View File

@@ -54,12 +54,19 @@ enum {
*/
ANDROID_DLEXT_USE_LIBRARY_FD = 0x10,
/* If opening a library using library_fd read it starting at library_fd_offset.
* This flag is only valid when ANDROID_DLEXT_USE_LIBRARY_FD is set.
*/
ANDROID_DLEXT_USE_LIBRARY_FD_OFFSET = 0x20,
/* Mask of valid bits */
ANDROID_DLEXT_VALID_FLAG_BITS = ANDROID_DLEXT_RESERVED_ADDRESS |
ANDROID_DLEXT_RESERVED_ADDRESS_HINT |
ANDROID_DLEXT_WRITE_RELRO |
ANDROID_DLEXT_USE_RELRO |
ANDROID_DLEXT_USE_LIBRARY_FD,
ANDROID_DLEXT_USE_LIBRARY_FD |
ANDROID_DLEXT_USE_LIBRARY_FD_OFFSET,
};
typedef struct {
@@ -68,6 +75,7 @@ typedef struct {
size_t reserved_size;
int relro_fd;
int library_fd;
off64_t library_fd_offset;
} android_dlextinfo;
extern void* android_dlopen_ext(const char* filename, int flag, const android_dlextinfo* extinfo);

View File

@@ -25,6 +25,7 @@
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#ifndef _ARPA_INET_H_
#define _ARPA_INET_H_
@@ -34,8 +35,6 @@
__BEGIN_DECLS
typedef uint32_t in_addr_t;
in_addr_t inet_addr(const char*);
int inet_aton(const char*, struct in_addr*);
in_addr_t inet_lnaof(struct in_addr);

View File

@@ -518,9 +518,8 @@ typedef enum __ns_cert_types {
(cp) += NS_INT32SZ; \
} while (/*CONSTCOND*/0)
/*
* ANSI C identifier hiding for bind's lib/nameser.
*/
#if !defined(__LP64__)
/* Annoyingly, LP32 shipped with __ names. */
#define ns_msg_getflag __ns_msg_getflag
#define ns_get16 __ns_get16
#define ns_get32 __ns_get32
@@ -564,101 +563,73 @@ typedef enum __ns_cert_types {
#define ns_subdomain __ns_subdomain
#define ns_makecanon __ns_makecanon
#define ns_samename __ns_samename
#define ns_newmsg_init __ns_newmsg_init
#define ns_newmsg_copy __ns_newmsg_copy
#define ns_newmsg_id __ns_newmsg_id
#define ns_newmsg_flag __ns_newmsg_flag
#define ns_newmsg_q __ns_newmsg_q
#define ns_newmsg_rr __ns_newmsg_rr
#define ns_newmsg_done __ns_newmsg_done
#define ns_rdata_unpack __ns_rdata_unpack
#define ns_rdata_equal __ns_rdata_equal
#define ns_rdata_refers __ns_rdata_refers
#endif
__BEGIN_DECLS
int ns_msg_getflag(ns_msg, int);
uint16_t ns_get16(const u_char *);
uint32_t ns_get32(const u_char *);
void ns_put16(uint16_t, u_char *);
void ns_put32(uint32_t, u_char *);
int ns_initparse(const u_char *, int, ns_msg *);
int ns_skiprr(const u_char *, const u_char *, ns_sect, int);
int ns_parserr(ns_msg *, ns_sect, int, ns_rr *);
int ns_parserr2(ns_msg *, ns_sect, int, ns_rr2 *);
int ns_msg_getflag(ns_msg, int) __LIBC_ABI_PUBLIC__;
uint16_t ns_get16(const u_char *) __LIBC_ABI_PUBLIC__;
uint32_t ns_get32(const u_char *) __LIBC_ABI_PUBLIC__;
void ns_put16(uint16_t, u_char *) __LIBC_ABI_PUBLIC__;
void ns_put32(uint32_t, u_char *) __LIBC_ABI_PUBLIC__;
int ns_initparse(const u_char *, int, ns_msg *) __LIBC_ABI_PUBLIC__;
int ns_skiprr(const u_char *, const u_char *, ns_sect, int) __LIBC_ABI_PUBLIC__;
int ns_parserr(ns_msg *, ns_sect, int, ns_rr *) __LIBC_ABI_PUBLIC__;
int ns_parserr2(ns_msg *, ns_sect, int, ns_rr2 *) __LIBC_HIDDEN__;
int ns_sprintrr(const ns_msg *, const ns_rr *,
const char *, const char *, char *, size_t);
const char *, const char *, char *, size_t) __LIBC_ABI_PUBLIC__;
int ns_sprintrrf(const u_char *, size_t, const char *,
ns_class, ns_type, u_long, const u_char *,
size_t, const char *, const char *,
char *, size_t);
int ns_format_ttl(u_long, char *, size_t);
int ns_parse_ttl(const char *, u_long *);
uint32_t ns_datetosecs(const char *cp, int *errp);
int ns_name_ntol(const u_char *, u_char *, size_t);
int ns_name_ntop(const u_char *, char *, size_t);
int ns_name_pton(const char *, u_char *, size_t);
int ns_name_pton2(const char *, u_char *, size_t, size_t *);
char *, size_t) __LIBC_ABI_PUBLIC__;
int ns_format_ttl(u_long, char *, size_t) __LIBC_ABI_PUBLIC__;
int ns_parse_ttl(const char *, u_long *) __LIBC_ABI_PUBLIC__;
uint32_t ns_datetosecs(const char *cp, int *errp) __LIBC_ABI_PUBLIC__;
int ns_name_ntol(const u_char *, u_char *, size_t) __LIBC_ABI_PUBLIC__;
int ns_name_ntop(const u_char *, char *, size_t) __LIBC_ABI_PUBLIC__;
int ns_name_pton(const char *, u_char *, size_t) __LIBC_ABI_PUBLIC__;
int ns_name_pton2(const char *, u_char *, size_t, size_t *) __LIBC_HIDDEN__;
int ns_name_unpack(const u_char *, const u_char *,
const u_char *, u_char *, size_t);
const u_char *, u_char *, size_t) __LIBC_ABI_PUBLIC__;
int ns_name_unpack2(const u_char *, const u_char *,
const u_char *, u_char *, size_t,
size_t *);
size_t *) __LIBC_HIDDEN__;
int ns_name_pack(const u_char *, u_char *, int,
const u_char **, const u_char **);
const u_char **, const u_char **) __LIBC_ABI_PUBLIC__;
int ns_name_uncompress(const u_char *, const u_char *,
const u_char *, char *, size_t);
const u_char *, char *, size_t) __LIBC_ABI_PUBLIC__;
int ns_name_compress(const char *, u_char *, size_t,
const u_char **, const u_char **);
int ns_name_skip(const u_char **, const u_char *);
const u_char **, const u_char **) __LIBC_ABI_PUBLIC__;
int ns_name_skip(const u_char **, const u_char *) __LIBC_ABI_PUBLIC__;
void ns_name_rollback(const u_char *, const u_char **,
const u_char **);
const u_char **) __LIBC_ABI_PUBLIC__;
int ns_sign(u_char *, int *, int, int, void *,
const u_char *, int, u_char *, int *, time_t);
const u_char *, int, u_char *, int *, time_t) __LIBC_ABI_PUBLIC__;
int ns_sign2(u_char *, int *, int, int, void *,
const u_char *, int, u_char *, int *, time_t,
u_char **, u_char **);
ssize_t ns_name_length(ns_nname_ct, size_t);
int ns_name_eq(ns_nname_ct, size_t, ns_nname_ct, size_t);
int ns_name_owned(ns_namemap_ct, int, ns_namemap_ct, int);
int ns_name_map(ns_nname_ct, size_t, ns_namemap_t, int);
int ns_name_labels(ns_nname_ct, size_t);
u_char **, u_char **) __LIBC_ABI_PUBLIC__;
ssize_t ns_name_length(ns_nname_ct, size_t) __LIBC_HIDDEN__;
int ns_name_eq(ns_nname_ct, size_t, ns_nname_ct, size_t) __LIBC_HIDDEN__;
int ns_name_owned(ns_namemap_ct, int, ns_namemap_ct, int) __LIBC_HIDDEN__;
int ns_name_map(ns_nname_ct, size_t, ns_namemap_t, int) __LIBC_HIDDEN__;
int ns_name_labels(ns_nname_ct, size_t) __LIBC_HIDDEN__;
int ns_sign_tcp(u_char *, int *, int, int,
ns_tcp_tsig_state *, int);
ns_tcp_tsig_state *, int) __LIBC_ABI_PUBLIC__;
int ns_sign_tcp2(u_char *, int *, int, int,
ns_tcp_tsig_state *, int,
u_char **, u_char **);
u_char **, u_char **) __LIBC_ABI_PUBLIC__;
int ns_sign_tcp_init(void *, const u_char *, int,
ns_tcp_tsig_state *);
u_char *ns_find_tsig(u_char *, u_char *);
ns_tcp_tsig_state *) __LIBC_ABI_PUBLIC__;
u_char *ns_find_tsig(u_char *, u_char *) __LIBC_ABI_PUBLIC__;
int ns_verify(u_char *, int *, void *,
const u_char *, int, u_char *, int *,
time_t *, int);
time_t *, int) __LIBC_ABI_PUBLIC__;
int ns_verify_tcp(u_char *, int *, ns_tcp_tsig_state *, int);
int ns_verify_tcp_init(void *, const u_char *, int,
ns_tcp_tsig_state *);
int ns_samedomain(const char *, const char *);
int ns_subdomain(const char *, const char *);
int ns_makecanon(const char *, char *, size_t);
int ns_samename(const char *, const char *);
int ns_newmsg_init(u_char *buffer, size_t bufsiz, ns_newmsg *);
int ns_newmsg_copy(ns_newmsg *, ns_msg *);
void ns_newmsg_id(ns_newmsg *handle, uint16_t id);
void ns_newmsg_flag(ns_newmsg *handle, ns_flag flag, u_int value);
int ns_newmsg_q(ns_newmsg *handle, ns_nname_ct qname,
ns_type qtype, ns_class qclass);
int ns_newmsg_rr(ns_newmsg *handle, ns_sect sect,
ns_nname_ct name, ns_type type,
ns_class rr_class, uint32_t ttl,
uint16_t rdlen, const u_char *rdata);
size_t ns_newmsg_done(ns_newmsg *handle);
ssize_t ns_rdata_unpack(const u_char *, const u_char *, ns_type,
const u_char *, size_t, u_char *, size_t);
int ns_rdata_equal(ns_type,
const u_char *, size_t,
const u_char *, size_t);
int ns_rdata_refers(ns_type,
const u_char *, size_t,
const u_char *);
ns_tcp_tsig_state *) __LIBC_ABI_PUBLIC__;
int ns_samedomain(const char *, const char *) __LIBC_ABI_PUBLIC__;
int ns_subdomain(const char *, const char *) __LIBC_ABI_PUBLIC__;
int ns_makecanon(const char *, char *, size_t) __LIBC_ABI_PUBLIC__;
int ns_samename(const char *, const char *) __LIBC_ABI_PUBLIC__;
__END_DECLS
#ifdef BIND_4_COMPAT

View File

@@ -54,6 +54,35 @@ typedef struct {
#define DF_BIND_NOW 0x00000008
#define DF_STATIC_TLS 0x00000010
#define DF_1_NOW 0x00000001 // Perform complete relocation processing.
#define DF_1_GLOBAL 0x00000002 // implies RTLD_GLOBAL
#define DF_1_GROUP 0x00000004
#define DF_1_NODELETE 0x00000008 // implies RTLD_NODELETE
#define DF_1_LOADFLTR 0x00000010
#define DF_1_INITFIRST 0x00000020
#define DF_1_NOOPEN 0x00000040 // Object can not be used with dlopen(3)
#define DF_1_ORIGIN 0x00000080
#define DF_1_DIRECT 0x00000100
#define DF_1_TRANS 0x00000200
#define DF_1_INTERPOSE 0x00000400
#define DF_1_NODEFLIB 0x00000800
#define DF_1_NODUMP 0x00001000 // Object cannot be dumped with dldump(3)
#define DF_1_CONFALT 0x00002000
#define DF_1_ENDFILTEE 0x00004000
#define DF_1_DISPRELDNE 0x00008000
#define DF_1_DISPRELPND 0x00010000
#define DF_1_NODIRECT 0x00020000
#define DF_1_IGNMULDEF 0x00040000 // Internal use
#define DF_1_NOKSYMS 0x00080000 // Internal use
#define DF_1_NOHDR 0x00100000 // Internal use
#define DF_1_EDITED 0x00200000
#define DF_1_NORELOC 0x00400000 // Internal use
#define DF_1_SYMINTPOSE 0x00800000
#define DF_1_GLOBAUDIT 0x01000000
#define DF_1_SINGLETON 0x02000000
#define DF_1_STUB 0x04000000
#define DF_1_PIE 0x08000000
#define DT_BIND_NOW 24
#define DT_INIT_ARRAY 25
#define DT_FINI_ARRAY 26
@@ -69,14 +98,15 @@ typedef struct {
#define PT_GNU_RELRO 0x6474e552
#define STB_LOOS 10
#define STB_HIOS 12
#define STB_LOPROC 13
#define STB_HIPROC 15
#define STB_LOOS 10
#define STB_HIOS 12
#define STB_LOPROC 13
#define STB_HIPROC 15
#define STT_LOOS 10
#define STT_HIOS 12
#define STT_LOPROC 13
#define STT_HIPROC 15
#define STT_GNU_IFUNC 10
#define STT_LOOS 10
#define STT_HIOS 12
#define STT_LOPROC 13
#define STT_HIPROC 15
#endif /* _ELF_H */

View File

@@ -81,15 +81,15 @@ extern ssize_t tee(int, int, size_t, unsigned int);
extern int unlinkat(int, const char*, int);
extern ssize_t vmsplice(int, const struct iovec*, size_t, unsigned int);
#if defined(__BIONIC_FORTIFY)
extern int __open_2(const char*, int);
extern int __open_real(const char*, int, ...) __asm__(__USER_LABEL_PREFIX__ "open");
extern int __open_real(const char*, int, ...) __RENAME(open);
extern int __openat_2(int, const char*, int);
extern int __openat_real(int, const char*, int, ...) __asm__(__USER_LABEL_PREFIX__ "openat");
extern int __openat_real(int, const char*, int, ...) __RENAME(openat);
__errordecl(__creat_missing_mode, "called with O_CREAT, but missing mode");
__errordecl(__creat_too_many_args, "too many arguments");
#if defined(__BIONIC_FORTIFY)
#if !defined(__clang__)
__BIONIC_FORTIFY_INLINE

View File

@@ -25,6 +25,7 @@
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#ifndef _NETINET_IN_H_
#define _NETINET_IN_H_
@@ -43,6 +44,9 @@ __BEGIN_DECLS
#define INET_ADDRSTRLEN 16
typedef uint16_t in_port_t;
typedef uint32_t in_addr_t;
extern int bindresvport (int sd, struct sockaddr_in *sin);
static const struct in6_addr in6addr_any = IN6ADDR_ANY_INIT;

View File

@@ -48,6 +48,9 @@
# include <linux/signal.h>
#endif
#include <sys/ucontext.h>
#define __BIONIC_HAVE_UCONTEXT_T
__BEGIN_DECLS
typedef int sig_atomic_t;

View File

@@ -33,7 +33,7 @@
#include <sys/cdefs.h>
#if defined(__cplusplus) && defined(_USING_LIBCXX)
#if defined(__cplusplus) && __cplusplus >= 201103L && defined(_USING_LIBCXX)
# ifdef __clang__
# if __has_feature(cxx_atomic)
# define _STDATOMIC_HAVE_ATOMIC
@@ -89,6 +89,7 @@ using std::atomic_signal_fence;
using std::memory_order;
using std::memory_order_relaxed;
using std::memory_order_consume;
using std::memory_order_acquire;
using std::memory_order_release;
using std::memory_order_acq_rel;
using std::memory_order_seq_cst;

View File

@@ -47,6 +47,8 @@
#define __need_NULL
#include <stddef.h>
__BEGIN_DECLS
#define _FSTDIO /* Define for new stdio with functions. */
typedef off_t fpos_t; /* stdio file position type */
@@ -136,9 +138,7 @@ typedef struct __sFILE {
fpos_t _offset; /* current lseek offset */
} FILE;
__BEGIN_DECLS
extern FILE __sF[];
__END_DECLS
#define __SLBF 0x0001 /* line buffered */
#define __SNBF 0x0002 /* unbuffered */
@@ -208,7 +208,6 @@ __END_DECLS
/*
* Functions defined in ANSI C standard.
*/
__BEGIN_DECLS
void clearerr(FILE *);
int fclose(FILE *);
int feof(FILE *);
@@ -296,16 +295,12 @@ int vsscanf(const char * __restrict, const char * __restrict, __va_list)
__scanflike(2, 0);
#endif /* __ISO_C_VISIBLE >= 1999 || __BSD_VISIBLE */
__END_DECLS
/*
* Functions defined in POSIX 1003.1.
*/
#if __BSD_VISIBLE || __POSIX_VISIBLE || __XPG_VISIBLE
#define L_ctermid 1024 /* size for ctermid(); PATH_MAX */
__BEGIN_DECLS
FILE *fdopen(int, const char *);
int fileno(FILE *);
@@ -329,15 +324,12 @@ int putc_unlocked(int, FILE *);
int putchar_unlocked(int);
#endif /* __POSIX_VISIBLE >= 199506 */
__END_DECLS
#endif /* __BSD_VISIBLE || __POSIX_VISIBLE || __XPG_VISIBLE */
/*
* Routines that are purely local.
*/
#if __BSD_VISIBLE
__BEGIN_DECLS
int asprintf(char ** __restrict, const char * __restrict, ...)
__printflike(2, 3);
char *fgetln(FILE * __restrict, size_t * __restrict);
@@ -347,25 +339,26 @@ int setlinebuf(FILE *);
int vasprintf(char ** __restrict, const char * __restrict,
__va_list)
__printflike(2, 0);
__END_DECLS
/*
* Stdio function-access interface.
*/
__BEGIN_DECLS
FILE *funopen(const void *,
int (*)(void *, char *, int),
int (*)(void *, const char *, int),
fpos_t (*)(void *, fpos_t, int),
int (*)(void *));
__END_DECLS
#define fropen(cookie, fn) funopen(cookie, fn, 0, 0, 0)
#define fwopen(cookie, fn) funopen(cookie, 0, fn, 0, 0)
#endif /* __BSD_VISIBLE */
#if defined(__BIONIC_FORTIFY)
extern char* __fgets_chk(char*, int, FILE*, size_t);
extern char* __fgets_real(char*, int, FILE*) __RENAME(fgets);
__errordecl(__fgets_too_big_error, "fgets called with size bigger than buffer");
__errordecl(__fgets_too_small_error, "fgets called with size less than zero");
__BEGIN_DECLS
#if defined(__BIONIC_FORTIFY)
__BIONIC_FORTIFY_INLINE
__printflike(3, 0)
@@ -411,11 +404,6 @@ int sprintf(char *dest, const char *format, ...)
}
#endif
extern char* __fgets_chk(char*, int, FILE*, size_t);
extern char* __fgets_real(char*, int, FILE*) __asm__(__USER_LABEL_PREFIX__ "fgets");
__errordecl(__fgets_too_big_error, "fgets called with size bigger than buffer");
__errordecl(__fgets_too_small_error, "fgets called with size less than zero");
#if !defined(__clang__)
__BIONIC_FORTIFY_INLINE
@@ -450,8 +438,8 @@ char *fgets(char* dest, int size, FILE* stream) {
#endif /* !defined(__clang__) */
__END_DECLS
#endif /* defined(__BIONIC_FORTIFY) */
__END_DECLS
#endif /* _STDIO_H_ */

View File

@@ -92,16 +92,18 @@ extern size_t strxfrm(char* __restrict, const char* __restrict, size_t);
extern int strcoll_l(const char *, const char *, locale_t) __purefunc;
extern size_t strxfrm_l(char* __restrict, const char* __restrict, size_t, locale_t);
extern char* __stpncpy_chk2(char* __restrict, const char* __restrict, size_t, size_t, size_t);
extern char* __strncpy_chk2(char* __restrict, const char* __restrict, size_t, size_t, size_t);
extern size_t __strlcpy_real(char* __restrict, const char* __restrict, size_t) __RENAME(strlcpy);
extern size_t __strlcpy_chk(char *, const char *, size_t, size_t);
extern size_t __strlcat_real(char* __restrict, const char* __restrict, size_t) __RENAME(strlcat);
extern size_t __strlcat_chk(char* __restrict, const char* __restrict, size_t, size_t);
#if defined(__BIONIC_FORTIFY)
__BIONIC_FORTIFY_INLINE
void* memcpy(void* __restrict dest, const void* __restrict src, size_t copy_amount) {
char *d = (char *) dest;
const char *s = (const char *) src;
size_t s_len = __bos0(s);
size_t d_len = __bos0(d);
return __builtin___memcpy_chk(dest, src, copy_amount, d_len);
return __builtin___memcpy_chk(dest, src, copy_amount, __bos0(dest));
}
__BIONIC_FORTIFY_INLINE
@@ -119,8 +121,6 @@ char* strcpy(char* __restrict dest, const char* __restrict src) {
return __builtin___strcpy_chk(dest, src, __bos(dest));
}
extern char* __stpncpy_chk2(char* __restrict, const char* __restrict, size_t, size_t, size_t);
__BIONIC_FORTIFY_INLINE
char* stpncpy(char* __restrict dest, const char* __restrict src, size_t n) {
size_t bos_dest = __bos(dest);
@@ -142,8 +142,6 @@ char* stpncpy(char* __restrict dest, const char* __restrict src, size_t n) {
return __stpncpy_chk2(dest, src, n, bos_dest, bos_src);
}
extern char* __strncpy_chk2(char* __restrict, const char* __restrict, size_t, size_t, size_t);
__BIONIC_FORTIFY_INLINE
char* strncpy(char* __restrict dest, const char* __restrict src, size_t n) {
size_t bos_dest = __bos(dest);
@@ -180,10 +178,6 @@ void* memset(void *s, int c, size_t n) {
return __builtin___memset_chk(s, c, n, __bos0(s));
}
extern size_t __strlcpy_real(char* __restrict, const char* __restrict, size_t)
__asm__(__USER_LABEL_PREFIX__ "strlcpy");
extern size_t __strlcpy_chk(char *, const char *, size_t, size_t);
__BIONIC_FORTIFY_INLINE
size_t strlcpy(char* __restrict dest, const char* __restrict src, size_t size) {
size_t bos = __bos(dest);
@@ -204,10 +198,6 @@ size_t strlcpy(char* __restrict dest, const char* __restrict src, size_t size) {
return __strlcpy_chk(dest, src, size, bos);
}
extern size_t __strlcat_real(char* __restrict, const char* __restrict, size_t)
__asm__(__USER_LABEL_PREFIX__ "strlcat");
extern size_t __strlcat_chk(char* __restrict, const char* __restrict, size_t, size_t);
__BIONIC_FORTIFY_INLINE
size_t strlcat(char* __restrict dest, const char* __restrict src, size_t size) {

View File

@@ -81,6 +81,7 @@ struct prop_msg
#define PROP_PATH_RAMDISK_DEFAULT "/default.prop"
#define PROP_PATH_SYSTEM_BUILD "/system/build.prop"
#define PROP_PATH_SYSTEM_DEFAULT "/system/default.prop"
#define PROP_PATH_VENDOR_BUILD "/vendor/build.prop"
#define PROP_PATH_LOCAL_OVERRIDE "/data/local.prop"
#define PROP_PATH_FACTORY "/factory/factory.prop"

View File

@@ -53,6 +53,9 @@
#ifndef __has_builtin
#define __has_builtin(x) 0
#endif
#ifndef __has_attribute
#define __has_attribute(x) 0
#endif
/*
@@ -267,20 +270,6 @@
#endif /* NO_KERNEL_RCSIDS */
#endif /* _KERNEL */
#if !defined(_STANDALONE) && !defined(_KERNEL)
#ifdef __GNUC__
#define __RENAME(x) ___RENAME(x)
#else
#ifdef __lint__
#define __RENAME(x) __symbolrename(x)
#else
#error "No function renaming possible"
#endif /* __lint__ */
#endif /* __GNUC__ */
#else /* _STANDALONE || _KERNEL */
#define __RENAME(x) no renaming in kernel or standalone environment
#endif
/*
* A barrier to stop the optimizer from moving code or assume live
* register values. This is gcc specific, the version is more or less
@@ -359,60 +348,15 @@
#endif
/*
* Macros for manipulating "link sets". Link sets are arrays of pointers
* to objects, which are gathered up by the linker.
*
* Object format-specific code has provided us with the following macros:
*
* __link_set_add_text(set, sym)
* Add a reference to the .text symbol `sym' to `set'.
*
* __link_set_add_rodata(set, sym)
* Add a reference to the .rodata symbol `sym' to `set'.
*
* __link_set_add_data(set, sym)
* Add a reference to the .data symbol `sym' to `set'.
*
* __link_set_add_bss(set, sym)
* Add a reference to the .bss symbol `sym' to `set'.
*
* __link_set_decl(set, ptype)
* Provide an extern declaration of the set `set', which
* contains an array of the pointer type `ptype'. This
* macro must be used by any code which wishes to reference
* the elements of a link set.
*
* __link_set_start(set)
* This points to the first slot in the link set.
*
* __link_set_end(set)
* This points to the (non-existent) slot after the last
* entry in the link set.
*
* __link_set_count(set)
* Count the number of entries in link set `set'.
*
* In addition, we provide the following macros for accessing link sets:
*
* __link_set_foreach(pvar, set)
* Iterate over the link set `set'. Because a link set is
* an array of pointers, pvar must be declared as "type **pvar",
* and the actual entry accessed as "*pvar".
*
* __link_set_entry(set, idx)
* Access the link set entry at index `idx' from set `set'.
* Some BSD source needs these macros.
* Originally they embedded the rcs versions of each source file
* in the generated binary. We strip strings during build anyway,.
*/
#define __link_set_foreach(pvar, set) \
for (pvar = __link_set_start(set); pvar < __link_set_end(set); pvar++)
#define __link_set_entry(set, idx) (__link_set_begin(set)[idx])
/*
* Some of the FreeBSD sources used in Bionic need this.
* Originally, this is used to embed the rcs versions of each source file
* in the generated binary. We certainly don't want this in Bionic.
*/
#define __FBSDID(s) /* nothing */
#define __IDSTRING(_prefix,_s) /* nothing */
#define __COPYRIGHT(_s) /* nothing */
#define __FBSDID(_s) /* nothing */
#define __RCSID(_s) /* nothing */
#define __SCCSID(_s) /* nothing */
/*-
* The following definitions are an extension of the behavior originally
@@ -570,11 +514,28 @@
#endif
#define __bos0(s) __builtin_object_size((s), 0)
#define __BIONIC_FORTIFY_INLINE \
extern __inline__ \
__attribute__ ((always_inline)) \
__attribute__ ((gnu_inline))
#if __GNUC_PREREQ(4,3) || __has_attribute(__artificial__)
#define __BIONIC_FORTIFY_INLINE extern __inline__ __always_inline __attribute__((gnu_inline)) __attribute__((__artificial__))
#else
#define __BIONIC_FORTIFY_INLINE extern __inline__ __always_inline __attribute__((gnu_inline))
#endif
#endif
#define __BIONIC_FORTIFY_UNKNOWN_SIZE ((size_t) -1)
/* Used to tag non-static symbols that are private and never exposed by the shared library. */
#define __LIBC_HIDDEN__ __attribute__((visibility("hidden")))
/* Like __LIBC_HIDDEN__, but preserves binary compatibility for LP32. */
#ifdef __LP64__
#define __LIBC64_HIDDEN__ __LIBC_HIDDEN__
#else
#define __LIBC64_HIDDEN__ __LIBC_ABI_PUBLIC__
#endif
/* Used to tag non-static symbols that are public and exposed by the shared library. */
#define __LIBC_ABI_PUBLIC__ __attribute__((visibility ("default")))
/* Used to rename functions so that the compiler emits a call to 'x' rather than the function this was applied to. */
#define __RENAME(x) __asm__(#x)
#endif /* !_SYS_CDEFS_H_ */

View File

@@ -30,27 +30,13 @@
#ifndef _SYS_CDEFS_ELF_H_
#define _SYS_CDEFS_ELF_H_
#ifdef __LEADING_UNDERSCORE
#define _C_LABEL(x) __CONCAT(_,x)
#define _C_LABEL_STRING(x) "_"x
#else
#define _C_LABEL(x) x
#define _C_LABEL_STRING(x) x
#endif
#define __strong_alias(alias, sym) \
__asm__(".global " #alias "\n" \
#alias " = " #sym);
#define ___RENAME(x) __asm__(___STRING(_C_LABEL(x)))
#define __indr_reference(sym,alias) /* nada, since we do weak refs */
#define __strong_alias(alias,sym) \
__asm__(".global " _C_LABEL_STRING(#alias) "\n" \
_C_LABEL_STRING(#alias) " = " _C_LABEL_STRING(#sym));
#define __weak_alias(alias,sym) \
__asm__(".weak " _C_LABEL_STRING(#alias) "\n" \
_C_LABEL_STRING(#alias) " = " _C_LABEL_STRING(#sym));
#define __weak_extern(sym) \
__asm__(".weak " _C_LABEL_STRING(#sym));
#define __weak_alias(alias,sym) \
__asm__(".weak " #alias "\n" \
#alias " = " #sym);
/* We use __warnattr instead of __warn_references.
* TODO: remove this and put an empty definition in one of the upstream-* compatibility headers.
@@ -58,74 +44,4 @@
#define __warn_references(sym,msg) \
/*__asm__(".section .gnu.warning." #sym "\n\t.ascii \"" msg "\"\n\t.text");*/
#define __SECTIONSTRING(_sec, _str) \
__asm__(".section " #_sec "\n\t.asciz \"" _str "\"\n\t.previous")
/* Used to tag non-static symbols that are private and never exposed by the shared library. */
#define __LIBC_HIDDEN__ __attribute__((visibility ("hidden")))
/* Like __LIBC_HIDDEN__, but preserves binary compatibility for LP32. */
#ifdef __LP64__
#define __LIBC64_HIDDEN__ __LIBC_HIDDEN__
#else
#define __LIBC64_HIDDEN__ __LIBC_ABI_PUBLIC__
#endif
/* Used to tag non-static symbols that are public and exposed by the shared library. */
#define __LIBC_ABI_PUBLIC__ __attribute__((visibility ("default")))
#define __IDSTRING(_n,_s) __SECTIONSTRING(.ident,_s)
#define __RCSID(_s) __IDSTRING(rcsid,_s)
#define __SCCSID(_s)
#define __SCCSID2(_s)
#if 0 /* XXX userland __COPYRIGHTs have \ns in them */
#define __COPYRIGHT(_s) __SECTIONSTRING(.copyright,_s)
#else
#define __COPYRIGHT(_s) \
static const char copyright[] \
__attribute__((__unused__,__section__(".copyright"))) = _s
#endif
#define __KERNEL_RCSID(_n, _s) __RCSID(_s)
#define __KERNEL_SCCSID(_n, _s)
#if 0 /* XXX see above */
#define __KERNEL_COPYRIGHT(_n, _s) __COPYRIGHT(_s)
#else
#define __KERNEL_COPYRIGHT(_n, _s) __SECTIONSTRING(.copyright, _s)
#endif
#ifndef __lint__
#define __link_set_make_entry(set, sym) \
static void const * const __link_set_##set##_sym_##sym \
__section("link_set_" #set) __used = &sym
#define __link_set_make_entry2(set, sym, n) \
static void const * const __link_set_##set##_sym_##sym##_##n \
__section("link_set_" #set) __used = &sym[n]
#else
#define __link_set_make_entry(set, sym) \
extern void const * const __link_set_##set##_sym_##sym
#define __link_set_make_entry2(set, sym, n) \
extern void const * const __link_set_##set##_sym_##sym##_##n
#endif /* __lint__ */
#define __link_set_add_text(set, sym) __link_set_make_entry(set, sym)
#define __link_set_add_rodata(set, sym) __link_set_make_entry(set, sym)
#define __link_set_add_data(set, sym) __link_set_make_entry(set, sym)
#define __link_set_add_bss(set, sym) __link_set_make_entry(set, sym)
#define __link_set_add_text2(set, sym, n) __link_set_make_entry2(set, sym, n)
#define __link_set_add_rodata2(set, sym, n) __link_set_make_entry2(set, sym, n)
#define __link_set_add_data2(set, sym, n) __link_set_make_entry2(set, sym, n)
#define __link_set_add_bss2(set, sym, n) __link_set_make_entry2(set, sym, n)
#define __link_set_decl(set, ptype) \
extern ptype * const __start_link_set_##set[]; \
extern ptype * const __stop_link_set_##set[] \
#define __link_set_start(set) (__start_link_set_##set)
#define __link_set_end(set) (__stop_link_set_##set)
#define __link_set_count(set) \
(__link_set_end(set) - __link_set_start(set))
#endif /* !_SYS_CDEFS_ELF_H_ */

View File

@@ -51,10 +51,11 @@ typedef struct {
#define FD_ZERO(set) (memset(set, 0, sizeof(*(fd_set*)(set))))
#if defined(__BIONIC_FORTIFY)
extern void __FD_CLR_chk(int, fd_set*, size_t);
extern void __FD_SET_chk(int, fd_set*, size_t);
extern int __FD_ISSET_chk(int, fd_set*, size_t);
#if defined(__BIONIC_FORTIFY)
#define FD_CLR(fd, set) __FD_CLR_chk(fd, set, __bos(set))
#define FD_SET(fd, set) __FD_SET_chk(fd, set, __bos(set))
#define FD_ISSET(fd, set) __FD_ISSET_chk(fd, set, __bos(set))

View File

@@ -291,11 +291,11 @@ extern ssize_t recv(int, void*, size_t, int);
__socketcall ssize_t sendto(int, const void*, size_t, int, const struct sockaddr*, socklen_t);
__socketcall ssize_t recvfrom(int, void*, size_t, int, const struct sockaddr*, socklen_t*);
#if defined(__BIONIC_FORTIFY)
__errordecl(__recvfrom_error, "recvfrom called with size bigger than buffer");
extern ssize_t __recvfrom_chk(int, void*, size_t, size_t, int, const struct sockaddr*, socklen_t*);
extern ssize_t __recvfrom_real(int, void*, size_t, int, const struct sockaddr*, socklen_t*)
__asm__(__USER_LABEL_PREFIX__ "recvfrom");
extern ssize_t __recvfrom_real(int, void*, size_t, int, const struct sockaddr*, socklen_t*) __RENAME(recvfrom);
#if defined(__BIONIC_FORTIFY)
__BIONIC_FORTIFY_INLINE
ssize_t recvfrom(int fd, void* buf, size_t len, int flags, const struct sockaddr* src_addr, socklen_t* addr_len) {

View File

@@ -159,12 +159,12 @@ extern int stat64(const char*, struct stat64*);
extern int mknod(const char*, mode_t, dev_t);
extern mode_t umask(mode_t);
#if defined(__BIONIC_FORTIFY)
extern mode_t __umask_chk(mode_t);
extern mode_t __umask_real(mode_t) __asm__(__USER_LABEL_PREFIX__ "umask");
extern mode_t __umask_real(mode_t) __RENAME(umask);
__errordecl(__umask_invalid_mode, "umask called with invalid mode");
#if defined(__BIONIC_FORTIFY)
__BIONIC_FORTIFY_INLINE
mode_t umask(mode_t mode) {
#if !defined(__clang__)

View File

@@ -129,7 +129,7 @@ __BEGIN_DECLS
#define _SC_AVPHYS_PAGES 0x0063
#define _SC_MONOTONIC_CLOCK 0x0064
extern int sysconf(int name);
long sysconf(int);
__END_DECLS

View File

@@ -68,11 +68,9 @@ typedef struct ucontext {
struct ucontext* uc_link;
stack_t uc_stack;
mcontext_t uc_mcontext;
sigset_t uc_sigmask;
// Android has a wrong (smaller) sigset_t on ARM.
union {
sigset_t bionic;
uint32_t kernel[2];
} uc_sigmask;
uint32_t __padding_rt_sigset;
// The kernel adds extra padding after uc_sigmask to match glibc sigset_t on ARM.
char __padding[120];
unsigned long uc_regspace[128] __attribute__((__aligned__(8)));
@@ -80,6 +78,10 @@ typedef struct ucontext {
#elif defined(__aarch64__)
#define NGREG 34 /* x0..x30 + sp + pc + pstate */
typedef unsigned long greg_t;
typedef greg_t gregset_t[NGREG];
#include <asm/sigcontext.h>
typedef struct sigcontext mcontext_t;
@@ -152,11 +154,9 @@ typedef struct ucontext {
struct ucontext* uc_link;
stack_t uc_stack;
mcontext_t uc_mcontext;
sigset_t uc_sigmask;
// Android has a wrong (smaller) sigset_t on x86.
union {
sigset_t bionic;
uint32_t kernel[2];
} uc_sigmask;
uint32_t __padding_rt_sigset;
struct _libc_fpstate __fpregs_mem;
} ucontext_t;

View File

@@ -91,7 +91,7 @@ struct user {
unsigned long start_stack;
long int signal;
int reserved;
unsigned long u_ar0;
struct user_regs_struct* u_ar0;
struct user_fpregs_struct* u_fpstate;
unsigned long magic;
char u_comm[32];
@@ -108,7 +108,7 @@ struct user_fpregs_struct {
__u64 rip;
__u64 rdp;
__u32 mxcsr;
__u32 mxcsr_mask;
__u32 mxcr_mask;
__u32 st_space[32];
__u32 xmm_space[64];
__u32 padding[24];
@@ -155,7 +155,7 @@ struct user {
long int signal;
int reserved;
int pad1;
unsigned long u_ar0;
struct user_regs_struct* u_ar0;
struct user_fpregs_struct* u_fpstate;
unsigned long magic;
char u_comm[32];
@@ -175,7 +175,7 @@ struct user {
unsigned long start_data;
unsigned long start_stack;
long int signal;
unsigned long u_ar0;
void* u_ar0;
unsigned long magic;
char u_comm[32];
};

View File

@@ -177,7 +177,7 @@ extern int acct(const char* filepath);
int getpagesize(void);
extern int sysconf(int name);
long sysconf(int);
extern int daemon(int, int);
@@ -197,12 +197,12 @@ extern int tcsetpgrp(int fd, pid_t _pid);
} while (_rc == -1 && errno == EINTR); \
_rc; })
#if defined(__BIONIC_FORTIFY)
extern ssize_t __read_chk(int, void*, size_t, size_t);
__errordecl(__read_dest_size_error, "read called with size bigger than destination");
__errordecl(__read_count_toobig_error, "read called with count > SSIZE_MAX");
extern ssize_t __read_real(int, void*, size_t)
__asm__(__USER_LABEL_PREFIX__ "read");
extern ssize_t __read_real(int, void*, size_t) __RENAME(read);
#if defined(__BIONIC_FORTIFY)
__BIONIC_FORTIFY_INLINE
ssize_t read(int fd, void* buf, size_t count) {

View File

@@ -14,8 +14,10 @@
* limitations under the License.
*/
#ifndef SCOPE_GUARD_H
#define SCOPE_GUARD_H
#ifndef _SCOPE_GUARD_H
#define _SCOPE_GUARD_H
#include "private/bionic_macros.h"
// TODO: include explicit std::move when it becomes available
template<typename F>
@@ -40,14 +42,12 @@ class ScopeGuard {
F f_;
bool active_;
ScopeGuard() = delete;
ScopeGuard(const ScopeGuard&) = delete;
ScopeGuard& operator=(const ScopeGuard&) = delete;
DISALLOW_IMPLICIT_CONSTRUCTORS(ScopeGuard);
};
template<typename T>
ScopeGuard<T> create_scope_guard(T f) {
ScopeGuard<T> make_scope_guard(T f) {
return ScopeGuard<T>(f);
}
#endif // SCOPE_GUARD_H
#endif // _SCOPE_GUARD_H

140
libc/private/UniquePtr.h Normal file
View File

@@ -0,0 +1,140 @@
/*
* Copyright (C) 2010 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef UNIQUE_PTR_H_included
#define UNIQUE_PTR_H_included
// Default deleter for pointer types.
template <typename T>
struct DefaultDelete {
enum { type_must_be_complete = sizeof(T) };
DefaultDelete() {}
void operator()(T* p) const {
delete p;
}
};
// Default deleter for array types.
template <typename T>
struct DefaultDelete<T[]> {
enum { type_must_be_complete = sizeof(T) };
void operator()(T* p) const {
delete[] p;
}
};
// A smart pointer that deletes the given pointer on destruction.
// Equivalent to C++0x's std::unique_ptr (a combination of boost::scoped_ptr
// and boost::scoped_array).
// Named to be in keeping with Android style but also to avoid
// collision with any other implementation, until we can switch over
// to unique_ptr.
// Use thus:
// UniquePtr<C> c(new C);
template <typename T, typename D = DefaultDelete<T> >
class UniquePtr {
public:
// Construct a new UniquePtr, taking ownership of the given raw pointer.
explicit UniquePtr(T* ptr = nullptr) : mPtr(ptr) { }
UniquePtr(UniquePtr<T, D>&& that) {
mPtr = that.mPtr;
that.mPtr = nullptr;
}
~UniquePtr() {
reset();
}
// Accessors.
T& operator*() const { return *mPtr; }
T* operator->() const { return mPtr; }
T* get() const { return mPtr; }
// Returns the raw pointer and hands over ownership to the caller.
// The pointer will not be deleted by UniquePtr.
T* release() __attribute__((warn_unused_result)) {
T* result = mPtr;
mPtr = nullptr;
return result;
}
// Takes ownership of the given raw pointer.
// If this smart pointer previously owned a different raw pointer, that
// raw pointer will be freed.
void reset(T* ptr = nullptr) {
if (ptr != mPtr) {
D()(mPtr);
mPtr = ptr;
}
}
private:
// The raw pointer.
T* mPtr;
// Comparing unique pointers is probably a mistake, since they're unique.
template <typename T2> bool operator==(const UniquePtr<T2>& p) const = delete;
template <typename T2> bool operator!=(const UniquePtr<T2>& p) const = delete;
// Disallow copy and assignment.
UniquePtr(const UniquePtr&) = delete;
void operator=(const UniquePtr&) = delete;
};
// Partial specialization for array types. Like std::unique_ptr, this removes
// operator* and operator-> but adds operator[].
template <typename T, typename D>
class UniquePtr<T[], D> {
public:
explicit UniquePtr(T* ptr = NULL) : mPtr(ptr) {
}
UniquePtr(UniquePtr<T, D>&& that) {
mPtr = that.mPtr;
that.mPtr = nullptr;
}
~UniquePtr() {
reset();
}
T& operator[](size_t i) const {
return mPtr[i];
}
T* get() const { return mPtr; }
T* release() __attribute__((warn_unused_result)) {
T* result = mPtr;
mPtr = NULL;
return result;
}
void reset(T* ptr = NULL) {
if (ptr != mPtr) {
D()(mPtr);
mPtr = ptr;
}
}
private:
T* mPtr;
// Disallow copy and assignment.
UniquePtr(const UniquePtr&) = delete;
void operator=(const UniquePtr&) = delete;
};
#endif // UNIQUE_PTR_H_included

View File

@@ -20,8 +20,8 @@
// DISALLOW_COPY_AND_ASSIGN disallows the copy and operator= functions.
// It goes in the private: declarations in a class.
#define DISALLOW_COPY_AND_ASSIGN(TypeName) \
TypeName(const TypeName&); \
void operator=(const TypeName&)
TypeName(const TypeName&) = delete; \
void operator=(const TypeName&) = delete
// A macro to disallow all the implicit constructors, namely the
// default constructor, copy constructor and operator= functions.
@@ -30,7 +30,7 @@
// that wants to prevent anyone from instantiating it. This is
// especially useful for classes containing only static methods.
#define DISALLOW_IMPLICIT_CONSTRUCTORS(TypeName) \
TypeName(); \
TypeName() = delete; \
DISALLOW_COPY_AND_ASSIGN(TypeName)
#define BIONIC_ALIGN(value, alignment) \

View File

@@ -34,6 +34,8 @@
#include <pthread.h>
__BEGIN_DECLS
/*
* file extension
*/
@@ -63,4 +65,6 @@ do { \
_FILEEXT_INIT(f); \
} while (0)
__END_DECLS
#endif /* _FILEEXT_H_ */

View File

@@ -44,15 +44,17 @@
#define ALIGNBYTES (sizeof(uintptr_t) - 1)
#define ALIGN(p) (((uintptr_t)(p) + ALIGNBYTES) &~ ALIGNBYTES)
#undef stdin
#undef stdout
#undef stderr
int __sdidinit;
#define NDYNAMIC 10 /* add ten more whenever necessary */
#define std(flags, file) \
{0,0,0,flags,file,{0,0},0,__sF+file,__sclose,__sread,__sseek,__swrite, \
{(unsigned char *)(__sFext+file), 0},NULL,0,{0,0,0},{0},{0,0},0,0}
/* p r w flags file _bf z cookie close read seek write
ext */
{0,0,0,flags,file,{0},0,__sF+file,__sclose,__sread,__sseek,__swrite, \
{(unsigned char *)(__sFext+file), 0},NULL,0,{0},{0},{0},0,0}
/* the usual - (stdin + stdout + stderr) */
static FILE usual[FOPEN_MAX - 3];
@@ -67,6 +69,9 @@ FILE __sF[3] = {
std(__SWR, STDOUT_FILENO), /* stdout */
std(__SWR|__SNBF, STDERR_FILENO) /* stderr */
};
FILE* stdin = &__sF[0];
FILE* stdout = &__sF[1];
FILE* stderr = &__sF[2];
struct glue __sglue = { &uglue, 3, __sF };
static struct glue *
@@ -165,17 +170,26 @@ void
__sinit(void)
{
_THREAD_PRIVATE_MUTEX(__sinit_mutex);
int i;
_THREAD_PRIVATE_MUTEX_LOCK(__sinit_mutex);
if (__sdidinit)
goto out; /* bail out if caller lost the race */
for (i = 0; i < FOPEN_MAX - 3; i++) {
if (__sdidinit) {
/* bail out if caller lost the race */
_THREAD_PRIVATE_MUTEX_UNLOCK(__sinit_mutex);
return;
}
/* Initialize stdin/stdout/stderr (for the recursive mutex). http://b/18208568. */
for (size_t i = 0; i < 3; ++i) {
_FILEEXT_SETUP(__sF+i, __sFext+i);
}
/* Initialize the pre-allocated (but initially unused) streams. */
for (size_t i = 0; i < FOPEN_MAX - 3; ++i) {
_FILEEXT_SETUP(usual+i, usualext+i);
}
/* make sure we clean up on exit */
__atexit_register_cleanup(_cleanup); /* conservative */
__sdidinit = 1;
out:
_THREAD_PRIVATE_MUTEX_UNLOCK(__sinit_mutex);
}

View File

@@ -68,7 +68,23 @@ fread(void *buf, size_t size, size_t count, FILE *fp)
fp->_r = 0;
total = resid;
p = buf;
while (resid > (r = fp->_r)) {
// BEGIN android-added
// Avoid pathological behavior on unbuffered files. OpenBSD
// will loop reading one byte then memcpying one byte!
if ((fp->_flags & __SNBF) != 0) {
// We know if we're unbuffered that our buffer is empty, so
// we can just read directly.
while (resid > 0 && (r = (*fp->_read)(fp->_cookie, p, resid)) > 0) {
p += r;
resid -= r;
}
FUNLOCKFILE(fp);
return ((total - resid) / size);
}
// END android-added
while (resid > (size_t)(r = fp->_r)) {
(void)memcpy((void *)p, (void *)fp->_p, (size_t)r);
fp->_p += r;
/* fp->_r = 0 ... done in __srefill */

View File

@@ -32,6 +32,10 @@
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
__BEGIN_DECLS
/*
* The first few FILEs are statically allocated; others are dynamically
* allocated and linked in via this glue structure.
@@ -44,3 +48,5 @@ struct glue {
/* This was referenced by a couple of different pieces of middleware and the Crystax NDK. */
__LIBC64_HIDDEN__ extern struct glue __sglue;
__END_DECLS

View File

@@ -41,6 +41,8 @@
#include "wcio.h"
#include "fileext.h"
__BEGIN_DECLS
/*
* Android <= KitKat had getc/putc macros in <stdio.h> that referred
* to __srget/__swbuf, so those symbols need to be public for LP32
@@ -137,3 +139,5 @@ extern int __sfvwrite(FILE *, struct __suio *);
wint_t __fputwc_unlock(wchar_t wc, FILE *fp);
#pragma GCC visibility pop
__END_DECLS

View File

@@ -32,6 +32,10 @@
#ifndef _WCIO_H_
#define _WCIO_H_
#include <sys/cdefs.h>
__BEGIN_DECLS
/* minimal requirement of SUSv2 */
#define WCIO_UNGETWC_BUFSIZE 1
@@ -78,4 +82,6 @@ do {\
#define WCIO_INIT(fp) \
memset(&(_EXT(fp)->_wcio), 0, sizeof(struct wchar_io_data))
__END_DECLS
#endif /*_WCIO_H_*/

View File

@@ -132,9 +132,15 @@ public class ZoneCompactor {
throw new RuntimeException("zone filename too long: " + zoneName.length());
}
// Follow the chain of links to work out where the real data for this zone lives.
String actualZoneName = zoneName;
while (links.get(actualZoneName) != null) {
actualZoneName = links.get(actualZoneName);
}
f.write(toAscii(new byte[MAXNAME], zoneName));
f.writeInt(offsets.get(zoneName));
f.writeInt(lengths.get(zoneName));
f.writeInt(offsets.get(actualZoneName));
f.writeInt(lengths.get(actualZoneName));
f.writeInt(0); // Used to be raw GMT offset. No longer used.
}

View File

@@ -13,8 +13,11 @@ import sys
import tarfile
import tempfile
regions = ['africa', 'antarctica', 'asia', 'australasia', 'backward',
'etcetera', 'europe', 'northamerica', 'southamerica']
regions = ['africa', 'antarctica', 'asia', 'australasia',
'etcetera', 'europe', 'northamerica', 'southamerica',
# These two deliberately come last so they override what came
# before (and each other).
'backward', 'backzone' ]
def CheckDirExists(dir, dirname):
if not os.path.isdir(dir):
@@ -49,16 +52,16 @@ def WriteSetupFile():
fields = line.split()
if fields:
if fields[0] == 'Link':
links.append('%s %s %s\n' % (fields[0], fields[1], fields[2]))
links.append('%s %s %s' % (fields[0], fields[1], fields[2]))
zones.append(fields[2])
elif fields[0] == 'Zone':
zones.append(fields[1])
zones.sort()
setup = open('setup', 'w')
for link in links:
setup.write(link)
for zone in zones:
for link in sorted(set(links)):
setup.write('%s\n' % link)
for zone in sorted(set(zones)):
setup.write('%s\n' % zone)
setup.close()
@@ -114,27 +117,37 @@ def BuildIcuToolsAndData(data_filename):
# Build the ICU tools.
print 'Configuring ICU tools...'
subprocess.check_call(['%s/runConfigureICU' % icu_dir, 'Linux'])
print 'Making ICU tools...'
subprocess.check_call(['make', '-j32'])
# Run the ICU tools.
os.chdir('tools/tzcode')
# The tz2icu tool only picks up icuregions and icuzones in they are in the CWD
for icu_data_file in [ 'icuregions', 'icuzones']:
icu_data_file_source = '%s/tools/tzcode/%s' % (icu_dir, icu_data_file)
icu_data_file_symlink = './%s' % icu_data_file
os.symlink(icu_data_file_source, icu_data_file_symlink)
shutil.copyfile('%s/%s' % (original_working_dir, data_filename), data_filename)
print 'Making ICU data...'
# The Makefile assumes the existence of the bin directory.
os.mkdir('%s/bin' % icu_working_dir)
subprocess.check_call(['make'])
# Copy the output files to their ultimate destination.
# Copy the source file to its ultimate destination.
icu_txt_data_dir = '%s/data/misc' % icu_dir
print 'Copying zoneinfo64.txt to %s ...' % icu_txt_data_dir
shutil.copy('zoneinfo64.txt', icu_txt_data_dir)
# Regenerate the .dat file.
os.chdir(icu_working_dir)
subprocess.check_call(['make', '-j32'])
# Copy the .dat file to its ultimate destination.
icu_dat_data_dir = '%s/stubdata' % icu_dir
datfiles = glob.glob('data/out/tmp/icudt??l.dat')
if len(datfiles) != 1:
print 'ERROR: Unexpectedly found %d .dat files (%s). Halting.' % (len(datfiles), datfiles)
sys.exit(1)
datfile = datfiles[0]
print 'Copying %s to %s ...' % (datfile, icu_dat_data_dir)
shutil.copy(datfile, icu_dat_data_dir)
@@ -162,9 +175,10 @@ def BuildBionicToolsAndData(data_filename):
print 'Calling zic(1)...'
os.mkdir('data')
for region in regions:
if region != 'backward':
subprocess.check_call(['zic', '-d', 'data', 'extracted/%s' % region])
zic_inputs = [ 'extracted/%s' % x for x in regions ]
zic_cmd = ['zic', '-d', 'data' ]
zic_cmd.extend(zic_inputs)
subprocess.check_call(zic_cmd)
WriteSetupFile()

View File

@@ -2252,14 +2252,11 @@ static int __bionic_open_tzdata_path(const char* path_prefix_variable, const cha
}
static int __bionic_open_tzdata(const char* olson_id, int* data_size) {
int fd = __bionic_open_tzdata_path("ANDROID_DATA", "/misc/zoneinfo/tzdata", olson_id, data_size);
if (fd < 0) {
fd = __bionic_open_tzdata_path("ANDROID_ROOT", "/usr/share/zoneinfo/tzdata", olson_id, data_size);
if (fd == -2) {
// The first thing that 'recovery' does is try to format the current time. It doesn't have
// any tzdata available, so we must not abort here --- doing so breaks the recovery image!
fprintf(stderr, "%s: couldn't find any tzdata when looking for %s!\n", __FUNCTION__, olson_id);
}
int fd = __bionic_open_tzdata_path("ANDROID_ROOT", "/usr/share/zoneinfo/tzdata", olson_id, data_size);
if (fd == -2) {
// The first thing that 'recovery' does is try to format the current time. It doesn't have
// any tzdata available, so we must not abort here --- doing so breaks the recovery image!
fprintf(stderr, "%s: couldn't find any tzdata when looking for %s!\n", __FUNCTION__, olson_id);
}
return fd;
}

View File

@@ -3526,7 +3526,9 @@ static struct mallinfo internal_mallinfo(mstate m) {
nm.arena = sum;
nm.ordblks = nfree;
nm.hblkhd = m->footprint - sum;
nm.usmblks = m->max_footprint;
/* BEGIN android-changed: usmblks set to footprint from max_footprint */
nm.usmblks = m->footprint;
/* END android-changed */
nm.uordblks = m->footprint - mfree;
nm.fordblks = mfree;
nm.keepcost = m->topsize;

Binary file not shown.

View File

@@ -8,6 +8,7 @@ LOCAL_SRC_FILES:= \
linker.cpp \
linker_allocator.cpp \
linker_environ.cpp \
linker_libc_support.c \
linker_phdr.cpp \
rt.cpp \

Some files were not shown because too many files have changed in this diff Show More